algolia / angular-instantsearch

⚡️Lightning-fast search for Angular apps, by Algolia
https://algolia.com/doc/deprecated/instantsearch/angular/v4/api-reference/instantsearch/
MIT License
261 stars 73 forks source link

[Bug] 'updateState' in type 'NgAisVoiceSearch' is not assignable to the same property in base type 'BaseWidget' #704

Open asithade opened 4 years ago

asithade commented 4 years ago

Describe the bug 🐛

Added the latest beta version of angular-instantsearch and when I try to run my project, I'm getting the following error:

ERROR in ../../../node_modules/angular-instantsearch/voice-search/voice-search.d.ts:39:5 - error TS2416: Property 'updateState' in type 'NgAisVoiceSearch' is not assignable to the same property in base type 'BaseWidget'.
  Type '(state: State) => void' is not assignable to type '(state: {}, isFirstRendering: boolean) => void | Promise<void>'.
    Types of parameters 'state' and 'state' are incompatible.
      Type '{}' is missing the following properties from type 'State': isBrowserSupported, isListening, toggleListening, voiceListeningState, templateContext

39     updateState: (state: State) => void;

To Reproduce 🔍

Steps to reproduce the behavior:

yarn add angular-instantsearch@3 -- select beta 4 ng serve

Haroenv commented 4 years ago

Can you show which typescript configuration you have? It might be that you have a stricter setup than the one Angular InstantSearch is made with. Ideally this would be reproducible in a GitHub repository. Thanks!

asithade commented 4 years ago

If we set strict to false in the tsconfig.ts, it compiles fine. Ideally we can still keep that turned on and have this compile though.

{
  "compileOnSave": true,
  "compilerOptions": {
    "downlevelIteration": true,
    "module": "esnext",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": false,
    "target": "es2015",
    "typeRoots": ["../../node_modules/@types/"],
    "lib": ["es2017", "dom"],
    "baseUrl": "src",
    "paths": {
      "@app/*": ["app/*"],
      "@modules/*": ["app/modules/*"],
      "@services/*": ["app/services/*"],
      "@models/*": ["app/core/models/*"],
      "@shared/*": ["app/shared/*"],
      "@environments/*": ["environments/*"]
    },
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "preserveWhitespaces": false
  }
}
asithade commented 4 years ago

Note: Adding skipLibCheck to true will also bypass this error