168 lines
2.6 KiB
Text
168 lines
2.6 KiB
Text
=== tests/cases/conformance/ambient/ambientDeclarations.ts ===
|
|
// Ambient variable without type annotation
|
|
declare var n;
|
|
>n : any
|
|
|
|
// Ambient variable with type annotation
|
|
declare var m: string;
|
|
>m : string
|
|
|
|
// Ambient function with no type annotations
|
|
declare function fn1();
|
|
>fn1 : typeof fn1
|
|
|
|
// Ambient function with type annotations
|
|
declare function fn2(n: string): number;
|
|
>fn2 : typeof fn2
|
|
>n : string
|
|
|
|
// Ambient function with valid overloads
|
|
declare function fn3(n: string): number;
|
|
>fn3 : typeof fn3
|
|
>n : string
|
|
|
|
declare function fn4(n: number, y: number): string;
|
|
>fn4 : typeof fn4
|
|
>n : number
|
|
>y : number
|
|
|
|
// Ambient function with optional parameters
|
|
declare function fn5(x, y?);
|
|
>fn5 : typeof fn5
|
|
>x : any
|
|
>y : any
|
|
|
|
declare function fn6(e?);
|
|
>fn6 : typeof fn6
|
|
>e : any
|
|
|
|
declare function fn7(x, y?, ...z);
|
|
>fn7 : typeof fn7
|
|
>x : any
|
|
>y : any
|
|
>z : any[]
|
|
|
|
declare function fn8(y?, ...z: number[]);
|
|
>fn8 : typeof fn8
|
|
>y : any
|
|
>z : number[]
|
|
|
|
declare function fn9(...q: {}[]);
|
|
>fn9 : typeof fn9
|
|
>q : {}[]
|
|
|
|
declare function fn10<T>(...q: T[]);
|
|
>fn10 : typeof fn10
|
|
>T : T
|
|
>q : T[]
|
|
>T : T
|
|
|
|
// Ambient class
|
|
declare class cls {
|
|
>cls : cls
|
|
|
|
constructor();
|
|
method(): cls;
|
|
>method : () => cls
|
|
>cls : cls
|
|
|
|
static static(p): number;
|
|
>static : (p: any) => number
|
|
>p : any
|
|
|
|
static q;
|
|
>q : any
|
|
|
|
private fn();
|
|
>fn : () => any
|
|
|
|
private static fns();
|
|
>fns : () => any
|
|
}
|
|
|
|
// Ambient enum
|
|
declare enum E1 {
|
|
>E1 : E1
|
|
|
|
x,
|
|
>x : E1
|
|
|
|
y,
|
|
>y : E1
|
|
|
|
z
|
|
>z : E1
|
|
}
|
|
|
|
// Ambient enum with integer literal initializer
|
|
declare enum E2 {
|
|
>E2 : E2
|
|
|
|
q,
|
|
>q : E2
|
|
|
|
a = 1,
|
|
>a : E2
|
|
|
|
b,
|
|
>b : E2
|
|
|
|
c = 2,
|
|
>c : E2
|
|
|
|
d
|
|
>d : E2
|
|
}
|
|
|
|
// Ambient enum members are always exported with or without export keyword
|
|
declare enum E3 {
|
|
>E3 : E3
|
|
|
|
A
|
|
>A : E3
|
|
}
|
|
declare module E3 {
|
|
>E3 : typeof E3
|
|
|
|
var B;
|
|
>B : any
|
|
}
|
|
var x = E3.B;
|
|
>x : any
|
|
>E3.B : any
|
|
>E3 : typeof E3
|
|
>B : any
|
|
|
|
// Ambient module
|
|
declare module M1 {
|
|
>M1 : typeof M1
|
|
|
|
var x;
|
|
>x : any
|
|
|
|
function fn(): number;
|
|
>fn : typeof fn
|
|
}
|
|
|
|
// 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
|
|
|
|
var q = M1.fn();
|
|
>q : number
|
|
>M1.fn() : number
|
|
>M1.fn : typeof M1.fn
|
|
>M1 : typeof M1
|
|
>fn : typeof M1.fn
|
|
|
|
// 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
|
|
}
|
|
|
|
|