Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

generate tsconfig

npx tsc --init
Comment

tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}
Comment

typescript tsconfig.json file

{
  "compilerOptions": {
    "module": "esnext",
    "target": "es2016",
    "jsx": "react-jsx",
    "strictFunctionTypes": true,
    "sourceMap": true,
    "outDir": "./build",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true
  },
  "exclude": ["node_modules", "**/node_modules/*"],
  "include": ["src", "electron/renderer.ts"]
}

Comment

init tsconfig file

// source from https://stackoverflow.com/questions/36916989/how-can-i-generate-a-tsconfig-json-file
$ tsc --init
// Try to run in your console the following to check the version:
$ tsc -v
// If the version is older than 1.6 you will need to update:
$ npm install -g typescript
// Remember that you need to install node.js to use npm.
Comment

basic tsconfig file

{
    "compilerOptions": {
      "outDir": "./dist/",
+     "sourceMap": true,
      "noImplicitAny": true,
      "module": "commonjs",
      "target": "es5",
      "jsx": "react",
      "allowJs": true,
      "moduleResolution": "node",
    }
  }
Comment

generate tsconfig

[1] $ tsc -v
[2] If the version is older than 1.6:
	$ npm install -g typescript
[3] $ tsc --init
Comment

tsconfig.json

// mytsconfig.
{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": false,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "typeRoots": ["src/types", "node_modules/@types"],
        "baseUrl": "src",
        "paths": {
            "@/*": ["*"] // matching @src/* to src/*
        },
        "outDir": "dist",
        "experimentalDecorators": true,
        
    },
    "exclude": ["node_modules", "dist"],
    "include": ["src/**/*","src/*"]
}
Comment

tsconfig.json, Typescript

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "jsxImportSource": "preact"
  }
}
Comment

build with tsconfig-paths

{
  "scripts": {
    "start": "node -r tsconfig-paths/register -r ts-node                 
              ./src/index/ts",
    "build": "tsc --project tsconfig.json && tscpaths -p
              tsconfig.json -s ./src -o ./dist"
  }
}
Comment

comments tsconfig.json

In some files the option for checking comments is off by default 
(tsconfig, tslint and eslint configs), as corresponding tools allow comments in
JSON (this is hardcoded). 

So IDEs recognize this and allow you to add comments even if standard 
doesnt allow.
Comment

PREVIOUS NEXT
Code Example
Typescript :: subplots matplotlib 
Typescript :: render async function to component 
Typescript :: pandas check if row exists in another dataframe 
Typescript :: locking value of cell 
Typescript :: how to add lint is declared but its value is never read. 
Typescript :: for in ts 
Typescript :: c# copy the elements of a list to another list 
Typescript :: api service in angular 
Typescript :: typescript list concat 
Typescript :: check anagramm in typescript 
Typescript :: useformik type for typescript 
Typescript :: admin_enqueue_scripts specific page 
Typescript :: Already included file name react tsconfig 
Typescript :: react-excel-renderer 
Typescript :: typescript final example 
Typescript :: decoDe query string to object javascript 
Typescript :: call function dynamically typescript 
Typescript :: typescript null and undefined check 
Typescript :: filter() array of objects on change react 
Typescript :: custom link react 
Typescript :: input deno 
Typescript :: react native paper 
Typescript :: typescrpt add onject to window namespace 
Typescript :: typescript one of array 
Typescript :: cmd move all files to parent directory 
Typescript :: typescript default value if null 
Typescript :: No type arguments expected for interface Callback 
Typescript :: how to reset windows update components in windows 
Typescript :: typeorm configuration typescript 
Typescript :: Scroll, Position 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =