Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

generate tsconfig

npx tsc --init
Comment

exclude folder from typescript compiler tsconfig.json

{
  "compilerOptions": {
    ...
  },
  "exclude": ["node_modules", "**/node_modules/*"]
}
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 resolve require json

{
  "compilerOptions": {
	// ...
    "resolveJsonModule": true,
	// ...
  }
}
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

PREVIOUS NEXT
Code Example
Typescript :: if image is broken show alternative image angular 
Typescript :: add dots to line matplotlib 
Typescript :: typescript sort number array descending 
Typescript :: angular 13 viewchild 
Typescript :: when to stop testing 
Typescript :: typescript class interface 
Typescript :: typescript type function callback in interface 
Typescript :: ternary operator in typescript 
Typescript :: SocketException: An attempt was made to access a socket in a way forbidden by its access permissions. in core 6.0 
Typescript :: how to get docker stats using shell script 
Typescript :: typescript get the time moment 
Typescript :: nested slots in vue 
Typescript :: Catch clause variable cannot have a type annotation. 
Typescript :: ts singleton pattern 
Typescript :: navigate in new tab with query params angular 
Typescript :: typescript append row in html table 
Typescript :: union types typescript 
Typescript :: typescript returntype remove promise 
Typescript :: add legends to y plots matplotlib 
Typescript :: write a script that prints hello world followed by a new line to the standard output in linux 
Typescript :: hide elements in 2s jquery 
Typescript :: props vue typescript 
Typescript :: the events calendar update the word event 
Typescript :: auto complete of process.env in typescript 
Typescript :: typescript dom type 
Typescript :: how to keep only certian objects python 
Typescript :: fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break Identify output ? 
Typescript :: update object in array in ngxrx store in angular 
Typescript :: bits required for address 1 GB memory 
Typescript :: no corners in broder css 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =