ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

`ts-node --init`, like `tsc --init`, to emit config file

Open cspotcode opened this issue 4 years ago • 0 comments

Link to discord conversation about this: https://discord.com/channels/508357248330760243/508357248330760249/932730462571474984

ts-node --init can behave roughly like tsc --init: emit tsconfig configuration

If tsconfig already exists, add "ts-node" sub-object to it If tsconfig does not already exist, emit one based off @tsconfig/bases

Check TS version. When "module": "nodenext" is available, set appropriate compilerOptions.

Example config WIP, inspired by tsc's init output, but using @tsconfig/bases to be more node-specific

{
  /*
   * Chosen based on your node version: 17.3.1
   * https://github.com/tsconfig/bases/blob/main/bases/node16.json
   */
  "extends": "ts-node/node16/tsconfig.json",

  "ts-node": {
    /* Visit https://typestrong.org/ts-node/docs/configuration to read more about these options */

    // "swc": true,                /*
                                    * Enable for faster startup without typechecking.
                                    * Requires swc dependency:
                                    * `yarn add @swc/core` / `yarn add @swc/wasm` / `npm install @swc/core` / `npm install @swc/wasm`
                                    */
    // "files": true,              /* Enable to fix some typechecking issues with missing types */
    // "ignoreDiagnostics": [],    /* Suppress certain TS diagnostic codes */
    // "skipIgnore": true,         /*
                                    * Enable to compile TypeScript in `node_modules`.
                                    * Necessary, for example, to run TS directly from git via `yarn dlx` or `npx`.
                                    */
    // "ignore": []                /* Override default ignore rules with custom regexps */
    "compilerOptions": {
      /* Override TypeScript compiler options in ts-node */
    }
  }
}

cspotcode avatar Jan 23 '22 02:01 cspotcode