Adding another test case to handle more generic scenarios

This commit is contained in:
Sheetal Nandi
2016-04-18 15:47:03 -07:00
parent dc4871a12a
commit 06f54b9124
4 changed files with 343 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
//// [declarationEmitFirstTypeArgumentGenericFunctionType.ts]
class X<A> {
}
var prop11: X< <Tany>() => Tany >; // spaces before the first type argument
var prop12: X<(<Tany>() => 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>() => Tany> { // written with space before type argument
return prop11;
}
function f4(): X<(<Tany>() => Tany)> { // written type with parenthesis
return prop12;
}
class Y<A, B> {
}
var prop2: Y<string[], <Tany>() => Tany>; // No space after second type argument
var prop2: Y<string[], <Tany>() => Tany>; // space after second type argument
var prop3: Y< <Tany>() => Tany, <Tany>() => Tany>; // space before first type argument
var prop4: Y<(<Tany>() => Tany), <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<A> {
}
declare var prop11: X<<Tany>() => Tany>;
declare var prop12: X<(<Tany>() => Tany)>;
declare function f1(): X<(<Tany>() => Tany)>;
declare function f2(): X<(<Tany>() => Tany)>;
declare function f3(): X<<Tany>() => Tany>;
declare function f4(): X<(<Tany>() => Tany)>;
declare class Y<A, B> {
}
declare var prop2: Y<string[], <Tany>() => Tany>;
declare var prop2: Y<string[], <Tany>() => Tany>;
declare var prop3: Y<<Tany>() => Tany, <Tany>() => Tany>;
declare var prop4: Y<(<Tany>() => Tany), <Tany>() => Tany>;
//// [DtsFileErrors]
tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.d.ts(3,21): error TS2314: Generic type 'X<A>' 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<A>' 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<A, B>' 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<A> {
}
declare var prop11: X<<Tany>() => Tany>;
~
!!! error TS2314: Generic type 'X<A>' 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>() => Tany)>;
declare function f1(): X<(<Tany>() => Tany)>;
declare function f2(): X<(<Tany>() => Tany)>;
declare function f3(): X<<Tany>() => Tany>;
~
!!! error TS2314: Generic type 'X<A>' 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>() => Tany)>;
declare class Y<A, B> {
}
declare var prop2: Y<string[], <Tany>() => Tany>;
declare var prop2: Y<string[], <Tany>() => Tany>;
declare var prop3: Y<<Tany>() => Tany, <Tany>() => Tany>;
~
!!! error TS2314: Generic type 'Y<A, B>' 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), <Tany>() => Tany>;

View File

@@ -0,0 +1,81 @@
=== tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts ===
class X<A> {
>X : Symbol(X, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 0, 0))
>A : Symbol(A, Decl(declarationEmitFirstTypeArgumentGenericFunctionType.ts, 1, 8))
}
var prop11: X< <Tany>() => 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>() => 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>() => 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>() => 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<A, B> {
>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<string[], <Tany>() => 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<string[], <Tany>() => 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, <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), <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))

View File

@@ -0,0 +1,81 @@
=== tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts ===
class X<A> {
>X : X<A>
>A : A
}
var prop11: X< <Tany>() => Tany >; // spaces before the first type argument
>prop11 : X<(<Tany>() => Tany)>
>X : X<A>
>Tany : Tany
>Tany : Tany
var prop12: X<(<Tany>() => Tany)>; // spaces before the first type argument
>prop12 : X<(<Tany>() => Tany)>
>X : X<A>
>Tany : Tany
>Tany : Tany
function f1() { // Inferred return type
>f1 : () => X<(<Tany>() => Tany)>
return prop11;
>prop11 : X<(<Tany>() => Tany)>
}
function f2() { // Inferred return type
>f2 : () => X<(<Tany>() => Tany)>
return prop12;
>prop12 : X<(<Tany>() => Tany)>
}
function f3(): X< <Tany>() => Tany> { // written with space before type argument
>f3 : () => X<(<Tany>() => Tany)>
>X : X<A>
>Tany : Tany
>Tany : Tany
return prop11;
>prop11 : X<(<Tany>() => Tany)>
}
function f4(): X<(<Tany>() => Tany)> { // written type with parenthesis
>f4 : () => X<(<Tany>() => Tany)>
>X : X<A>
>Tany : Tany
>Tany : Tany
return prop12;
>prop12 : X<(<Tany>() => Tany)>
}
class Y<A, B> {
>Y : Y<A, B>
>A : A
>B : B
}
var prop2: Y<string[], <Tany>() => Tany>; // No space after second type argument
>prop2 : Y<string[], <Tany>() => Tany>
>Y : Y<A, B>
>Tany : Tany
>Tany : Tany
var prop2: Y<string[], <Tany>() => Tany>; // space after second type argument
>prop2 : Y<string[], <Tany>() => Tany>
>Y : Y<A, B>
>Tany : Tany
>Tany : Tany
var prop3: Y< <Tany>() => Tany, <Tany>() => Tany>; // space before first type argument
>prop3 : Y<(<Tany>() => Tany), <Tany>() => Tany>
>Y : Y<A, B>
>Tany : Tany
>Tany : Tany
>Tany : Tany
>Tany : Tany
var prop4: Y<(<Tany>() => Tany), <Tany>() => Tany>; // parenthesized first type argument
>prop4 : Y<(<Tany>() => Tany), <Tany>() => Tany>
>Y : Y<A, B>
>Tany : Tany
>Tany : Tany
>Tany : Tany
>Tany : Tany

View File

@@ -0,0 +1,26 @@
// @declaration: true
// @module: commonjs
// @target: es6
class X<A> {
}
var prop11: X< <Tany>() => Tany >; // spaces before the first type argument
var prop12: X<(<Tany>() => 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>() => Tany> { // written with space before type argument
return prop11;
}
function f4(): X<(<Tany>() => Tany)> { // written type with parenthesis
return prop12;
}
class Y<A, B> {
}
var prop2: Y<string[], <Tany>() => Tany>; // No space after second type argument
var prop2: Y<string[], <Tany>() => Tany>; // space after second type argument
var prop3: Y< <Tany>() => Tany, <Tany>() => Tany>; // space before first type argument
var prop4: Y<(<Tany>() => Tany), <Tany>() => Tany>; // parenthesized first type argument