microsoft / microsoft/TypeScript
Autocompletion does NOT remove `type` from `import type` when needed
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
We use TypeScript configuration "verbatimModuleSyntax": true in tsconfig.json and so import statements can be specified ether import module or import type module.
Previously in the case when module was imported as a type like import type Test from 'test' and it needs to be imported without type like import Test from 'test' autocompletion will remove the type part. With the new version this behaviour is broken and type part is not being removed by autocompletion.
Before
// "type" will be removed here
import type Test from 'test'; // -> import Test from 'test';
// use autocompletion -> "type: being removed from above
const test = new Test();
Now
// "type" stays at place
import type Test from 'test'; // -> no changes
// use autocompletion -> no changes
const test = new Test();
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.106.3
- OS Version: Linux x64 6.14.0-36-generic snap
Steps to Reproduce:
- Make new project
- Add
tsconfig.json - Specify
"verbatimModuleSyntax": truein thetsconfig.json - Add new file
test.tsexport class Test {} - Add new file
example.tsconst test: Test; // use autocompletion on the "Test" - Observe that
import typehas been addedimport type { Test } from 'test'; const test: Test; - Try to create new
Testinstanceimport type { Test } from 'test'; const test: Test = new Test(); - Observe error
`'Test' cannot be used as a value because it was imported using 'import type'.ts(1361)` - Use autocomplete on the
Test, observe thatimport type Test from 'test'has NOT been changed toimport Test from 'test'
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
verbatimModuleSyntax を指定した tsconfig.json、Test を export する test.ts、および示されているとおりの example.ts を使って問題を再現し、オートコンプリートの手順を実行して import type が残ることを確認します。オートコンプリートまたは import の編集に関係する TypeScript のエントリーポイントを追跡し、その後、Test を値として使用すると type が削除され、型のみの使用では保持されることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- developer-experience, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100