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

@material-ui/core v1.x.x TS2344 error #11629

Closed
ptommasi opened this issue May 29, 2018 · 2 comments
Closed

@material-ui/core v1.x.x TS2344 error #11629

ptommasi opened this issue May 29, 2018 · 2 comments

Comments

@ptommasi
Copy link

My UI is failing to compile because of a TS2344 error in file @material-ui/core/TextField/TextField.d.ts, in detail:

(11,62): error TS2344: Type '"defaultValue" | "onChange"' does not satisfy the constraint '"classes" | "component" | "innerRef" | "className" | "style" | "margin" | "disabled" | "fullWidth...'.
Type '"defaultValue"' is not assignable to type '"classes" | "component" | "innerRef" | "className" | "style" | "margin" | "disabled" | "fullWidth...'.

I had the same issue in the past with a beta version, and I solved thanks to Material-ui-next typescript error, but same trick didn't work. I also tried to copy and paste the configuration from the stack overflow answer, but npm wasn't able to find that exact versions of the packages.

Checking the file TextField.d.ts and following FormControlProps declaration coming from file FormControl.d.ts, I noticed an error "[ts] Type 'ReactType' is not generic." on the declaration component?: React.ReactType<FormControlProps>;, don't know if that's the triggering cause.

At the moment package.json looks like:

	... 
	"dependencies": {
		"@material-ui/core": "^1.1.0",
		"immutability-helper": "^2.7.0",
		"node-sass-chokidar": "0.0.3",
		"npm-run-all": "^4.1.3",
		"react": "^16.4.0",
		"react-dom": "^16.4.0",
		"react-redux": "^5.0.7",
		"react-s-alert": "^1.4.1",
		"react-scripts-ts": "2.4.0",
		"react-tippy": "^1.2.2",
		"redux-logger": "^3.0.6",
		"redux-thunk": "^2.3.0",
		"serve": "^6.5.8"
	},
	"devDependencies": {
		"@types/jest": "^20.0.4",
		"@types/node": "^8.0.14",
		"@types/react": "^16.3.14",
		"@types/react-dom": "^16.0.5",
		"@types/react-redux": "^5.0.20",
		"@types/react-s-alert": "^1.3.1",
		"@types/redux-logger": "^3.0.5"
	},
	...

This is the first time I use v1 of Material-UI (since 0.xx is not supported anymore), I tried different version combinations for @material-ui/core (1.0.0, 1.1.0) and react / react-dom / @types/react / @types/react-dom (different v16 releases, v15 too out of desperation), no luck with any combination.

Any idea?

@zr3
Copy link

zr3 commented Jun 2, 2018

It looks like this is caused by an update to typescript itself and has been fixed here, but not published yet: #11656

There's a workaround in that issue that I just tried out in the mean time, and it works. I have a new app created with create-react-app, installed the latest material-ui, and added { "compilerOptions": { "keyofStringsOnly": true } }, and no more problem.

@oliviertassinari
Copy link
Member

I'm gonna assume the issue if fixed now.

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

3 participants