question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error TS2304: Cannot find name 'T'

See original GitHub issue

Version

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

  1. Setup A ReactJS Project: create-react-app antdsample --scripts-version=react-scripts-ts
  2. Add ANTD yarn add antd --save
  3. Import a Button into App.tsx import {Button} from 'antd';
  4. 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:closed
  • Created 6 years ago
  • Comments:24 (11 by maintainers)

github_iconTop GitHub Comments

9reactions
panjieswcommented, Jun 4, 2017

Alternatively, while waiting the fix to be released, you can temporarily set "skipLibCheck": true in tsconfig.json.

4reactions
benjycuicommented, Jun 1, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found