error TS2304: Cannot find name 'T'
See original GitHub issueVersion
2.10.4
Environment
Windows 10, Chrome 58.0, “react”: “^15.5.4”, “react-scripts-ts”: “2.2.0”, typescript: 2.3.2
Reproduction link
https://github.com/danprime/antdtypescript
Steps to reproduce
- Setup A ReactJS Project:
create-react-app antdsample --scripts-version=react-scripts-ts
- Add ANTD
yarn add antd --save
- Import a Button into App.tsx
import {Button} from 'antd';
- Add
<Button>Test Button</Button>
within render() function.
ref: https://github.com/Microsoft/TypeScript-React-Starter
Or clone reproduction link, type npm install, then npm start.
What is expected?
Should render the basic Create React App page with a Button labeled “Test button”
What is actually happening?
I get a screen with the error:
Failed to compile /mnt/c/Users/danpr/workspace/ts2/node_modules/antd/lib/table/Column.d.ts (29,61): error TS2304: Cannot find name ‘T’. This error occurred during the build time and cannot be dismissed.
Here’s my tsconfig.json
{
"compilerOptions": {
"outDir": "build/dist",
"module": "es6",
"target": "es6",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "preserve",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
],
"types": [
"typePatches"
]
}
package.json
{
"name": "ts2",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "^19.2.3",
"@types/node": "^7.0.22",
"@types/react": "^15.0.25",
"@types/react-dom": "^15.5.0",
"antd": "^2.10.4",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"react-scripts-ts": "2.2.0"
},
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:24 (11 by maintainers)
Top Results From Across the Web
Error:(19, 35) TS2304: Cannot find name 'T'. Why I can' ...
But I get TS error Error:(19, 35) TS2304: Cannot find name 'T'. 1) Why error? <T> is generic type. It can't be declared...
Read more >Cannot find name 'T'. Why I can't extend interface in TS ...
I want to extend an interface for React props. But I get TS error Error:(19, 35) TS2304: Cannot find name 'T'. 1) Why...
Read more >TypeScript error TS2304 cannot find name require
The error that I'm getting is the "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page....
Read more >Fix the Cannot Find Name 'require' Error in TypeScript
To fix the “cannot find name 'require'” error in TypeScript, install the @types/node package into your project by running npm i -D @types/node...
Read more >Cannot find name 'T'. Why I can't extend interface in TS?- ...
[Solved]-Error:(19, 35) TS2304: Cannot find name 'T'. Why I can't extend interface in TS?-Reactjs ... Simple function example. Just extend the ObjectLiteral type....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Alternatively, while waiting the fix to be released, you can temporarily set
"skipLibCheck": true
intsconfig.json
.I will try to find more info. But if we cannot solve this issue, I think we need to downgrade to TypeScript@2.2.x