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

Typescript error: TS2694 - "no exported member RefObject" in @material-ui/core v.1.x #11643

Closed
2 tasks done
definitelynotsoftware opened this issue May 30, 2018 · 6 comments
Closed
2 tasks done

Comments

@definitelynotsoftware
Copy link

definitelynotsoftware commented May 30, 2018

I think this is mainly a TypeScript issue? I've attempted to upgrade to both material-ui v1.0 and v1.1 using TypeScript 2.8.3, but I'm unable to compile and run.

Full error:

in [at-loader] ./node_modules/@material-ui/core/styles/withStyles.d.ts:46:37
TS2694: Namespace 'React' has no exported member 'RefObject'.

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Your Environment

Tech Version
Material-UI v1.x.0
React 16.4.0
TypeScript 2.8.3
types/react ^ 16.3.0
@lummish
Copy link

lummish commented Jun 1, 2018

I was able to resolve this error by updating to Typescript 2.9.1, however now I'm getting a different error:

.../node_modules/@material-ui/core/index.d.ts
(12,3): Type '"classes" | Removals' does not satisfy the constraint 'string'. 
    Type 'Removals' is not assignable to type 'string'.
      Type 'keyof C' is not assignable to type 'string'.
        Type 'string | number | symbol' is not assignable to type 'string'.
          Type 'number' is not assignable to type 'string'.

@lummish
Copy link

lummish commented Jun 1, 2018

@danbergman Reference issue #11669 for a fix. Looks like it's been fixed but the fix hasn't made it to release yet. In the mean time, simply removing the string requirement for the key type in Omit should get rid of the issue.

@JakeDluhy
Copy link

Upgrading to typescript 2.9.1 did not work for me. I'm on [email protected], @types/[email protected], [email protected]

@CodeJjang
Copy link

@JakeDluhy Same here, I also tried to add the allowSyntheticDefaultImports: false to tsconfig as some suggested but it didn't work either.

I also tried with the latest dev version of typescript 3.

I just can't make my code compile. Does anyone have a solution?

@lummish What versions do you use?

@t49tran
Copy link
Contributor

t49tran commented Jun 7, 2018

It's more of a problem with your version of @types/react rather than material-ui or typescript. Update your @types/react to the latest version will solve the problem.

RefObject is declared inside React namespace like below under the latest version of @types/react:

declare namespace React {
    //
    // React Elements
    // ----------------------------------------------------------------------
    type ReactType<P = any> = string | ComponentType<P>;
    type ComponentType<P = {}> = ComponentClass<P> | StatelessComponent<P>;

    type Key = string | number;

    interface RefObject<T> {
        readonly current: T | null;
    }

Check your node_modules/@types/react to see if RefObject declaration is missing.

@t49tran
Copy link
Contributor

t49tran commented Jun 29, 2018

@oliviertassinari, I think this issue can be closed if there is no further update / report.

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

No branches or pull requests

6 participants