Test cases for type literal annotation
This commit is contained in:
parent
9e41b0fed4
commit
c661ffa7ec
|
@ -0,0 +1,92 @@
|
|||
//// [declFileTypeAnnotationTypeLiteral.ts]
|
||||
|
||||
class c {
|
||||
}
|
||||
class g<T> {
|
||||
}
|
||||
module m {
|
||||
export class c {
|
||||
}
|
||||
}
|
||||
|
||||
// Object literal with everything
|
||||
var x: {
|
||||
// Call signatures
|
||||
(a: number): c;
|
||||
(a: string): g<string>;
|
||||
|
||||
// Construct signatures
|
||||
new (a: number): c;
|
||||
new (a: string): m.c;
|
||||
|
||||
// Indexers
|
||||
[n: number]: c;
|
||||
[n: string]: c;
|
||||
|
||||
// Properties
|
||||
a: c;
|
||||
b: g<string>;
|
||||
|
||||
// methods
|
||||
m1(): g<number>;
|
||||
m2(a: string, b?: number, ...c: c[]): string;
|
||||
};
|
||||
|
||||
|
||||
// Function type
|
||||
var y: (a: string) => string;
|
||||
|
||||
// constructor type
|
||||
var z: new (a: string) => m.c;
|
||||
|
||||
//// [declFileTypeAnnotationTypeLiteral.js]
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
var g = (function () {
|
||||
function g() {
|
||||
}
|
||||
return g;
|
||||
})();
|
||||
var m;
|
||||
(function (m) {
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m.c = c;
|
||||
})(m || (m = {}));
|
||||
// Object literal with everything
|
||||
var x;
|
||||
// Function type
|
||||
var y;
|
||||
// constructor type
|
||||
var z;
|
||||
|
||||
|
||||
//// [declFileTypeAnnotationTypeLiteral.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
declare class g<T> {
|
||||
}
|
||||
declare module m {
|
||||
class c {
|
||||
}
|
||||
}
|
||||
declare var x: {
|
||||
(a: number): c;
|
||||
(a: string): g<string>;
|
||||
new (a: number): c;
|
||||
new (a: string): m.c;
|
||||
[n: number]: c;
|
||||
[n: string]: c;
|
||||
a: c;
|
||||
b: g<string>;
|
||||
m1(): g<number>;
|
||||
m2(a: string, b?: number, ...c: c[]): string;
|
||||
};
|
||||
declare var y: (a: string) => string;
|
||||
declare var z: new (a: string) => m.c;
|
|
@ -0,0 +1,85 @@
|
|||
=== tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts ===
|
||||
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
class g<T> {
|
||||
>g : g<T>
|
||||
>T : T
|
||||
}
|
||||
module m {
|
||||
>m : typeof m
|
||||
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
}
|
||||
|
||||
// Object literal with everything
|
||||
var x: {
|
||||
>x : { (a: number): c; (a: string): g<string>; new (a: number): c; new (a: string): m.c; [x: string]: c; [x: number]: c; a: c; b: g<string>; m1(): g<number>; m2(a: string, b?: number, ...c: c[]): string; }
|
||||
|
||||
// Call signatures
|
||||
(a: number): c;
|
||||
>a : number
|
||||
>c : c
|
||||
|
||||
(a: string): g<string>;
|
||||
>a : string
|
||||
>g : g<T>
|
||||
|
||||
// Construct signatures
|
||||
new (a: number): c;
|
||||
>a : number
|
||||
>c : c
|
||||
|
||||
new (a: string): m.c;
|
||||
>a : string
|
||||
>m : unknown
|
||||
>c : m.c
|
||||
|
||||
// Indexers
|
||||
[n: number]: c;
|
||||
>n : number
|
||||
>c : c
|
||||
|
||||
[n: string]: c;
|
||||
>n : string
|
||||
>c : c
|
||||
|
||||
// Properties
|
||||
a: c;
|
||||
>a : c
|
||||
>c : c
|
||||
|
||||
b: g<string>;
|
||||
>b : g<string>
|
||||
>g : g<T>
|
||||
|
||||
// methods
|
||||
m1(): g<number>;
|
||||
>m1 : () => g<number>
|
||||
>g : g<T>
|
||||
|
||||
m2(a: string, b?: number, ...c: c[]): string;
|
||||
>m2 : (a: string, b?: number, ...c: c[]) => string
|
||||
>a : string
|
||||
>b : number
|
||||
>c : c[]
|
||||
>c : c
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Function type
|
||||
var y: (a: string) => string;
|
||||
>y : (a: string) => string
|
||||
>a : string
|
||||
|
||||
// constructor type
|
||||
var z: new (a: string) => m.c;
|
||||
>z : new (a: string) => m.c
|
||||
>a : string
|
||||
>m : unknown
|
||||
>c : m.c
|
||||
|
41
tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts
Normal file
41
tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
// @target: ES5
|
||||
// @declaration: true
|
||||
|
||||
class c {
|
||||
}
|
||||
class g<T> {
|
||||
}
|
||||
module m {
|
||||
export class c {
|
||||
}
|
||||
}
|
||||
|
||||
// Object literal with everything
|
||||
var x: {
|
||||
// Call signatures
|
||||
(a: number): c;
|
||||
(a: string): g<string>;
|
||||
|
||||
// Construct signatures
|
||||
new (a: number): c;
|
||||
new (a: string): m.c;
|
||||
|
||||
// Indexers
|
||||
[n: number]: c;
|
||||
[n: string]: c;
|
||||
|
||||
// Properties
|
||||
a: c;
|
||||
b: g<string>;
|
||||
|
||||
// methods
|
||||
m1(): g<number>;
|
||||
m2(a: string, b?: number, ...c: c[]): string;
|
||||
};
|
||||
|
||||
|
||||
// Function type
|
||||
var y: (a: string) => string;
|
||||
|
||||
// constructor type
|
||||
var z: new (a: string) => m.c;
|
Loading…
Reference in a new issue