microsoft / microsoft/TypeScript

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

オープン
#63,129 コメント 14 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 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

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

### 🙁 Actual behavior

```txt
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.

Edit: I've created a [repro repo](https://github.com/valler/repro-repo-for-ms-typescript-issue-63129).

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた Playground の再現例と repro リポジトリから始め、記載されているコンパイラオプションと診断 TS2877 を手がかりにしてください。サブパスインポート '#alice.ts' が書き換え不可能な入力ファイルとして扱われる理由を追跡してください。この有効な指定子で TS2877 が発生しなくなり、報告されている相対パスの動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
64/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。