Skip to content

Fails to use @types/react #26

@korya

Description

@korya

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions