Skip to content

node18 and strictest configs incompatibility #168

@SkeLLLa

Description

@SkeLLLa

Environment:
Node: 18
Typescript: 5.0.4

Steps to reproduce:

  1. Create a simple project with typescript 5 and configs: npm i -D @tsconfig/strictest @tsconfig/node18 typescript @types/node
  2. Create a index.ts file with following contents
import { readFileSync } from 'node:fs';

export function test() {
  console.log(readFileSync('./index.ts'))
}
  1. Use tsconfig.json from README:
{
  "extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"]
}
  1. Compile code using tsc

Expected result:

Code compiles without errors.

Actual result:

Code compilation fails with errors:

src/index.ts:1:10 - error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.

1 import { readFileSync } from 'node:fs';
           ~~~~~~~~~~~~

src/index.ts:3:1 - error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.

3 export function test() {
  ~~~~~~

Extras:
Nether using "type": "module" in package.json, nor using .mts , .cts extensions not helping.

Suggestions:

  • Maybe it worth to set "verbatimModuleSyntax": false, in all node* configs, unless they have "module": "commonjs"
  • Move "verbatimModuleSyntax": true, to @tsconfig/esm, since it doesn't works only with esm.

Related to #161

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions