Closed
Description
Bug Report
🔎 Search Terms
impliedNodeFormat
🕗 Version & Regression Information
branch packageJsonWatch
- I was unable to test this on prior versions because:
- might not expect
impliedNodeFormat
to be set correctly in earlier versions
- might not expect
⏯ Playground Link
Not possible
💻 Code
The documentation for SourceFile["impliedNodeFormat"]
says
/**
* When `module` is `Node12` or `NodeNext`, this field controls whether the
* source file in question is an ESNext-output-format file, or a CommonJS-output-format
* module. This is derived by the module resolver as it looks up the file, since
* it is derived from either the file extension of the module, or the containing
* `package.json` context, and affects both checking and emit.
*
* It is _public_ so that (pre)transformers can set this field,
* since it switches the builtin `node` module transform. Generally speaking, if unset,
* the field is treated as though it is `ModuleKind.CommonJS`.
*/
impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
however, in a unittest is was found that setting
- setting compilerOptions:module to "Node12" did NOT result in "impliedNodeFormat" being set correctly
- setting compilerOptions:moduleResolution to "Node12", while leaving compilerOptions:module unset, DID result in "impliedNodeFormat" being set correctly
🙁 Actual Current In-code Documentation
Need to set compilerOptions:module
It is the in-code documentation that needs to change.
🙂 Actual Behavior
Need to set compilerOptions:moduleResolution
Test
I set up a unittest in a pull to the packageWatchJson branch. #48958 which shows that moduleResolution set to Node12 works correctly.