Skip to content

Commit dbf025b

Browse files
committed
add test
1 parent 6695c4a commit dbf025b

7 files changed

Lines changed: 75 additions & 5 deletions

tests/baselines/reference/dependentDestructuredVariablesNoCrash1.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependentDestructuredVariablesNoCrash1.ts(3,10): error TS7010: 'f', which lacks return-type annotation, implicitly has an 'any' return type.
22
dependentDestructuredVariablesNoCrash1.ts(5,12): error TS1015: Parameter cannot have question mark and initializer.
3-
dependentDestructuredVariablesNoCrash1.ts(5,12): error TS2461: Type '(() => any) | undefined' is not an array type.
3+
dependentDestructuredVariablesNoCrash1.ts(5,12): error TS2488: Type '(() => any) | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
44
dependentDestructuredVariablesNoCrash1.ts(5,20): error TS7022: 'undefined' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
55
dependentDestructuredVariablesNoCrash1.ts(5,45): error TS2373: Parameter '[first, undefined]' cannot reference identifier 'undefined' declared after it.
66

@@ -16,7 +16,7 @@ dependentDestructuredVariablesNoCrash1.ts(5,45): error TS2373: Parameter '[first
1616
~~~~~~~~~~~~~~~~~~
1717
!!! error TS1015: Parameter cannot have question mark and initializer.
1818
~~~~~~~~~~~~~~~~~~
19-
!!! error TS2461: Type '(() => any) | undefined' is not an array type.
19+
!!! error TS2488: Type '(() => any) | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
2020
~~~~~~~~~
2121
!!! error TS7022: 'undefined' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
2222
~~~~~~~~~

tests/baselines/reference/dependentDestructuredVariablesNoCrash1.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ function f([first, undefined]?: () => any = undefined) {}
1111
//// [dependentDestructuredVariablesNoCrash1.js]
1212
"use strict";
1313
// https://github.com/microsoft/TypeScript/issues/63044
14-
function f(_a) {
15-
var _b = _a === void 0 ? undefined : _a, first = _b[0], undefined = _b[1];
16-
}
14+
function f([first, undefined] = undefined) { }
1715

1816

1917
//// [dependentDestructuredVariablesNoCrash1.d.ts]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
dependentDestructuredVariablesNoCrash2.ts(3,9): error TS7010: '(Missing)', which lacks return-type annotation, implicitly has an 'any' return type.
2+
dependentDestructuredVariablesNoCrash2.ts(3,10): error TS1003: Identifier expected.
3+
dependentDestructuredVariablesNoCrash2.ts(3,11): error TS2488: Type 'string | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
4+
dependentDestructuredVariablesNoCrash2.ts(3,11): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
5+
dependentDestructuredVariablesNoCrash2.ts(3,12): error TS7022: 'undefined' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
6+
dependentDestructuredVariablesNoCrash2.ts(3,54): error TS2373: Parameter '[undefined, unknown]' cannot reference identifier 'undefined' declared after it.
7+
8+
9+
==== dependentDestructuredVariablesNoCrash2.ts (6 errors) ====
10+
// https://github.com/microsoft/TypeScript/issues/63091
11+
12+
function ([undefined, unknown]: string | undefined = undefined)
13+
14+
!!! error TS7010: '(Missing)', which lacks return-type annotation, implicitly has an 'any' return type.
15+
~
16+
!!! error TS1003: Identifier expected.
17+
~~~~~~~~~~~~~~~~~~~~
18+
!!! error TS2488: Type 'string | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
19+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
21+
~~~~~~~~~
22+
!!! error TS7022: 'undefined' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
23+
~~~~~~~~~
24+
!!! error TS2373: Parameter '[undefined, unknown]' cannot reference identifier 'undefined' declared after it.
25+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash2.ts] ////
2+
3+
//// [dependentDestructuredVariablesNoCrash2.ts]
4+
// https://github.com/microsoft/TypeScript/issues/63091
5+
6+
function ([undefined, unknown]: string | undefined = undefined)
7+
8+
9+
//// [dependentDestructuredVariablesNoCrash2.js]
10+
"use strict";
11+
// https://github.com/microsoft/TypeScript/issues/63091
12+
13+
14+
//// [dependentDestructuredVariablesNoCrash2.d.ts]
15+
declare function ([undefined, unknown]?: string | undefined): any;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash2.ts] ////
2+
3+
=== dependentDestructuredVariablesNoCrash2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/63091
5+
6+
function ([undefined, unknown]: string | undefined = undefined)
7+
> : Symbol((Missing), Decl(dependentDestructuredVariablesNoCrash2.ts, 0, 0))
8+
>undefined : Symbol(undefined, Decl(dependentDestructuredVariablesNoCrash2.ts, 2, 11))
9+
>unknown : Symbol(unknown, Decl(dependentDestructuredVariablesNoCrash2.ts, 2, 21))
10+
>undefined : Symbol(undefined, Decl(dependentDestructuredVariablesNoCrash2.ts, 2, 11))
11+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash2.ts] ////
2+
3+
=== dependentDestructuredVariablesNoCrash2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/63091
5+
6+
function ([undefined, unknown]: string | undefined = undefined)
7+
> : ([undefined, unknown]?: string | undefined) => any
8+
> : ^ ^^^ ^^^^^^^^
9+
>undefined : any
10+
> : ^^^
11+
>unknown : any
12+
> : ^^^
13+
>undefined : any
14+
> : ^^^
15+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
// https://github.com/microsoft/TypeScript/issues/63091
5+
6+
function ([undefined, unknown]: string | undefined = undefined)

0 commit comments

Comments
 (0)