Skip to content

TSC should not error on valid subpath specifier syntax (TS2877)Β #63129

@valler

Description

@valler

πŸ”Ž Search Terms

TS2877

πŸ•— Version & Regression Information

This changed between versions 5.6 and 5.7 (best guess; 5.7 introduced rewriteRelativeImportExtensions).

⏯ Playground Link

https://www.typescriptlang.org/play/?rewriteRelativeImportExtensions=true&resolvePackageJsonExports=true&resolvePackageJsonImports=true&noUncheckedSideEffectImports=true&allowArbitraryExtensions=true&allowImportingTsExtensions=true#code/PTAEEkFsAcHsCcAuBnUAbAlgawKakQBY7J4DGAhgK4mgAqAygEwAcA7KwDQBQIoA7kQB2oDMIBm5UonxF4OAOSpBsQqIDm-eLEEbyAI1iVphHJAB0XHmAACKALQ4AHtBxSH8LfABcMjKj6GaAAmoHIAjpQYcqDkoNCSWORqOGYAVsja+LChxLBoAG44XBgwCNIARADE5JikKSjlANxcQA

πŸ’» Code

// Imports like these cause TS2877,
// when in fact there's nothing wrong about them.
import "#alice.ts";

πŸ™ Actual behavior

error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path.

πŸ™‚ Expected behavior

Don't error.

Additional information about the issue

Specifiers aren't paths. Especially subpath imports and exports allow for almost arbitrary string rewriting. The compiler is blatantly wrong about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions