You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the behavior in every version I tried, and I reviewed the FAQ for entries about import attributes and type only imports
I was unable to test this on prior versions because _______
⏯ Playground Link
Couldn't get playground to create a separate module, so attaching a minimal example typescript-json-repro.zip
run
npm i
npm run build
💻 Code
// tsc fails with: Importing a JSON file into an ECMAScript module requires a 'type: "json"'importtypeenMessagesfrom"./en.json";
🙁 Actual behavior
When I try to address the issue as TSC suggests I run into another:
// tsc fails with: Importing a JSON file into an ECMAScript module requires a 'type: "json"'importtypeenMessagesfrom"./en.json";// tsc fails with: Import attributes cannot be used with type-only imports or exports. ts(2857)importtypeenMessagesfrom"./en.json"with{type: "json"};// tsc is happy but me and eslint are not, I don't use imported module for anything other than typings in this caseimportenMessagesfrom"./en.json"with{type: "json"};
🙂 Expected behavior
Type only imports should not require specifying 'type: "json"' as they are not retained in the JS output. Alternatively import attributes should be allowed with type only imports. One of the options below should work
We've encountered the same issue when upgrading from 5.6.3 to 5.7.2 (PREreview/prereview.org#2130). Making it a regular import leads to an import/no-extraneous-dependencies ESLint failure, as the package we're importing from is only used for its types (as so is a dev dependency).
🔎 Search Terms
"import attributes", "import assert", "type json"
🕗 Version & Regression Information
⏯ Playground Link
Couldn't get playground to create a separate module, so attaching a minimal example
typescript-json-repro.zip
run
💻 Code
🙁 Actual behavior
When I try to address the issue as TSC suggests I run into another:
🙂 Expected behavior
Type only imports should not require specifying 'type: "json"' as they are not retained in the JS output. Alternatively import attributes should be allowed with type only imports. One of the options below should work
Additional information about the issue
tsconfig.json
The text was updated successfully, but these errors were encountered: