-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Add check for delete expression must be optional (#37921
- Loading branch information
1 parent
1b8c68d
commit 669acb4
Showing
14 changed files
with
856 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(2,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(3,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(6,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(7,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(10,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(11,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(14,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(15,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(16,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(19,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(20,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(23,8): error TS2790: The operand of a 'delete' operator must be optional. | ||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(24,9): error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
|
||
==== tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts (13 errors) ==== | ||
declare const o1: undefined | { b: string }; | ||
delete o1?.b; | ||
~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o1?.b); | ||
~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
declare const o2: undefined | { b: { c: string } }; | ||
delete o2?.b.c; | ||
~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o2?.b.c); | ||
~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
declare const o3: { b: undefined | { c: string } }; | ||
delete o3.b?.c; | ||
~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o3.b?.c); | ||
~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
declare const o4: { b?: { c: { d?: { e: string } } } }; | ||
delete o4.b?.c.d?.e; | ||
~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o4.b?.c.d)?.e; | ||
~~~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o4.b?.c.d?.e); | ||
~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
declare const o5: { b?(): { c: { d?: { e: string } } } }; | ||
delete o5.b?.().c.d?.e; | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o5.b?.().c.d?.e); | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
|
||
declare const o6: { b?: { c: { d?: { e: string } } } }; | ||
delete o6.b?.['c'].d?.['e']; | ||
~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. | ||
delete (o6.b?.['c'].d?.['e']); | ||
~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2790: The operand of a 'delete' operator must be optional. |
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt
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,46 @@ | ||
tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. | ||
|
||
|
||
==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (1 errors) ==== | ||
interface Foo { | ||
a: number | ||
b: number | undefined | ||
c: number | null | ||
d?: number | ||
e: number | undefined | null | ||
f?: number | undefined | null | ||
g: unknown | ||
h: any | ||
i: never | ||
} | ||
|
||
interface AA { | ||
[s: string]: number | ||
} | ||
|
||
type BB = { | ||
[P in keyof any]: number | ||
} | ||
|
||
declare const f: Foo | ||
declare const a: AA | ||
declare const b: BB | ||
|
||
delete f.a | ||
delete f.b | ||
delete f.c | ||
delete f.d | ||
delete f.e | ||
delete f.f | ||
delete f.g | ||
delete f.h | ||
delete f.i | ||
delete f.j | ||
~ | ||
!!! error TS2339: Property 'j' does not exist on type 'Foo'. | ||
|
||
delete a.a | ||
delete a.b | ||
|
||
delete b.a | ||
delete b.b |
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).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,57 @@ | ||
//// [deleteExpressionMustBeOptional.ts] | ||
interface Foo { | ||
a: number | ||
b: number | undefined | ||
c: number | null | ||
d?: number | ||
e: number | undefined | null | ||
f?: number | undefined | null | ||
g: unknown | ||
h: any | ||
i: never | ||
} | ||
|
||
interface AA { | ||
[s: string]: number | ||
} | ||
|
||
type BB = { | ||
[P in keyof any]: number | ||
} | ||
|
||
declare const f: Foo | ||
declare const a: AA | ||
declare const b: BB | ||
|
||
delete f.a | ||
delete f.b | ||
delete f.c | ||
delete f.d | ||
delete f.e | ||
delete f.f | ||
delete f.g | ||
delete f.h | ||
delete f.i | ||
delete f.j | ||
|
||
delete a.a | ||
delete a.b | ||
|
||
delete b.a | ||
delete b.b | ||
|
||
//// [deleteExpressionMustBeOptional.js] | ||
delete f.a; | ||
delete f.b; | ||
delete f.c; | ||
delete f.d; | ||
delete f.e; | ||
delete f.f; | ||
delete f.g; | ||
delete f.h; | ||
delete f.i; | ||
delete f.j; | ||
delete a.a; | ||
delete a.b; | ||
delete b.a; | ||
delete b.b; |
118 changes: 118 additions & 0 deletions
118
tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).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,118 @@ | ||
=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === | ||
interface Foo { | ||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) | ||
|
||
a: number | ||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) | ||
|
||
b: number | undefined | ||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) | ||
|
||
c: number | null | ||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) | ||
|
||
d?: number | ||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) | ||
|
||
e: number | undefined | null | ||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) | ||
|
||
f?: number | undefined | null | ||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) | ||
|
||
g: unknown | ||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) | ||
|
||
h: any | ||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) | ||
|
||
i: never | ||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) | ||
} | ||
|
||
interface AA { | ||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) | ||
|
||
[s: string]: number | ||
>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) | ||
} | ||
|
||
type BB = { | ||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) | ||
|
||
[P in keyof any]: number | ||
>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) | ||
} | ||
|
||
declare const f: Foo | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) | ||
|
||
declare const a: AA | ||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) | ||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) | ||
|
||
declare const b: BB | ||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) | ||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) | ||
|
||
delete f.a | ||
>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) | ||
|
||
delete f.b | ||
>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) | ||
|
||
delete f.c | ||
>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) | ||
|
||
delete f.d | ||
>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) | ||
|
||
delete f.e | ||
>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) | ||
|
||
delete f.f | ||
>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) | ||
|
||
delete f.g | ||
>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) | ||
|
||
delete f.h | ||
>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) | ||
|
||
delete f.i | ||
>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) | ||
|
||
delete f.j | ||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) | ||
|
||
delete a.a | ||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) | ||
|
||
delete a.b | ||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) | ||
|
||
delete b.a | ||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) | ||
|
||
delete b.b | ||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) | ||
|
Oops, something went wrong.