Skip to content

SourceFile.impliedNodeFormat - misleading doc comment #48961

Closed
@craigphicks

Description

@craigphicks

Bug Report

🔎 Search Terms

impliedNodeFormat

#48794

🕗 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

⏯ 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.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions