GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Importing JSON file as type only conflicts with import attribute type requirement · Issue #60724 · microsoft/TypeScript Closed Labels Milestone Description🔎 Search Terms"import attributes", "import assert", "type json" 🕗 Version & Regression Information
⏯ Playground LinkCouldn't get playground to create a separate module, so attaching a minimal example run 💻 Code// tsc fails with: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import type enMessages from "./en.json"; 🙁 Actual behaviorWhen 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"' import type enMessages from "./en.json"; // tsc fails with: Import attributes cannot be used with type-only imports or exports. ts(2857) import type enMessages from "./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 case import enMessages from "./en.json" with { type: "json" }; 🙂 Expected behaviorType 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 import type enMessages from "./en.json"; import enMessages from "./en.json" with { type: "json" }; Additional information about the issuetsconfig.json {
"compilerOptions": {
"target": "esnext",
"esModuleInterop": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"declaration": true,
"rootDir": "src",
"outDir": "dist/types"
},
"include": ["./src/**/*", "./src/**/*.json"],
"exclude": ["build", "node_modules", "dist"]
}
Reacted by Alfonsus Ardani Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |