microsoft / microsoft/TypeScript
JSDoc: Infer return value of function
オープン
まだ誰も着手していません。
Bug
Domain: JSDoc
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Issue Type: Bug
Typescript works:
type Data = { a: string };
function test<T>(funct: (arg: Data) => T): T {
return funct({a: 'test'});
}
test(a => a.a); // return type: string => works OK
JSDoc bug:
/** @typedef {{ a: string }} Data */
/**
* @template T
* @param { (arg: Data) => T } funct
* @returns {T}
*/
function test(funct) {
return funct({a: 'test'});
}
test((/** @type { Data } */ a) => a.a); // return type: string => works OK
test(a => a.a); // return type: any => not works - BUG
VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:36:32.643Z)
OS version: Darwin x64 20.3.0
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (8 x 2700) |
| GPU Status | 2d_canvas: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled webgl: enabled webgl2: enabled |
| Load (avg) | 2, 2, 2 |
| Memory (System) | 16.00GB (0.91GB free) |
| Process Argv | --crash-reporter-id 2e37b1f3-b89a-4c4c-8add-c119edc3cc5b --crash-reporter-id 2e37b1f3-b89a-4c4c-8add-c119edc3cc5b |
| Screen Reader | no |
| VM | 0% |
Extensions (17)
| Extension | Author (truncated) | Version |
|---|---|---|
| vscode-openapi | 42C | 4.5.0 |
| swagger-viewer | Arj | 3.0.1 |
| bracket-pair-colorizer-2 | Coe | 0.2.0 |
| vscode-simpler-icons | dav | 1.6.5 |
| vscode-eslint | dba | 2.1.20 |
| gitlens | eam | 11.4.1 |
| EditorConfig | Edi | 0.16.4 |
| json-tools | eri | 1.0.2 |
| code-runner | for | 0.11.3 |
| jsdoc | lll | 1.0.3 |
| dotenv | mik | 1.0.1 |
| prettify-json | moh | 0.0.3 |
| vscode-typescript-tslint-plugin | ms- | 1.3.3 |
| vscode-yaml | red | 0.18.0 |
| sort-lines | Tyr | 1.9.0 |
| vscode-icons | vsc | 11.4.0 |
| html-css-class-completion | Zig | 1.20.0 |
(3 theme extensions excluded)
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt678:30270856
pythonvspyt602cf:30294773
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsnew554cf:30291488
pythontb:30283811
vspre833cf:30267465
pythonptprofiler:30281270
vscnewfilehidden:30294815
vshan820:30294714
pythondataviewer:30285071
vscus158:30286553
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue にある 2 つの TypeScript および JSDoc の例を再現し、注釈のない callback の推論された戻り値の型を比較します。JSDoc のジェネリック callback の推論経路を追跡し、失敗する例のカバレッジを追加します。注釈のない callback の戻り値が any ではなく string と推論されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 38/100