-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: flag: exactOptionalPropertyTypesBugs specific to enabling this flagBugs specific to enabling this flagHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
exactOptionalPropertyTypes optional generic indexed access undefined missing contextual constraint eopt
π Version & Regression Information
- This changed in 5.3.0-dev.20230914
β― Playground Link
π» Code
// @exactOptionalPropertyTypes: true
interface XStateConfiguration {
theme?: "auto" | "dark" | "light";
viewColumn?: "beside" | "active";
}
declare function getVscodeConfiguration<T>(section: string): T | undefined;
export function getConfiguration<Name extends keyof XStateConfiguration>(
name: Name,
): XStateConfiguration[Name] {
const genericAssignabilityTest: XStateConfiguration[Name] = undefined; // error
return getVscodeConfiguration(name); // error
}
const concreteAssignabilityTest: XStateConfiguration[keyof XStateConfiguration] = undefined; // okπ Actual behavior
undefined is not assignable to an indexed access like this in expression space
π Expected behavior
I'd expect this to typecheck OK - just like the concrete example
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Domain: flag: exactOptionalPropertyTypesBugs specific to enabling this flagBugs specific to enabling this flagHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases