TypeScript/tests/baselines/reference/ambientErrors.errors.txt
Wesley Wigham 62d8b85f1d
Allow literal initializers of readonly properties in declaration files (#26313)
* Allow literal initializers of readonly properties in declaration files

* Move some conditions a bit
2018-09-05 11:30:05 -07:00

104 lines
5 KiB
Plaintext

tests/cases/conformance/ambient/ambientErrors.ts(2,17): error TS1039: Initializers are not allowed in ambient contexts.
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(20,24): error TS1183: An implementation cannot be declared in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(29,9): error TS1066: In ambient enum declarations member initializer must be constant expression.
tests/cases/conformance/ambient/ambientErrors.ts(34,13): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1183: An implementation cannot be declared in ambient contexts.
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 TS1183: An implementation cannot be declared in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1183: An implementation cannot be declared in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1183: An implementation cannot be declared in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient 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;
// 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 TS1183: An implementation cannot be declared in ambient contexts.
// 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
~~~~~~~~~~~~
!!! error TS1066: In ambient enum declarations member initializer must be constant expression.
}
// 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 TS1183: An implementation cannot be declared in ambient contexts.
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 TS1183: An implementation cannot be declared in ambient contexts.
fn() { }
~
!!! error TS1183: An implementation cannot be declared in ambient contexts.
static sfn() { }
~
!!! error TS1183: An implementation cannot be declared in ambient contexts.
}
}
// Ambient external module not in the global module
module M2 {
declare module 'nope' { }
~~~~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
}
// Ambient external module with a string literal name that isn't a top level external module name
declare module '../foo' { }
~~~~~~~~
!!! error TS2436: Ambient 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.
}