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
interfaceProperty<T>{name: keyofT}interfaceThingA{a: stringb: string}interfaceThingB{c: stringd: string}functionFilter<TextendsThingA|ThingB>(properties: Property<T>[]){returnproperties.map((property)=>`input-${property.name}`)// <-- Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'.(2731)}
π Actual behavior
Typescript thinks that property.name here may be a Symbol. I guess maybe this makes sense since T extends ThingA | ThingB wouldn't prohibit a ThingC interface that extends ThingA with a symbol property. But I'd expect this new error to pop up in a lot more places in my codebase, but I only see it in this one spot.
I'm not sure in what circumstances this error is triggered, or how to work around it. I'd rather not add String(...) around the property because that's unnecessary extra runtime code.
π Expected behavior
Because this doesn't fail in TS < 4.7, I'd expect it not to suddenly start failing.
The text was updated successfully, but these errors were encountered:
Uncaught (in promise) TypeError: Cannot convert a Symbol value to a string
at <anonymous>:2:59
at Array.map (<anonymous>)
at Filter (<anonymous>:2:23)
at <anonymous>:5:1
Bug Report
π Search Terms
Implicit conversion symbol fail runtime
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Typescript thinks that
property.name
here may be a Symbol. I guess maybe this makes sense sinceT extends ThingA | ThingB
wouldn't prohibit aThingC
interface that extends ThingA with a symbol property. But I'd expect this new error to pop up in a lot more places in my codebase, but I only see it in this one spot.I'm not sure in what circumstances this error is triggered, or how to work around it. I'd rather not add
String(...)
around the property because that's unnecessary extra runtime code.π Expected behavior
Because this doesn't fail in TS < 4.7, I'd expect it not to suddenly start failing.
The text was updated successfully, but these errors were encountered: