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 小時
- 30 天內合併 PR
- 117
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/TypeScript 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
microsoft/TypeScript#64322 · 2 則留言 · 1 個 reaction · 已指派 2 人 ·
-
Possible Improvement
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/TypeScript#64278 · 1 則留言 · 1 個 reaction ·
-
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