Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uhyo committed Oct 11, 2020
1 parent f03f686 commit e360400
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts(1,15): error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.


==== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts (1 errors) ====
type F = ({a: string}) => void;
~~~~~~
!!! error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.

const f = ({a: string}) => string;

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//// [renamingDestructuredPropertyInFunctionType.ts]
type F = ({a: string}) => void;

const f = ({a: string}) => string;


//// [renamingDestructuredPropertyInFunctionType.js]
var f = function (_a) {
var string = _a.a;
return string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts ===
type F = ({a: string}) => void;
>F : Symbol(F, Decl(renamingDestructuredPropertyInFunctionType.ts, 0, 0))
>a : Symbol(a)
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 0, 11))

const f = ({a: string}) => string;
>f : Symbol(f, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 5))
>a : Symbol(a)
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 12))
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType.ts, 2, 12))

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts ===
type F = ({a: string}) => void;
>F : F
>a : any
>string : any

const f = ({a: string}) => string;
>f : ({ a: string }: { a: any; }) => any
>({a: string}) => string : ({ a: string }: { a: any; }) => any
>a : any
>string : any
>string : any

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts(1,15): error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.
tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts(3,16): error TS7031: Binding element 'string' implicitly has an 'any' type.


==== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts (2 errors) ====
type F = ({a: string}) => void;
~~~~~~
!!! error TS2797: Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.

const f = ({a: string}) => string;
~~~~~~
!!! error TS7031: Binding element 'string' implicitly has an 'any' type.


Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//// [renamingDestructuredPropertyInFunctionType2.ts]
type F = ({a: string}) => void;

const f = ({a: string}) => string;



//// [renamingDestructuredPropertyInFunctionType2.js]
var f = function (_a) {
var string = _a.a;
return string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts ===
type F = ({a: string}) => void;
>F : Symbol(F, Decl(renamingDestructuredPropertyInFunctionType2.ts, 0, 0))
>a : Symbol(a)
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 0, 11))

const f = ({a: string}) => string;
>f : Symbol(f, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 5))
>a : Symbol(a)
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 12))
>string : Symbol(string, Decl(renamingDestructuredPropertyInFunctionType2.ts, 2, 12))


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts ===
type F = ({a: string}) => void;
>F : F
>a : any
>string : any

const f = ({a: string}) => string;
>f : ({ a: string }: { a: any; }) => any
>({a: string}) => string : ({ a: string }: { a: any; }) => any
>a : any
>string : any
>string : any


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type F = ({a: string}) => void;

const f = ({a: string}) => string;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @noImplicitAny: true
type F = ({a: string}) => void;

const f = ({a: string}) => string;

0 comments on commit e360400

Please sign in to comment.