check: JSON imports are data, not modules #2
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/json-imports"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
safe-ts check <entry>reported aparse-errorinside any.jsonfile the program imports(
import data from "./x.json" with { type: "json" }): the module graph resolved the import to thefile and parsed it as TypeScript.
Project::resolvenow only returns code files (ts,tsx,mts,cts,js,jsx,mjs,cjs,vue). JSON modules and other assets (CSS, images) are treated as data: they aren'tanalyzed or followed. That one function is used by the module graph, the editor path's lazy
loading, import resolution and type lookups, so all of them skip the file. Dependency inference
(
infer.rs) already filtered by extension the same way.Tests
crates/safe_ts_core/tests/fixtures/json_imports(importsdata.jsonwithwith { type: "json" }, expects no diagnostics). Before the fix it fails withdata.json:1 parse-error; after the fix it passes../target/release/safe-ts check crates/safe_ts_core/tests/fixtures/json_imports/main.ts:before, 1 problem (the parse-error); after, no problems.
cargo nextest run: 94/95 pass. The one failure,fixtures_match_annotationson thefeaturesfixture (main.ts:55, unexpectedunhandled-failureforcreateDecipheriv()),also fails on unmodified
main(0e01fb3) and has nothing to do with this change.npm run test:vite: passes.npm run test:std: 115/116. The one failure,every Node callable is mapped exactly once, alsofails on
mainhere (local Node is v26.13.0, so the API list differs) and is unrelated.Not covered
couldn't resolve). They are plain data and can't fail, so nothing is lost there.
🤖 Generated with Claude Code
`safe-ts check` followed `import data from "./x.json" with { type: "json" }` into the JSON file and parsed it as TypeScript, which reported a parse-error in every imported .json. The project resolver now only hands back code files (ts/tsx/mts/cts/js/jsx/mjs/cjs/vue); JSON, stylesheets and other assets are neither analyzed nor followed. The `json_imports` fixture reproduces it. Co-Authored-By: Claude Opus 5.5 <[email protected]>