Skip to content

The error for allowImportingTsExtensions does not reference rewriteRelativeImportExtensions #60397

Open
@fpapado

Description

@fpapado

🔎 Search Terms

  • error TS5096
  • allowImportingTsExtensions
  • rewriteRelativeImportExtensions
  • tsconfig
  • diagnostics
  • intellisense

🕗 Version & Regression Information

  • This changed between versions N/A and 5.7.0-beta
  • This changed in commit or PR Rewrite relative import extensions with flag #59767
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries for allowImportingTsExtensions and rewriteRelativeImportExtensions
  • I was unable to test this on prior versions because it was only introduced in 5.7

⏯ Playground Link

No response

💻 Code

tsconfig.json with diagnostic error:

{
  "compilerOptions": {
    "module": "Node16",
    "moduleResolution": "Node16",
    "allowImportingTsExtensions": true,
  }
}

🙁 Actual behavior

When specifying allowImportingTsExtensions as above, I get an error, as intended:

tsconfig.json:5:35 - error TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.

However, if I add "rewriteRelativeImportExtensions": true to the same tsconfig, the error goes away, which is contrary to the error message.

The behavior seems correct, but the error message seems incomplete or inconsistent.


At the same time, intellisense for allowImportingTsExtensions in VSCode reports:

Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.

This is only mentioned as a requirement in intellisense, but not in the error message.

🙂 Expected behavior

I would expect the message to reference rewriteRelativeImportExtensions as one of the conditions that allow for allowImportingTsExtensions.

I am not sure whether --moduleResolution bundler is required, but at least unifying the intellisense and diagnostic would be good.

The combination of factors seems to be "noEmit or emitDeclarationOnly or rewriteRelativeImportExtensions", but I am not sure what the exact new diagnostic message should be 😅

(I don't mean to be nitpicky! I tend to learn best from intellisense and the diagnostics errors, so I was on the lookout for them when trying out the 5.7.0-beta and rewriteRelativeImportExtensions 😌)

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions