We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The regression reported here can be traced back to #53192. The minimal~ repro case for it is this:
enum AutomationMode { NONE = "", TIME = "time", SYSTEM = "system", LOCATION = "location", } interface ThemePreset { id: string; } interface Automation { mode: AutomationMode; } interface UserSettings { presets: ThemePreset[]; automation: Automation; } interface ExtensionData { settings: UserSettings; } export function getMockData(): ExtensionData { return { settings: { presets: [], automation: { mode: "", }, } as UserSettings, } }
TS playground
Originally posted by @Andarist in #53192 (comment)
The text was updated successfully, but these errors were encountered:
Isn't it intentional that string literals are not assignable to string-based enums, even if they match one of the enum members?
Sorry, something went wrong.
It's about comparability and it seems that this type of conversion is valid in such a context, for example, this is OK:
const foo = "" as AutomationMode
Ah, I missed the type assertion as UserSettings so it just looked like an assignability failure, which was expected.
as UserSettings
The fix here is to exclude the comparable relation from the optimization in #53192. I will put up a PR.
ahejlsberg
Successfully merging a pull request may close this issue.
The regression reported here can be traced back to #53192. The minimal~ repro case for it is this:
TS playground
Originally posted by @Andarist in #53192 (comment)
The text was updated successfully, but these errors were encountered: