microsoft / microsoft/TypeScript
Lib dependencies are transitive
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.8.3
Search Terms: lib target dependencies triple-slash
Code
I have a reproduction repository at https://github.com/astorije/repro-tsc-lib-issue.
Essentially, consider the following code:
console.log(Object.values({ foo: BigInt(42) }));
Object.values is a ES2017 feature, and BigInt is a ES2020.
Also consider the target is tsconfig.json is es2015, and lib is either not specified or simply contains es2015 and dom.
Expected behavior:
Given the code and the TS configuration above, the type checker should always fails with:
index.ts:2:20 - error TS2339: Property 'values' does not exist on type 'ObjectConstructor'.
2 console.log(Object.values({ foo: BigInt(42) }));
~~~~~~
index.ts:2:34 - error TS2304: Cannot find name 'BigInt'.
2 console.log(Object.values({ foo: BigInt(42) }));
~~~~~~
And if you only have typescript as a dependency in package.json, that is indeed what you'll get. So far, so good. See the expected folder of my repro repo.
Actual behavior:
If you have a (direct or indirect) dependency to @types/node, or if any dependency contains a declaration file that has /// <reference lib="es2018" />, /// <reference lib="es2020.bigint" />, etc., the type checker will now stop reporting these errors. See the actual folder of my repro repo.
This seems significant to me because it means that dependencies can silence potential browser incompatibilities. If I specified a target of es2015, with no extra lib, Babel transpiling, or polyfills, I should not be able to compile the code above.
Is there something obvious I'm missing? I realize it's the very design of libbut as explained in #15732, that assumes the project uses polyfills, which is not something that can be enforced/checked by a third-party library at compile time.
Related Issues:
Apologies for the vagueness of the search terms. It's significant enough that it must already exist in an issue or a StackOverflow question, but after spending some time looking, I did not find anything similar.
The only issues that seem somewhat related, but different:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
再現リポジトリから始め、TypeScript 3.8.3 を使用して、その期待されるフォルダーと実際のフォルダーを比較します。tsconfig.json と index.ts の例を読み、その後、関連する issue #33111、#35656、#15732 を確認します。完了条件は、推移的な宣言参照によって報告された Object.values と BigInt のエラーが抑制されるべきかどうかを判断し、その動作を文書化または修正することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100