From a37d6d471b03352a697d74d794d6e855a2ee3df5 Mon Sep 17 00:00:00 2001 From: uhyo Date: Sun, 11 Oct 2020 18:27:17 +0900 Subject: [PATCH] add tests --- ...ngDestructuredPropertyInFunctionType.errors.txt | 10 ++++++++++ .../renamingDestructuredPropertyInFunctionType.js | 11 +++++++++++ ...amingDestructuredPropertyInFunctionType.symbols | 12 ++++++++++++ ...enamingDestructuredPropertyInFunctionType.types | 13 +++++++++++++ ...gDestructuredPropertyInFunctionType2.errors.txt | 14 ++++++++++++++ .../renamingDestructuredPropertyInFunctionType2.js | 12 ++++++++++++ ...mingDestructuredPropertyInFunctionType2.symbols | 13 +++++++++++++ ...namingDestructuredPropertyInFunctionType2.types | 14 ++++++++++++++ .../renamingDestructuredPropertyInFunctionType.ts | 3 +++ .../renamingDestructuredPropertyInFunctionType2.ts | 5 +++++ 10 files changed, 107 insertions(+) create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType.errors.txt create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType.symbols create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType.types create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.errors.txt create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.js create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.symbols create mode 100644 tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.types create mode 100644 tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts create mode 100644 tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.errors.txt b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.errors.txt new file mode 100644 index 00000000000..d6eaa158e74 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js new file mode 100644 index 00000000000..3d3a24d9a28 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js @@ -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; +}; diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.symbols b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.symbols new file mode 100644 index 00000000000..c0fc1701b12 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.symbols @@ -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)) + diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.types b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.types new file mode 100644 index 00000000000..7ff9138462d --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.types @@ -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 + diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.errors.txt b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.errors.txt new file mode 100644 index 00000000000..9817532b13a --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.errors.txt @@ -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. + + \ No newline at end of file diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.js b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.js new file mode 100644 index 00000000000..de499468762 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.js @@ -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; +}; diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.symbols b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.symbols new file mode 100644 index 00000000000..0e5dac47a36 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.symbols @@ -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)) + + diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.types b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.types new file mode 100644 index 00000000000..02b4a3400e2 --- /dev/null +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType2.types @@ -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 + + diff --git a/tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts b/tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts new file mode 100644 index 00000000000..c61bbe96700 --- /dev/null +++ b/tests/cases/compiler/renamingDestructuredPropertyInFunctionType.ts @@ -0,0 +1,3 @@ +type F = ({a: string}) => void; + +const f = ({a: string}) => string; diff --git a/tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts b/tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts new file mode 100644 index 00000000000..9f56fe8a119 --- /dev/null +++ b/tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts @@ -0,0 +1,5 @@ +// @noImplicitAny: true +type F = ({a: string}) => void; + +const f = ({a: string}) => string; +