Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

generate tsconfig

npx tsc --init
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

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

pass tsconfig.json to node command

# To force the use of a specific tsconfig.json, use the TS_NODE_PROJECT environment variable
TS_NODE_PROJECT="path/to/tsconfig.json" node --loader ts-node/esm ./my-script.ts
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 :: see sheets of excel file python 
Typescript :: how to know if window exists in nodejs 
Typescript :: angular date to string format 
Typescript :: style mat-dialog-container 
Typescript :: get ids of array of objects 
Typescript :: voting results 2020 live 
Typescript :: how do i remove the brackets around a list in python 
Typescript :: angular array filter typescript 
Typescript :: symfony assets install 
Typescript :: why is a tree set sorted 
Typescript :: test management 
Typescript :: @babel/preset-typescript 
Typescript :: exposants python 
Typescript :: ngclass stackoverflow 
Typescript :: how to route to another page in angular 
Typescript :: uncheck all checkboxes typescript 
Typescript :: get last item from array ts 
Typescript :: Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk/cmdline-tools/latest/ 
Typescript :: Check if a temporary table exists and delete if it exists 
Typescript :: latex figure over two columns 
Typescript :: react-native.ps1 cannot be loaded because running scripts is disabled on this system 
Typescript :: python get first n elements of list 
Typescript :: class typescript constructor 
Typescript :: how to target all child elements css 
Typescript :: angular set query params 
Typescript :: typescript break for each 
Typescript :: typescript array of react elements 
Typescript :: howt o make sure its a valid sudoku in python 
Typescript :: how to declare variable in typescript 
Typescript :: subplots matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =