-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Search Terms
partial nested object type
π Version & Regression Information
- This changed between versions 4.5.5 and 4.6.4. It reproduces in all versions since 4.6.4 (including nightly)
β― Playground Link
Playground link with relevant code
π» Code
type OverridesInput = {
someProp?: 'A' | 'B'
}
const foo: Partial<{something: any}> & {variables: {
overrides?: OverridesInput;
} & Partial<{
overrides?: OverridesInput;
}>} = {variables: {overrides: false}};π Actual behavior
There is no error on the overrides field in the object. Changing the type of foo slightly (removing one of the intersections) causes the error to appear correctly, but this unique combination of types produces no error. Does not matter what the contents of OverridesInput is, nor what the content inside the outer partial (currently {something: any}) is. Additionally, the following all produce the error correctly:
type OverridesInput = {
someProp?: 'A' | 'B'
}
const foo: {variables: {
overrides?: OverridesInput;
} & Partial<{
overrides?: OverridesInput;
}>} = {variables: {overrides: false}};type OverridesInput = {
someProp?: 'A' | 'B'
}
const foo: Partial<{something: any}> & {variables: {
overrides?: OverridesInput;
}} = {variables: {overrides: false}};type OverridesInput = {
someProp?: 'A' | 'B'
}
const foo: Partial<{something: any}> & {variables: Partial<{
overrides?: OverridesInput;
}>} = {variables: {overrides: false}};π Expected behavior
There should be an error on the overrides field of the object since false is not assignable to OverridesInput | undefined.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue