Skip to content

TS2823 import attributes error when using node16 moduleΒ #60507

@canassa

Description

@canassa

πŸ”Ž Search Terms

TS2823 import attributes node16 module

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about 5.6.3 and dev

⏯ Playground Link

https://www.typescriptlang.org/play/?target=99&moduleResolution=99&module=100&ts=5.8.0-dev.20241115#code/JYWwDg9gTgLgBGAhgYwNaIOYFMBSBnCAOzgDMoIQ4ByAOgHok1MsaArAwquAd2BgAs4AbzgwAnmCwAuauyJcAvkA

πŸ’» Code

import packageJson from './package.json' with { type: 'json' }

πŸ™ Actual behavior

We get the following error:

TS2823: Import attributes are only supported when the --module option is set to esnext, nodenext, or preserve

πŸ™‚ Expected behavior

The docs state the following:

nodenext: Currently identical to node16, but will be a moving target reflecting the latest Node.js versions as Node.js’s module system evolves.

Either the syntax should be supported on node16 or the documentation needs to be updated.

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

DocsThe issue relates to how you learn TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions