You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typescript with strict settings complains about implicit any:
error TS7053: Element implicitly has an 'any' type because expression of type '"key1"' can't be used to index type '{ key1: string; } | { key2: string; }'.
Property 'key1' does not exist on type '{ key1: string; } | { key2: string; }'.
typeof typedObj["prop"]["key1"] === "string" ||
~~~~~~~~~~~~~~~~~~~~~~~~
error TS7053: Element implicitly has an 'any' type because expression of type '"key2"' can't be used to index type '{ key1: string; } | { key2: string; }'.
Property 'key2' does not exist on type '{ key1: string; } | { key2: string; }'.
typeof typedObj["prop"]["key2"] === "string")
Possible solution: adding "key1" in typedObj["prop"]:
Hi, thanks for this nice project. We have been using it for some quite complex API responses and found an edge case:
Repro (simplified - the real case has a union of two interfaces):
Type guard:
Typescript with strict settings complains about implicit any:
Possible solution: adding
"key1" in typedObj["prop"]
:The text was updated successfully, but these errors were encountered: