piotrwitek / react-redux-typescript-guide

The complete guide to static typing in "React & Redux" apps using TypeScript
https://piotrwitek.github.io/react-redux-typescript-guide/
MIT License
13.35k stars 1.09k forks source link

VSCode problems tab reporting errors in playground. #172

Closed parkerault closed 5 years ago

parkerault commented 5 years ago

There don't seem to be any problems reported by tsc so no big deal, but the VSCode problems tab is reporting several issues in the playground project. I know this is outside of the scope of your work on this project, but this can definitely trip up new typescript users like myself.

src/features/todos/epics.spec.ts

Cannot find module 'MyTypes'.
No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments.

src/features/todos/reducer.spec.ts

Module '"."' has no exported member 'TodosState'.

src/hoc/with-error-boundary.tsx

Conversion of type 'ComponentType<BaseProps>' to type 'ComponentType<InjectedProps>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'FunctionComponent<BaseProps>' is not comparable to type 'ComponentType<InjectedProps>'.
    Type 'FunctionComponent<BaseProps>' is not comparable to type 'FunctionComponent<InjectedProps>'.
      Types of parameters 'props' and 'props' are incompatible.
        Type 'PropsWithChildren<InjectedProps>' is not comparable to type 'PropsWithChildren<BaseProps>'.
          Type 'PropsWithChildren<InjectedProps>' is not comparable to type 'BaseProps'.
            'PropsWithChildren<InjectedProps>' is assignable to the constraint of type 'BaseProps', but 'BaseProps' could be instantiated with a different subtype of constraint 'InjectedProps'.

src/hoc/with-state.tsx

Conversion of type 'ComponentType<BaseProps>' to type 'ComponentType<InjectedProps>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'FunctionComponent<BaseProps>' is not comparable to type 'ComponentType<InjectedProps>'.
    Type 'FunctionComponent<BaseProps>' is not comparable to type 'FunctionComponent<InjectedProps>'.
      Types of parameters 'props' and 'props' are incompatible.
        Type 'PropsWithChildren<InjectedProps>' is not comparable to type 'PropsWithChildren<BaseProps>'.
          Type 'PropsWithChildren<InjectedProps>' is not comparable to type 'BaseProps'.
            'PropsWithChildren<InjectedProps>' is assignable to the constraint of type 'BaseProps', but 'BaseProps' could be instantiated with a different subtype of constraint 'InjectedProps'.

Screenshot of full list of errors:

image

piotrwitek commented 5 years ago

Hey, are you sure these errors are reported by TS version supplied with the project?

On Fri, Jun 28, 2019, 8:52 PM parkerault notifications@github.com wrote:

There don't seem to be any problems reported by tsc so no big deal, but the VSCode problems tab is reporting several issues in the playground project. I know this is outside of the scope of your work on this project, but this can definitely trip up new typescript users like myself.

src/features/todos/epics.spec.ts

Cannot find module 'MyTypes'. No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments.

src/features/todos/reducer.spec.ts

Module '"."' has no exported member 'TodosState'.

src/hoc/with-error-boundary.tsx

Conversion of type 'ComponentType' to type 'ComponentType' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'FunctionComponent' is not comparable to type 'ComponentType'. Type 'FunctionComponent' is not comparable to type 'FunctionComponent'. Types of parameters 'props' and 'props' are incompatible. Type 'PropsWithChildren' is not comparable to type 'PropsWithChildren'. Type 'PropsWithChildren' is not comparable to type 'BaseProps'. 'PropsWithChildren' is assignable to the constraint of type 'BaseProps', but 'BaseProps' could be instantiated with a different subtype of constraint 'InjectedProps'.

src/hoc/with-state.tsx

Conversion of type 'ComponentType' to type 'ComponentType' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'FunctionComponent' is not comparable to type 'ComponentType'. Type 'FunctionComponent' is not comparable to type 'FunctionComponent'. Types of parameters 'props' and 'props' are incompatible. Type 'PropsWithChildren' is not comparable to type 'PropsWithChildren'. Type 'PropsWithChildren' is not comparable to type 'BaseProps'. 'PropsWithChildren' is assignable to the constraint of type 'BaseProps', but 'BaseProps' could be instantiated with a different subtype of constraint 'InjectedProps'.

Screenshot of full list of errors:

[image: image] https://user-images.githubusercontent.com/78856/60364094-f9720500-99aa-11e9-91eb-c100ad4eae91.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/piotrwitek/react-redux-typescript-guide/issues/172?email_source=notifications&email_token=AAFUOA47M7BHAXPI6UB76CDP4ZMWDA5CNFSM4H4HX222YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4MCWEQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFUOA4ZLNLTN5H746FIGH3P4ZMWDANCNFSM4H4HX22Q .

parkerault commented 5 years ago

Looks like it's running 3.5.1. I hadn't looked up how VSCode manages typescript versions, but apparently it uses the latest stable version unless you point it at a custom tsc binary in the settings.

piotrwitek commented 5 years ago

In general, if you have typescript installed in your node_modules dependencies you should use that instead of the default one. I'm closing this as this is a false alert.

Also please notice that at the top of the repo you have listed the supported TS version.