-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
I'm trying to format a TypeScript file called index.ts with the following line inside:
import content from "./content.json" assert { type: "json" }; …but I get the following error:
[error] src/index.ts: SyntaxError: This experimental syntax requires enabling one of the following parser plugin(s): "importAttributes", "importAssertions". (3:37)
I tried adding a babel.config.json file containing the following:
{
"plugins": ["importAttributes"],
"parserOpts": {
"plugins": ["importAttributes"]
}
}…but it didn't work.
I also tried installing @babel/plugin-syntax-import-assertions and putting it in babel.config.json, .babelrc, .prettierrc.json as well, etc, but nothing seems to enable the plugin.
Environments:
- Prettier Version: 3.1.1, @babel/parser 7.23.6 (from package-lock.json)
- Running Prettier via:
npx prettier --write . - Runtime: Node v20.9.0, npm 10.1.0
- Operating System: macOS Ventura 13.6.3
- Prettier plugins (if any): @trivago/prettier-plugin-sort-imports (don't think it's relevant)
Steps to reproduce:
Try to format the aforementioned line with Prettier 3.1.1 and you'll see an error.
Metadata
Metadata
Assignees
Labels
lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.