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

create-react-app-with-typescript: TS2344: 'Type Removals | "classes"' does not satisfy constraint 'string' #11656

Closed
2 tasks done
mathenshall opened this issue May 31, 2018 · 12 comments

Comments

@mathenshall
Copy link

  • 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.

Expected Behavior

Demo page should render without an error.

Current Behavior

On following instructions to clone (using curl command line provided in readme) the following error is shown in the browser:-
/Users/xxxxxx/create-react-app-with-typescript/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'.
The package.json specifies 'latest' for all dependancies, and it seems that material-ui typings are not compatible with Typescript version 2.9.1. Changing the version to 2.8.1 fixes the issue.

Steps to Reproduce (for bugs)

Follow instructions on readme for create-react-app-with-typescript

@giantryansaul
Copy link

We are getting the same error. Only happens on Typescript 2.9.x, does not happen on 2.8.x.

@Nufflee
Copy link

Nufflee commented May 31, 2018

Same exact issue here. @giantryansaul

@feddyups
Copy link

feddyups commented May 31, 2018

same issue.
`ERROR in [at-loader] ./node_modules/@material-ui/core/index.d.ts:12:3
TS2344: 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'.

ERROR in [at-loader] ./node_modules/@material-ui/core/index.d.ts:57:77
TS2344: Type 'keyof U' does not satisfy the constraint 'string'.
Type 'string | number | symbol' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.`

does not appear when Typescript is locked down to 2.8.4

@mctep
Copy link
Contributor

mctep commented Jun 1, 2018

TS 2.9 has start support number and sybmol types for keyof. It is possible to disable this behaviour with keyofStringsOnly option as workaround.

https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#keyof-now-includes-string-number-and-symbol-keys

@olee
Copy link
Contributor

olee commented Jun 1, 2018

I am also getting lots of these errors wherever I import material-ui components with Typescript 2.9

(33,14): JSX element type 'Grid' does not have any construct or call signatures.

but it only seems to happen when I do imports like

import Grid from '@material-ui/core/Grid';

@JustinSomers
Copy link

JustinSomers commented Jun 1, 2018

With @mctep's suggestion, I set the "keyOfStringsOnly" option to true in my tsconfig.json file, which fixed the issue:
{ "compilerOptions": { "keyofStringsOnly": true },

@feddyups
Copy link

feddyups commented Jun 1, 2018

@mctep : the workaround suggested will be good enough for now, thanks!

@Bessonov
Copy link

Bessonov commented Jun 2, 2018

Run in same issue like @olee . Downgraded ts to 2.8.3.

@romainquellec
Copy link

same !

@mctep
Copy link
Contributor

mctep commented Jun 4, 2018

@olee @Bessonov It may be related to #11698

@klundgren
Copy link

I'm getting this similar error with TS 2.9 and TS 3.2:

TS2344: Type '"align"' does not satisfy the constraint '"hidden" | "dir" | "slot" | "style" | "title" | "color" | "children" | "headers" | "prefix" | "lang" | "id" | "colSpan" | "placeholder" | "rowSpan" | "scope" | "defaultChecked" | ... 236 more ... | "onTransitionEndCapture"'.

@eps1lon
Copy link
Member

eps1lon commented Jan 16, 2019

I'm getting this similar error with TS 2.9 and TS 3.2:

TS2344: Type '"align"' does not satisfy the constraint '"hidden" | "dir" | "slot" | "style" | "title" | "color" | "children" | "headers" | "prefix" | "lang" | "id" | "colSpan" | "placeholder" | "rowSpan" | "scope" | "defaultChecked" | ... 236 more ... | "onTransitionEndCapture"'.

@klundgren This is a possible duplicate of #14179. Could you please follow #14179 (comment). If this doesn't help please open a new issue and follow the issue template.

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