diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.js b/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.js new file mode 100644 index 0000000000..5e4a8ea714 --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.js @@ -0,0 +1,92 @@ +//// [declFileTypeAnnotationTypeLiteral.ts] + +class c { +} +class g { +} +module m { + export class c { + } +} + +// Object literal with everything +var x: { + // Call signatures + (a: number): c; + (a: string): g; + + // Construct signatures + new (a: number): c; + new (a: string): m.c; + + // Indexers + [n: number]: c; + [n: string]: c; + + // Properties + a: c; + b: g; + + // methods + m1(): g; + 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 { +} +declare module m { + class c { + } +} +declare var x: { + (a: number): c; + (a: string): g; + new (a: number): c; + new (a: string): m.c; + [n: number]: c; + [n: string]: c; + a: c; + b: g; + m1(): g; + m2(a: string, b?: number, ...c: c[]): string; +}; +declare var y: (a: string) => string; +declare var z: new (a: string) => m.c; diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.types b/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.types new file mode 100644 index 0000000000..432ee1506f --- /dev/null +++ b/tests/baselines/reference/declFileTypeAnnotationTypeLiteral.types @@ -0,0 +1,85 @@ +=== tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts === + +class c { +>c : c +} +class g { +>g : g +>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; new (a: number): c; new (a: string): m.c; [x: string]: c; [x: number]: c; a: c; b: g; m1(): g; m2(a: string, b?: number, ...c: c[]): string; } + + // Call signatures + (a: number): c; +>a : number +>c : c + + (a: string): g; +>a : string +>g : g + + // 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; +>b : g +>g : g + + // methods + m1(): g; +>m1 : () => g +>g : g + + 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 + diff --git a/tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts b/tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts new file mode 100644 index 0000000000..e41495b68d --- /dev/null +++ b/tests/cases/compiler/declFileTypeAnnotationTypeLiteral.ts @@ -0,0 +1,41 @@ +// @target: ES5 +// @declaration: true + +class c { +} +class g { +} +module m { + export class c { + } +} + +// Object literal with everything +var x: { + // Call signatures + (a: number): c; + (a: string): g; + + // Construct signatures + new (a: number): c; + new (a: string): m.c; + + // Indexers + [n: number]: c; + [n: string]: c; + + // Properties + a: c; + b: g; + + // methods + m1(): g; + m2(a: string, b?: number, ...c: c[]): string; +}; + + +// Function type +var y: (a: string) => string; + +// constructor type +var z: new (a: string) => m.c; \ No newline at end of file