microsoft / microsoft/TypeScript
Mapped types created from reverse mapped types with union/intersection constraints don't have declaration linked
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
reverse mapped type go to definition union intersection constraint declarations
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
type StrictOptionName = "noImplicitAny" | "strictNullChecks";
interface CompilerOptions {
isolatedModules?: boolean;
noImplicitAny?: boolean;
strict?: boolean;
strictNullChecks?: boolean;
verbatimModuleSyntax?: boolean;
}
type CompilerOptionKeys = keyof {
[K in keyof CompilerOptions as string extends K ? never : K]: any;
};
declare function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean;
declare function createComputedCompilerOptions<T extends Record<string, CompilerOptionKeys[]>>(options: {
[K in (keyof T & CompilerOptionKeys) | StrictOptionName]: {
dependencies: T[K];
computeValue: (compilerOptions: Pick<CompilerOptions, K | T[K][number]>) => Exclude<CompilerOptions[K], undefined>;
};
}): typeof options;
const computed = createComputedCompilerOptions({
isolatedModules: {
dependencies: ["verbatimModuleSyntax"],
computeValue: (compilerOptions) => {
return !!(
compilerOptions.isolatedModules || compilerOptions.verbatimModuleSyntax
);
},
},
noImplicitAny: {
dependencies: ["strict"],
computeValue: (compilerOptions) => {
return getStrictOptionValue(compilerOptions, "noImplicitAny");
},
},
strictNullChecks: {
dependencies: ["strict"],
computeValue: (compilerOptions) => {
return getStrictOptionValue(compilerOptions, "strictNullChecks");
},
},
});
const getIsIsolatedModules = computed.isolatedModules/*1*/.computeValue
🙁 Actual behavior
Go to definition doesn't go anywhere at marker 1
🙂 Expected behavior
Go to definition should go to the property at the line 21
Additional information about the issue
modifiersType for this mapped type is unknown. I think that potentially the modifiers type when iterating over any reverse mapped type (when reversed.mappedType === (mappedType.target || mappedType) could use that reversed.source as the modifiers type. If not that then at least declarations could be outsourced to that type for linking properties.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript Playground の再現例から始め、marker 1 における go-to-definition リクエストを調べます。reverse mapped type とその modifiersType に注目してください。結果を 21 行目の期待されるプロパティと比較します。computed.isolatedModules.computeValue からの go-to-definition がそのプロパティ宣言に解決されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100