Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Re-export node-relevant @tsconfig/bases; use by default in absence of a tsconfig file #1202

@cspotcode

Description

@cspotcode

This is technically 2 features in one:

a) re-export @tsconfig/bases so that a user's tsconfig can, for example, "extends": "ts-node/node14/tsconfig.json"
b) in the absence of a tsconfig, check node version and use a suitable default.

https://github.com/tsconfig/bases

This allows ts-node to handle bare scripts using modern language features. For example, bigint literals require a modern "target" option which tsc does not adopt by default. If someone tried to write a ts-node shebang script using bigint literals, it would fail to compile unless they accompanied it with a tsconfig.json.

Note: changelog below mentions CLI and programmatic flags to disable this automatic base config.
Decided that was not necessary but put an implementation in #1249

TODO

  • add CLI flag --skip-default-project
    • UPDATE decided to omit this feature until it is requested, per discord discussion below.
      Users can always create a tsconfig.json to suppress default project, or specify --compiler-options to override options)
  • update programmatic option to match? skipDefaultProject?
    • not implemented, see rationale above
  • what to name the CLI flag
  • extract CLI flag to another PR; do not implement it in this first pass
  • add tests
  • newer @tsconfig/bases are incompatible with Typescript 2.7: how to handle this?
    • can check ts.ScriptTarget and ts.libs to ensure they have the necessary entries. If node14 config is incompatible, try node12, then node10
    • TS 3.4 added target ES2019 but does not have the necessary require('typescript').libs entries for the node12 tsconfig, so checking libs is necessary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions