diff --git a/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.js b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.js new file mode 100644 index 00000000000..2748b57933b --- /dev/null +++ b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.js @@ -0,0 +1,155 @@ +//// [declarationEmitFirstTypeArgumentGenericFunctionType.ts] + +class X { +} +var prop11: X< () => Tany >; // spaces before the first type argument +var prop12: X<(() => Tany)>; // spaces before the first type argument +function f1() { // Inferred return type + return prop11; +} +function f2() { // Inferred return type + return prop12; +} +function f3(): X< () => Tany> { // written with space before type argument + return prop11; +} +function f4(): X<(() => Tany)> { // written type with parenthesis + return prop12; +} +class Y { +} +var prop2: Y() => Tany>; // No space after second type argument +var prop2: Y() => Tany>; // space after second type argument +var prop3: Y< () => Tany, () => Tany>; // space before first type argument +var prop4: Y<(() => Tany), () => Tany>; // parenthesized first type argument + + +//// [declarationEmitFirstTypeArgumentGenericFunctionType.js] +class X { +} +var prop11; // spaces before the first type argument +var prop12; // spaces before the first type argument +function f1() { + return prop11; +} +function f2() { + return prop12; +} +function f3() { + return prop11; +} +function f4() { + return prop12; +} +class Y { +} +var prop2; // No space after second type argument +var prop2; // space after second type argument +var prop3; // space before first type argument +var prop4; // parenthesized first type argument + + +//// [declarationEmitFirstTypeArgumentGenericFunctionType.d.ts] +declare class X { +} +declare var prop11: X<() => Tany>; +declare var prop12: X<(() => Tany)>; +declare function f1(): X<(() => Tany)>; +declare function f2(): X<(() => Tany)>; +declare function f3(): X<() => Tany>; +declare function f4(): X<(() => Tany)>; +declare class Y { +} +declare var prop2: Y() => Tany>; +declare var prop2: Y() => Tany>; +declare var prop3: Y<() => Tany, () => Tany>; +declare var prop4: Y<(() => Tany), () => Tany>; + + +//// [DtsFileErrors] + + +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,21): error TS2314: Generic type 'X' requires 1 type argument(s). +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,22): error TS1005: '=' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,24): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,30): error TS1109: Expression expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,32): error TS1005: ';' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,35): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,40): error TS1109: Expression expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,24): error TS2314: Generic type 'X' requires 1 type argument(s). +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,25): error TS1144: '{' or ';' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,27): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,33): error TS1109: Expression expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,35): error TS1005: ';' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,38): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(7,43): error TS1109: Expression expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,20): error TS2314: Generic type 'Y' requires 2 type argument(s). +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,21): error TS1005: '=' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,23): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,29): error TS1109: Expression expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,31): error TS1005: ';' expected. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,34): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,52): error TS2304: Cannot find name 'Tany'. +tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(13,57): error TS1109: Expression expected. + + +==== tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts (22 errors) ==== + declare class X { + } + declare var prop11: X<() => Tany>; + ~ +!!! error TS2314: Generic type 'X' requires 1 type argument(s). + ~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + ~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + declare var prop12: X<(() => Tany)>; + declare function f1(): X<(() => Tany)>; + declare function f2(): X<(() => Tany)>; + declare function f3(): X<() => Tany>; + ~ +!!! error TS2314: Generic type 'X' requires 1 type argument(s). + ~~ +!!! error TS1144: '{' or ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + ~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + declare function f4(): X<(() => Tany)>; + declare class Y { + } + declare var prop2: Y() => Tany>; + declare var prop2: Y() => Tany>; + declare var prop3: Y<() => Tany, () => Tany>; + ~ +!!! error TS2314: Generic type 'Y' requires 2 type argument(s). + ~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + ~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~~~~ +!!! error TS2304: Cannot find name 'Tany'. + ~ +!!! error TS1109: Expression expected. + declare var prop4: Y<(() => Tany), () => Tany>; + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.symbols b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.symbols new file mode 100644 index 00000000000..ebbc2b764b0 --- /dev/null +++ b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.symbols @@ -0,0 +1,81 @@ +=== tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts === + +class X { +>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0)) +>A : Symbol(A, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 1, 8)) +} +var prop11: X< () => Tany >; // spaces before the first type argument +>prop11 : Symbol(prop11, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 3, 3)) +>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 3, 16)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 3, 16)) + +var prop12: X<(() => Tany)>; // spaces before the first type argument +>prop12 : Symbol(prop12, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 3)) +>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 16)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 16)) + +function f1() { // Inferred return type +>f1 : Symbol(f1, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 34)) + + return prop11; +>prop11 : Symbol(prop11, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 3, 3)) +} +function f2() { // Inferred return type +>f2 : Symbol(f2, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 7, 1)) + + return prop12; +>prop12 : Symbol(prop12, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 3)) +} +function f3(): X< () => Tany> { // written with space before type argument +>f3 : Symbol(f3, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 10, 1)) +>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 11, 19)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 11, 19)) + + return prop11; +>prop11 : Symbol(prop11, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 3, 3)) +} +function f4(): X<(() => Tany)> { // written type with parenthesis +>f4 : Symbol(f4, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 13, 1)) +>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 14, 19)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 14, 19)) + + return prop12; +>prop12 : Symbol(prop12, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 4, 3)) +} +class Y { +>Y : Symbol(Y, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 16, 1)) +>A : Symbol(A, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 17, 8)) +>B : Symbol(B, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 17, 10)) +} +var prop2: Y() => Tany>; // No space after second type argument +>prop2 : Symbol(prop2, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 19, 3), Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 20, 3)) +>Y : Symbol(Y, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 16, 1)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 19, 24)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 19, 24)) + +var prop2: Y() => Tany>; // space after second type argument +>prop2 : Symbol(prop2, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 19, 3), Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 20, 3)) +>Y : Symbol(Y, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 16, 1)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 20, 24)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 20, 24)) + +var prop3: Y< () => Tany, () => Tany>; // space before first type argument +>prop3 : Symbol(prop3, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 21, 3)) +>Y : Symbol(Y, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 16, 1)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 21, 15)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 21, 15)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 21, 33)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 21, 33)) + +var prop4: Y<(() => Tany), () => Tany>; // parenthesized first type argument +>prop4 : Symbol(prop4, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 22, 3)) +>Y : Symbol(Y, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 16, 1)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 22, 15)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 22, 15)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 22, 34)) +>Tany : Symbol(Tany, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 22, 34)) + diff --git a/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.types b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.types new file mode 100644 index 00000000000..4dd6ecba987 --- /dev/null +++ b/tests/baselines/reference/declarationEmitFirstTypeArgumentGenericFunctionType.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts === + +class X { +>X : X +>A : A +} +var prop11: X< () => Tany >; // spaces before the first type argument +>prop11 : X<(() => Tany)> +>X : X +>Tany : Tany +>Tany : Tany + +var prop12: X<(() => Tany)>; // spaces before the first type argument +>prop12 : X<(() => Tany)> +>X : X +>Tany : Tany +>Tany : Tany + +function f1() { // Inferred return type +>f1 : () => X<(() => Tany)> + + return prop11; +>prop11 : X<(() => Tany)> +} +function f2() { // Inferred return type +>f2 : () => X<(() => Tany)> + + return prop12; +>prop12 : X<(() => Tany)> +} +function f3(): X< () => Tany> { // written with space before type argument +>f3 : () => X<(() => Tany)> +>X : X +>Tany : Tany +>Tany : Tany + + return prop11; +>prop11 : X<(() => Tany)> +} +function f4(): X<(() => Tany)> { // written type with parenthesis +>f4 : () => X<(() => Tany)> +>X : X +>Tany : Tany +>Tany : Tany + + return prop12; +>prop12 : X<(() => Tany)> +} +class Y { +>Y : Y +>A : A +>B : B +} +var prop2: Y() => Tany>; // No space after second type argument +>prop2 : Y() => Tany> +>Y : Y +>Tany : Tany +>Tany : Tany + +var prop2: Y() => Tany>; // space after second type argument +>prop2 : Y() => Tany> +>Y : Y +>Tany : Tany +>Tany : Tany + +var prop3: Y< () => Tany, () => Tany>; // space before first type argument +>prop3 : Y<(() => Tany), () => Tany> +>Y : Y +>Tany : Tany +>Tany : Tany +>Tany : Tany +>Tany : Tany + +var prop4: Y<(() => Tany), () => Tany>; // parenthesized first type argument +>prop4 : Y<(() => Tany), () => Tany> +>Y : Y +>Tany : Tany +>Tany : Tany +>Tany : Tany +>Tany : Tany + diff --git a/tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts b/tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts new file mode 100644 index 00000000000..3c5100d0772 --- /dev/null +++ b/tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts @@ -0,0 +1,26 @@ +// @declaration: true +// @module: commonjs +// @target: es6 + +class X { +} +var prop11: X< () => Tany >; // spaces before the first type argument +var prop12: X<(() => Tany)>; // spaces before the first type argument +function f1() { // Inferred return type + return prop11; +} +function f2() { // Inferred return type + return prop12; +} +function f3(): X< () => Tany> { // written with space before type argument + return prop11; +} +function f4(): X<(() => Tany)> { // written type with parenthesis + return prop12; +} +class Y { +} +var prop2: Y() => Tany>; // No space after second type argument +var prop2: Y() => Tany>; // space after second type argument +var prop3: Y< () => Tany, () => Tany>; // space before first type argument +var prop4: Y<(() => Tany), () => Tany>; // parenthesized first type argument