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
Unlike the static import case, this is the case for both commonjs and esm outputs, since import() is available in commonjs modules in node and has the same semantics there as the ESM import (and therefore TS doesn't transform the import() statement to a Promise.resolve(require())).
The text was updated successfully, but these errors were encountered:
Note - obviously not all dynamic imports even can be analyzed, but TS does already analyze these sorts of dynamic imports where a literal is provided to both a) provide type definitions in the file, and b) copy the JSON file to the output dist. If it's doing that, I think it should also demand the import attributes (whereas obviously I wouldn't expect this for import(arbitraryString)).
π Search Terms
dynamic import, import attribute, resolveJsonModule,
π Version & Regression Information
β― Playground Link
https://github.com/kirkwaiblinger/repro-TS-dynamic-json-import-validation
π» Code
π Actual behavior
No error, even though this is a runtime error in nodejs.
π Expected behavior
Error because dynamic
import('./someThing.json')
requires import attribute.Additional information about the issue
Unlike the static import case, this is the case for both commonjs and esm outputs, since
import()
is available in commonjs modules in node and has the same semantics there as the ESM import (and therefore TS doesn't transform theimport()
statement to aPromise.resolve(require())
).The text was updated successfully, but these errors were encountered: