Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve excess property checking for intersections (#32582)
* Improve excess property checking for intersections Still a draft, the implementation needs improvement * Use mutable isIntersection in checkTypeRelatedTo This makes parameter lists a lot shorter. Seems like a slight improvement, although I can revert if I change my mind. * Fix semicolon lint * Remove TODOOOO * Revert "Use mutable isIntersection in checkTypeRelatedTo" This reverts commit b8dccff.
- Loading branch information
Showing
16 changed files
with
220 additions
and
58 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/excessPropertyCheckWithNestedArrayIntersection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//// [excessPropertyCheckWithNestedArrayIntersection.ts] | ||
interface ValueOnlyFields { | ||
fields: Array<{ | ||
value: number | null; | ||
}>; | ||
} | ||
interface ValueAndKeyFields { | ||
fields: Array<{ | ||
key: string | null; | ||
value: number | null; | ||
}>; | ||
} | ||
interface BugRepro { | ||
dataType: ValueAndKeyFields & ValueOnlyFields; | ||
} | ||
const repro: BugRepro = { | ||
dataType: { | ||
fields: [{ | ||
key: 'bla', // should be OK: Not excess | ||
value: null, | ||
}], | ||
} | ||
} | ||
|
||
|
||
//// [excessPropertyCheckWithNestedArrayIntersection.js] | ||
var repro = { | ||
dataType: { | ||
fields: [{ | ||
key: 'bla', | ||
value: null | ||
}] | ||
} | ||
}; |
56 changes: 56 additions & 0 deletions
56
tests/baselines/reference/excessPropertyCheckWithNestedArrayIntersection.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
=== tests/cases/compiler/excessPropertyCheckWithNestedArrayIntersection.ts === | ||
interface ValueOnlyFields { | ||
>ValueOnlyFields : Symbol(ValueOnlyFields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 0, 0)) | ||
|
||
fields: Array<{ | ||
>fields : Symbol(ValueOnlyFields.fields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 0, 27)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
value: number | null; | ||
>value : Symbol(value, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 1, 19)) | ||
|
||
}>; | ||
} | ||
interface ValueAndKeyFields { | ||
>ValueAndKeyFields : Symbol(ValueAndKeyFields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 4, 1)) | ||
|
||
fields: Array<{ | ||
>fields : Symbol(ValueAndKeyFields.fields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 5, 29)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
key: string | null; | ||
>key : Symbol(key, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 6, 19)) | ||
|
||
value: number | null; | ||
>value : Symbol(value, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 7, 27)) | ||
|
||
}>; | ||
} | ||
interface BugRepro { | ||
>BugRepro : Symbol(BugRepro, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 10, 1)) | ||
|
||
dataType: ValueAndKeyFields & ValueOnlyFields; | ||
>dataType : Symbol(BugRepro.dataType, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 11, 20)) | ||
>ValueAndKeyFields : Symbol(ValueAndKeyFields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 4, 1)) | ||
>ValueOnlyFields : Symbol(ValueOnlyFields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 0, 0)) | ||
} | ||
const repro: BugRepro = { | ||
>repro : Symbol(repro, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 14, 5)) | ||
>BugRepro : Symbol(BugRepro, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 10, 1)) | ||
|
||
dataType: { | ||
>dataType : Symbol(dataType, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 14, 25)) | ||
|
||
fields: [{ | ||
>fields : Symbol(fields, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 15, 13)) | ||
|
||
key: 'bla', // should be OK: Not excess | ||
>key : Symbol(key, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 16, 14)) | ||
|
||
value: null, | ||
>value : Symbol(value, Decl(excessPropertyCheckWithNestedArrayIntersection.ts, 17, 17)) | ||
|
||
}], | ||
} | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/excessPropertyCheckWithNestedArrayIntersection.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
=== tests/cases/compiler/excessPropertyCheckWithNestedArrayIntersection.ts === | ||
interface ValueOnlyFields { | ||
fields: Array<{ | ||
>fields : { value: number; }[] | ||
|
||
value: number | null; | ||
>value : number | ||
>null : null | ||
|
||
}>; | ||
} | ||
interface ValueAndKeyFields { | ||
fields: Array<{ | ||
>fields : { key: string; value: number; }[] | ||
|
||
key: string | null; | ||
>key : string | ||
>null : null | ||
|
||
value: number | null; | ||
>value : number | ||
>null : null | ||
|
||
}>; | ||
} | ||
interface BugRepro { | ||
dataType: ValueAndKeyFields & ValueOnlyFields; | ||
>dataType : ValueAndKeyFields & ValueOnlyFields | ||
} | ||
const repro: BugRepro = { | ||
>repro : BugRepro | ||
>{ dataType: { fields: [{ key: 'bla', // should be OK: Not excess value: null, }], }} : { dataType: { fields: { key: string; value: null; }[]; }; } | ||
|
||
dataType: { | ||
>dataType : { fields: { key: string; value: null; }[]; } | ||
>{ fields: [{ key: 'bla', // should be OK: Not excess value: null, }], } : { fields: { key: string; value: null; }[]; } | ||
|
||
fields: [{ | ||
>fields : { key: string; value: null; }[] | ||
>[{ key: 'bla', // should be OK: Not excess value: null, }] : { key: string; value: null; }[] | ||
>{ key: 'bla', // should be OK: Not excess value: null, } : { key: string; value: null; } | ||
|
||
key: 'bla', // should be OK: Not excess | ||
>key : string | ||
>'bla' : "bla" | ||
|
||
value: null, | ||
>value : null | ||
>null : null | ||
|
||
}], | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/cases/compiler/excessPropertyCheckWithNestedArrayIntersection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
interface ValueOnlyFields { | ||
fields: Array<{ | ||
value: number | null; | ||
}>; | ||
} | ||
interface ValueAndKeyFields { | ||
fields: Array<{ | ||
key: string | null; | ||
value: number | null; | ||
}>; | ||
} | ||
interface BugRepro { | ||
dataType: ValueAndKeyFields & ValueOnlyFields; | ||
} | ||
const repro: BugRepro = { | ||
dataType: { | ||
fields: [{ | ||
key: 'bla', // should be OK: Not excess | ||
value: null, | ||
}], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters