==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ==== // Ambient variable with an initializer declare var x = 4; ~ !!! Initializers are not allowed in ambient contexts. // Ambient functions with invalid overloads declare function fn(x: number): string; declare function fn(x: 'foo'): number; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! Specialized overload signature is not assignable to any non-specialized signature. // Ambient functions with duplicate signatures declare function fn1(x: number): string; declare function fn1(x: number): string; // Ambient function overloads that differ only by return type declare function fn2(x: number): string; declare function fn2(x: number): number; // Ambient function with default parameter values declare function fn3(x = 3); ~~~~~ !!! A parameter initializer is only allowed in a function or constructor implementation. // Ambient function with function body declare function fn4() { }; ~ !!! A function implementation cannot be declared in an ambient context. // Ambient enum with non - integer literal constant member declare enum E1 { y = 4.23 ~ !!! Ambient enum elements can only have integer literal initializers. } // Ambient enum with computer member declare enum E2 { x = 'foo'.length ~ !!! Ambient enum elements can only have integer literal initializers. } // Ambient module with initializers for values, bodies for functions / classes declare module M1 { var x = 3; ~ !!! Initializers are not allowed in ambient contexts. function fn() { } ~ !!! A function implementation cannot be declared in an ambient context. class C { static x = 3; ~ !!! Initializers are not allowed in ambient contexts. y = 4; ~ !!! Initializers are not allowed in ambient contexts. constructor() { } ~ !!! A constructor implementation cannot be declared in an ambient context. fn() { } ~ !!! A function implementation cannot be declared in an ambient context. static sfn() { } ~ !!! A function implementation cannot be declared in an ambient context. } } // Ambient external module not in the global module module M2 { declare module 'nope' { } ~~~~~~ !!! Ambient external modules cannot be nested in other modules. } // Ambient external module with a string literal name that isn't a top level external module name declare module '../foo' { } ~~~~~~~~ !!! Ambient external module declaration cannot specify relative module name. // Ambient external module with export assignment and other exported members declare module 'bar' { var n; export var q; export = n; ~~~~~~~~~~~ !!! An export assignment cannot be used in a module with other exported elements. }