The behavior of VS Code's TypeScript extension controls the behavior described here, utilizing TypeScript itself.
When working with JS files, VS Code may not flag errors when referencing non-existent properties in imported JSON files due to its design, but it does offer autocomplete suggestions for existing properties. This functionality works with both EMCAScript and RequireJS-style imports (e.g.
import * as j from "./test.json";
). However, there are limitations highlighted in this GitHub issue:
import ConstJson from './config.json' as const; #32063.
On the other hand, TS files will identify accesses to non-existent properties as problems.