Skip to content

node24 TypeScript import issues #345

Description

@Daniel15

tsconfig.json:

{
  "extends": ["@tsconfig/strictest/tsconfig.json", "@tsconfig/node24/tsconfig.json"],
  "include": ["**/*"],
  "exclude": ["node_modules", "**/dist"]
}

package.json has "type": "module".

import {Foo} from './Foo' gives me an error:

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'?
ts(2835)

import {Foo} from './Foo.ts' also gives me an error:

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled
.ts(5097)

Adding these options to the tsconfig makes it work:

  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "noEmit": true
  }

but it shouldn't be necessary to modify the config to get it working.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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