microsoft / microsoft/TypeScript

Code completion: suggest tokens from "paths" in tsconfig.json

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

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

In Discussion Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Search Terms

Code completion; module

Suggestion

Use Cases

For those paths which contains no wildcard character, can we suggest tokens from module it points?

For example:

{
  "baseUrl": '.',
  "paths": {
    "my-base-module": [
        "../../dest/base"
    ],
}

in the example, we can say that bare module specifier "my-base-module" is mapped to path "../../dest/base", which is actually a .d.ts.

However, my IDE(Visual Studio Code) do not list available symbols in "my-base-module",
such as, When I type:

const v: Ve // I 'm going to type Vec3, which is defined in "../../dest/base".

I hopo IDE can suggest Vec3 and auto-complete the importing statement as:

import { Vec3 } from "my-base-module";

You may ask: Why don't you put "../../dest/base" in "types" option in tsconfig.json.

Well, the "../../dest/base" is just a library of me. It is indeed another Typescript project's output bundle file(bundling use rollup). It is bundled as a single module, which, in later, maybe registered as a SystemJS module with name "my-base-module" because I hope users of the library treat the library as a single JS module so they can write:

import /* xx */ from "my-base-module";

Examples

As stated above, I would upload my example if it's needed.

Checklist

My suggestion meets these guidelines:

  • [-] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [-] This wouldn't change the runtime behavior of existing JavaScript code
  • [-] This could be implemented without emitting different JS based on the types of the expressions
  • [-] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [-] This feature would agree with the rest of TypeScript's Design Goals.

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

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

はじめの一歩

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

調査の方向性

この issue には tsconfig.json のパスの例と TypeScript のコード補完シナリオが示されていますが、リポジトリのファイルやテストは指定されていません。まず、マップされた bare module を通じた Vec3 の欠落している補完を再現してください。マップされた bundle のシンボルが候補として提示され、import が "my-base-module" を使用すれば完了です。

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

評価

技術スタック
typescript
領域
developer-experience
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

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

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