TypeScript/tests/baselines/reference/ambientDeclarations.types

171 lines
2.7 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/ambient/ambientDeclarations.ts ===
// Ambient variable without type annotation
declare var n;
>n : any
2014-08-15 23:33:16 +02:00
// Ambient variable with type annotation
declare var m: string;
>m : string
2014-08-15 23:33:16 +02:00
// Ambient function with no type annotations
declare function fn1();
>fn1 : () => any
2014-08-15 23:33:16 +02:00
// Ambient function with type annotations
declare function fn2(n: string): number;
>fn2 : (n: string) => number
>n : string
2014-08-15 23:33:16 +02:00
// Ambient function with valid overloads
declare function fn3(n: string): number;
>fn3 : (n: string) => number
>n : string
2014-08-15 23:33:16 +02:00
declare function fn4(n: number, y: number): string;
>fn4 : (n: number, y: number) => string
>n : number
>y : number
2014-08-15 23:33:16 +02:00
// Ambient function with optional parameters
declare function fn5(x, y?);
>fn5 : (x: any, y?: any) => any
>x : any
>y : any
2014-08-15 23:33:16 +02:00
declare function fn6(e?);
>fn6 : (e?: any) => any
>e : any
2014-08-15 23:33:16 +02:00
declare function fn7(x, y?, ...z);
>fn7 : (x: any, y?: any, ...z: any[]) => any
>x : any
>y : any
>z : any[]
2014-08-15 23:33:16 +02:00
declare function fn8(y?, ...z: number[]);
>fn8 : (y?: any, ...z: number[]) => any
>y : any
>z : number[]
2014-08-15 23:33:16 +02:00
declare function fn9(...q: {}[]);
>fn9 : (...q: {}[]) => any
>q : {}[]
2014-08-15 23:33:16 +02:00
declare function fn10<T>(...q: T[]);
>fn10 : <T>(...q: T[]) => any
>T : T
>q : T[]
>T : T
2014-08-15 23:33:16 +02:00
// Ambient class
declare class cls {
>cls : cls
2014-08-15 23:33:16 +02:00
constructor();
method(): cls;
>method : () => cls
>cls : cls
2014-08-15 23:33:16 +02:00
static static(p): number;
>static : (p: any) => number
>p : any
2014-08-15 23:33:16 +02:00
static q;
>q : any
2014-08-15 23:33:16 +02:00
private fn();
>fn : () => any
2014-08-15 23:33:16 +02:00
private static fns();
>fns : () => any
2014-08-15 23:33:16 +02:00
}
// Ambient enum
declare enum E1 {
>E1 : E1
2014-08-15 23:33:16 +02:00
x,
>x : E1
2014-08-15 23:33:16 +02:00
y,
>y : E1
2014-08-15 23:33:16 +02:00
z
>z : E1
2014-08-15 23:33:16 +02:00
}
// Ambient enum with integer literal initializer
declare enum E2 {
>E2 : E2
2014-08-15 23:33:16 +02:00
q,
>q : E2
2014-08-15 23:33:16 +02:00
a = 1,
>a : E2
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
b,
>b : E2
2014-08-15 23:33:16 +02:00
c = 2,
>c : E2
2015-04-13 21:36:11 +02:00
>2 : number
2014-08-15 23:33:16 +02:00
d
>d : E2
2014-08-15 23:33:16 +02:00
}
// Ambient enum members are always exported with or without export keyword
declare enum E3 {
>E3 : E3
2014-08-15 23:33:16 +02:00
A
>A : E3
2014-08-15 23:33:16 +02:00
}
declare module E3 {
>E3 : typeof E3
2014-08-15 23:33:16 +02:00
var B;
>B : any
2014-08-15 23:33:16 +02:00
}
var x = E3.B;
>x : any
>E3.B : any
>E3 : typeof E3
>B : any
2014-08-15 23:33:16 +02:00
// Ambient module
declare module M1 {
>M1 : typeof M1
2014-08-15 23:33:16 +02:00
var x;
>x : any
2014-08-15 23:33:16 +02:00
function fn(): number;
>fn : () => number
2014-08-15 23:33:16 +02:00
}
// Ambient module members are always exported with or without export keyword
var p = M1.x;
>p : any
>M1.x : any
>M1 : typeof M1
>x : any
2014-08-15 23:33:16 +02:00
var q = M1.fn();
>q : number
2014-08-15 23:33:16 +02:00
>M1.fn() : number
>M1.fn : () => number
>M1 : typeof M1
>fn : () => number
2014-08-15 23:33:16 +02:00
// Ambient external module in the global module
// Ambient external module with a string literal name that is a top level external module name
declare module 'external1' {
var q;
>q : any
2014-08-15 23:33:16 +02:00
}