TypeScript emits d.ts file that is invalid for complex mapped type.
@weswigham がすでに取り組んでいます。
2024年6月14日 から。
評価
この issue はまだ評価されていません。
説明
🔎 Search Terms
d.ts emit type error
🕗 Version & Regression Information
This is a compile error when consuming a d.ts file emitting by the same version and configuration of TypeScript
This in 3.5.1, 4.0.5, 5.4.5 and 5.5.0-dev.20240528, but NOT in 3.3.3
⏯ Playground Link
💻 Code
export function adaptEnum<TEnum extends Record<string, string>>(
) {
type Part1 = {
[Property in keyof TEnum]: () => TEnum[Property]
};
const factoryOut = () => {
return (0 as unknown as typeof factoryOut & Part1)[0 as unknown as keyof TEnum]()
};
return factoryOut;
}
🙁 Actual behavior
Emits:
export declare function adaptEnum<TEnum extends Record<string, string>>(): () => TEnum[string] | TEnum[number] | TEnum[symbol];
Which Errors:
Type 'number' cannot be used to index type 'TEnum'.(2536)
🙂 Expected behavior
I expect TypeScript to either error when trying to emit a d.ts file, or generate a valid d.ts file it can consume without error.
Additional information about the issue
This issue report is derived from minimizing the same code that produced https://github.com/microsoft/TypeScript/issues/56718 (which is now fixed) and is similar to that issue. The same workaround I have from that case still works, so this isn't blocking anything except removing that workaround.
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
githubnext/gh-aw-cao#13143 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
blinklabs-io/bursa#904 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · コメント 2 件 ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100