Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to use @types/react #26

Open
korya opened this issue Apr 3, 2017 · 1 comment
Open

Fails to use @types/react #26

korya opened this issue Apr 3, 2017 · 1 comment

Comments

@korya
Copy link

korya commented Apr 3, 2017

I use ntypescript in webpack, mostly for 3rd party libraries. Recently I have added react to my project and started to get errors for @types/react:

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(171,34): error TS1005: ',' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(172,34): error TS1005: ',' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,43): error TS1005: ']' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,44): error TS1005: ';' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,45): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,46): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2636,61): error TS1005: '(' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/react/index.d.ts
(2695,1): error TS1128: Declaration or statement expected.

The problematic source code lines (causing the first error) are:

    // Base component for plain JS classes
    class Component<P, S> implements ComponentLifecycle<P, S> {
        constructor(props?: P, context?: any);
        setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
                                  The error points here
        setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
                                  ... and here
        forceUpdate(callBack?: () => any): void;
        render(): JSX.Element | null;

Is it caused by the fact that the type definition uses some syntax/features introduced in Typescript 2.2? Is there a workaround?

@korya
Copy link
Author

korya commented Apr 3, 2017

Just upgraded @types/lodash and got similar errors:

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,21): error TS1005: ']' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,22): error TS1005: ';' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,23): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,33): error TS1005: ']' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,34): error TS1005: ')' expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,35): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(11587,37): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(19580,1): error TS1128: Declaration or statement expected.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(241,13): error TS2300: Duplicate identifier '_'.

ERROR in /Users/korya/dev/superapp/node_modules/@types/lodash/index.d.ts
(245,19): error TS2300: Duplicate identifier '_'.

The problematic source code (causing the first error):

    type ConformsPredicateObject<T> = {
        [P in keyof T]: (val: T[P]) => boolean;
                     The error points here
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant