104 lines
No EOL
5.1 KiB
Text
104 lines
No EOL
5.1 KiB
Text
tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(37,18): error TS1039: Initializers are not allowed in ambient contexts.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(38,11): error TS1039: Initializers are not allowed in ambient contexts.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1111: A constructor implementation cannot be declared in an ambient context.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient external module declaration cannot specify relative module name.
|
|
tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
|
|
|
|
|
==== tests/cases/conformance/ambient/ambientErrors.ts (14 errors) ====
|
|
// Ambient variable with an initializer
|
|
declare var x = 4;
|
|
~
|
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
|
|
|
// Ambient functions with invalid overloads
|
|
declare function fn(x: number): string;
|
|
declare function fn(x: 'foo'): number;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2382: 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);
|
|
~~~~~
|
|
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
|
|
|
// Ambient function with function body
|
|
declare function fn4() { };
|
|
~
|
|
!!! error TS1037: 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 with computer member
|
|
declare enum E2 {
|
|
x = 'foo'.length
|
|
}
|
|
|
|
// Ambient module with initializers for values, bodies for functions / classes
|
|
declare module M1 {
|
|
var x = 3;
|
|
~
|
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
|
function fn() { }
|
|
~
|
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
|
class C {
|
|
static x = 3;
|
|
~
|
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
|
y = 4;
|
|
~
|
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
|
constructor() { }
|
|
~
|
|
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
|
|
fn() { }
|
|
~
|
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
|
static sfn() { }
|
|
~
|
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
|
}
|
|
}
|
|
|
|
// Ambient external module not in the global module
|
|
module M2 {
|
|
declare module 'nope' { }
|
|
~~~~~~
|
|
!!! error TS2435: 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' { }
|
|
~~~~~~~~
|
|
!!! error TS2436: 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;
|
|
~~~~~~~~~~~
|
|
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
|
}
|
|
|