Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
@weswigham がすでに取り組んでいます。
2021年6月2日 から。
評価
この issue はまだ評価されていません。
説明
Bug Report
The following code used to work on 4.2.3, but does not build with 4.3.2, reporting the error on the last line
type ObjectFixedKeys<T extends object> = {
[K in keyof T]: string extends K ? never : K
} extends { [_ in keyof T]: infer U }
? U
: never
type DistributeKeysUnion<U> = U extends string
? { [K in U]: any }
: never
type ObjectDictionaryKeys<T extends object> = Exclude<
T,
DistributeKeysUnion<ObjectFixedKeys<T>>
>
type Condition = { $and: Array<Condition> }
| { $or: Array<Condition> }
| { [member: string]: string }
type O = ObjectFixedKeys<Condition>
type D = DistributeKeysUnion<ObjectFixedKeys<Condition>>
declare const s: string
type CT = ObjectDictionaryKeys<Condition>
declare const ct : CT
const h = ct[s]
Error:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'CT'.
No index signature with a parameter of type 'string' was found on type 'CT'.
🕗 Version & Regression Information
I tracked the regression to the version 4.3.0-dev.20210422
Probably related to https://github.com/microsoft/TypeScript/commit/8ea4ec94967c9db8542ca229dedd656fe9e051df
⏯ Playground Link
Playground link with relevant code
Note how the last line is evaluated to never, however if you select version 4.2.3 it gets evaluated to "foo" | "bar" as expected.
- 主要言語
- 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
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
kubernetes-sigs/prow#953 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
caddyserver/caddy#8046 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jaegertracing/jaeger#9588 ·