microsoft / microsoft/TypeScript
Not possible to have optional object property compatible with both Closure Compiler and Intellisense
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
- VSCode Version: 1.32.3 x64
- OS Version: Ubuntu 18.04
Steps to Reproduce:
- Enable "checkJs": true in jsconfig.json.
- Create a Javascript file:
class A {
/**
* @param {{field: string|undefined}} obj
*/
constructor(obj) {
this.obj = obj;
}
}
let a = new A({});
Results in this error:

Adding error text here for duplicate detection:
Argument of type '{}' is not assignable to parameter of type '{ field: string; }'.
Property 'field' is missing in type '{}' but required in type '{ field: string; }' .ts(2345)
Does this issue occur when all extensions are disabled?: Yes
Expected behaviour:
Some way to mark object properties as optional compatible both with Closure Compiler and VsCode intellisense. Either through @typedef, through structural interfaces with @record, direct @param notation using string|undefined, or something similar.
This notation works fine today, but it is not recognized by Closure Compiler. It is debatable whether this is an issue with Intellisense or lacking support from Closure Compiler.
class A {
/**
* @param {AParam} obj
*/
constructor(obj) {
this.obj = obj;
}
}
/** @typedef {{field?: string|undefined}} */
var AParam;
let a = new A({});
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
レポートに示されている JSDoc の @param 形式と @typedef 形式を使用し、checkJs を有効にした jsconfig.json で再現することから始めます。TypeScript がオプショナルプロパティの表記を、示されている Closure Compiler 互換性要件に対してどのように扱うかを比較します。対応している表記によって、報告されているプロパティ不足エラーなしで new A({}) を使用でき、同時に Closure Compiler との互換性も維持できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers, developer-experience
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100