Skip to content

TS1324 false positive despite module: node20 being set #2137

@wojtekmaj

Description

@wojtekmaj

I've tested tsgo against my server codebase. In this codebase I import a few json files dynamically.

I got unexpected errors that I don't get on latest stable TypeScript version:

src/file.ts:28:5 - error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.

28     {
       ~
29       with: { type: 'json' },
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30     }
   ~~~~~

Understandable, but here's my tsconfig.json:

{
  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "erasableSyntaxOnly": true,
    "incremental": true,
    "isolatedModules": true,
    "lib": ["es2024"],
    "module": "node20",
    "moduleDetection": "force",
    "noEmit": true,
    "noUncheckedIndexedAccess": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "es2024",
    "verbatimModuleSyntax": true
  }
}

Clearly, module is set to "node20" which is one of the values mentioned as accepted in the error message.

I also made sure and I do not run tsgo with any additional flags that could have overwritten my config file.

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