Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding TypeScript support to Create React Library

Adding TypeScript support to Create React Library

Install Typescript packages:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

Create a tsconfig.json file in the root folder

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "noImplicitAny": false,
    "strictNullChecks": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noImplicitThis": true
  },
  "include": [
    "src"
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.