2014-11-20 03:06:01 +01:00
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(24,5): error TS1066: Ambient enum elements can only have integer literal initializers.
tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers.
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,20): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(38,13): 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.
2014-09-12 22:35:07 +02:00
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.
2014-11-20 03:06:01 +01:00
==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ====
2014-07-13 01:04:16 +02:00
// Ambient variable with an initializer
declare var x = 4;
2014-11-20 03:06:01 +01:00
~
!!! error TS1039: Initializers are not allowed in ambient contexts.
2014-07-13 01:04:16 +02:00
// Ambient functions with invalid overloads
declare function fn(x: number): string;
declare function fn(x: 'foo'): number;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
2014-07-13 01:04:16 +02:00
// 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);
~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2014-07-13 01:04:16 +02:00
// Ambient function with function body
declare function fn4() { };
2014-11-20 03:06:01 +01:00
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
2014-07-13 01:04:16 +02:00
// Ambient enum with non - integer literal constant member
declare enum E1 {
y = 4.23
2014-11-20 03:06:01 +01:00
~
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
2014-07-13 01:04:16 +02:00
}
// Ambient enum with computer member
declare enum E2 {
x = 'foo'.length
2014-11-20 03:06:01 +01:00
~
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
2014-07-13 01:04:16 +02:00
}
// Ambient module with initializers for values, bodies for functions / classes
declare module M1 {
var x = 3;
2014-11-20 03:06:01 +01:00
~
!!! error TS1039: Initializers are not allowed in ambient contexts.
2014-07-13 01:04:16 +02:00
function fn() { }
2014-11-20 03:06:01 +01:00
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
2014-07-13 01:04:16 +02:00
class C {
static x = 3;
2014-11-20 03:06:01 +01:00
~
2014-09-12 00:19:57 +02:00
!!! error TS1039: Initializers are not allowed in ambient contexts.
2014-07-13 01:04:16 +02:00
y = 4;
2014-11-20 03:06:01 +01:00
~
2014-09-12 00:19:57 +02:00
!!! error TS1039: Initializers are not allowed in ambient contexts.
2014-07-13 01:04:16 +02:00
constructor() { }
2014-11-20 03:06:01 +01:00
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
2014-07-13 01:04:16 +02:00
fn() { }
2014-11-20 03:06:01 +01:00
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
2014-07-13 01:04:16 +02:00
static sfn() { }
2014-11-20 03:06:01 +01:00
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
2014-07-13 01:04:16 +02:00
}
}
// Ambient external module not in the global module
module M2 {
declare module 'nope' { }
2014-07-17 01:15:10 +02:00
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2435: Ambient external modules cannot be nested in other modules.
2014-07-13 01:04:16 +02:00
}
// Ambient external module with a string literal name that isn't a top level external module name
declare module '../foo' { }
2014-07-17 01:15:10 +02:00
~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2436: Ambient external module declaration cannot specify relative module name.
2014-07-13 01:04:16 +02:00
// Ambient external module with export assignment and other exported members
declare module 'bar' {
var n;
export var q;
export = n;
~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
2014-07-13 01:04:16 +02:00
}