Skip to content

Commit e360400

Browse files
committed
add tests
1 parent f03f686 commit e360400

10 files changed

+107
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts(1,15): error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.
2+
3+
4+
==== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts (1 errors) ====
5+
type F = ({a: string}) => void;
6+
~~~~~~
7+
!!! error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.
8+
9+
const f = ({a: string}) => string;
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [renamingDestructuredPropertyInFunctionType.ts]
2+
type F = ({a: string}) => void;
3+
4+
const f = ({a: string}) => string;
5+
6+
7+
//// [renamingDestructuredPropertyInFunctionType.js]
8+
var f = function (_a) {
9+
var string = _a.a;
10+
return string;
11+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts ===
2+
type F = ({a: string}) => void;
3+
>F : Symbol(F, Decl(renamingDestructuredPropertyInFunctionType.ts, 0, 0))
4+
>a : Symbol(a)
5+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 0, 11))
6+
7+
const f = ({a: string}) => string;
8+
>f : Symbol(f, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 5))
9+
>a : Symbol(a)
10+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 12))
11+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 12))
12+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts ===
2+
type F = ({a: string}) => void;
3+
>F : F
4+
>a : any
5+
>string : any
6+
7+
const f = ({a: string}) => string;
8+
>f : ({ a: string }: { a: any; }) => any
9+
>({a: string}) => string : ({ a: string }: { a: any; }) => any
10+
>a : any
11+
>string : any
12+
>string : any
13+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts(1,15): error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.
2+
tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts(3,16): error TS7031: Binding element 'string' implicitly has an 'any' type.
3+
4+
5+
==== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts (2 errors) ====
6+
type F = ({a: string}) => void;
7+
~~~~~~
8+
!!! error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.
9+
10+
const f = ({a: string}) => string;
11+
~~~~~~
12+
!!! error TS7031: Binding element 'string' implicitly has an 'any' type.
13+
14+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [renamingDestructuredPropertyInFunctionType2.ts]
2+
type F = ({a: string}) => void;
3+
4+
const f = ({a: string}) => string;
5+
6+
7+
8+
//// [renamingDestructuredPropertyInFunctionType2.js]
9+
var f = function (_a) {
10+
var string = _a.a;
11+
return string;
12+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts ===
2+
type F = ({a: string}) => void;
3+
>F : Symbol(F, Decl(renamingDestructuredPropertyInFunctionType2.ts, 0, 0))
4+
>a : Symbol(a)
5+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 0, 11))
6+
7+
const f = ({a: string}) => string;
8+
>f : Symbol(f, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 5))
9+
>a : Symbol(a)
10+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 12))
11+
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 12))
12+
13+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts ===
2+
type F = ({a: string}) => void;
3+
>F : F
4+
>a : any
5+
>string : any
6+
7+
const f = ({a: string}) => string;
8+
>f : ({ a: string }: { a: any; }) => any
9+
>({a: string}) => string : ({ a: string }: { a: any; }) => any
10+
>a : any
11+
>string : any
12+
>string : any
13+
14+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type F = ({a: string}) => void;
2+
3+
const f = ({a: string}) => string;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @noImplicitAny: true
2+
type F = ({a: string}) => void;
3+
4+
const f = ({a: string}) => string;
5+

0 commit comments

Comments
 (0)