-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add declaration file version of this test
- Loading branch information
1 parent
6aee14c
commit 52a5578
Showing
3 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
tests/baselines/reference/erasableSyntaxOnlyDeclaration.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
decl.d.ts(1,1): error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier. | ||
decl.d.ts(3,17): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
decl.d.ts(3,17): error TS2369: A parameter property is only allowed in a constructor implementation. | ||
|
||
|
||
==== decl.d.ts (3 errors) ==== | ||
class MyClassErr { | ||
~~~~~ | ||
!!! error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier. | ||
// No parameter properties | ||
constructor(public foo: string); | ||
~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2369: A parameter property is only allowed in a constructor implementation. | ||
} | ||
|
||
namespace IllegalBecauseInstantiated { | ||
export const m = 1; | ||
} | ||
|
||
namespace AlsoIllegalBecauseInstantiated { | ||
class PrivateClass { | ||
|
||
} | ||
} | ||
|
||
enum NotLegalEnum { | ||
B = 1 | ||
} | ||
|
||
const enum NotLegalConstEnum { | ||
C = 2 | ||
} | ||
|
||
// No errors after this point | ||
class MyClassOk { | ||
// Not a parameter property, ok | ||
constructor(foo: string); | ||
} | ||
namespace NotInstantiated { | ||
export interface JustAType { } | ||
export type ATypeInANamespace = {}; | ||
} | ||
declare namespace AmbientIsNotInstantiated { | ||
export const stillOk = 12; | ||
} | ||
|
||
declare enum LegalEnum { | ||
A = 1 | ||
} | ||
|
||
declare namespace AmbientStuff { | ||
namespace Nested { | ||
export const stillOk = 12; | ||
} | ||
enum EnumInAmbientContext { | ||
B = 1 | ||
} | ||
} | ||
|
89 changes: 89 additions & 0 deletions
89
tests/baselines/reference/erasableSyntaxOnlyDeclaration.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
//// [tests/cases/compiler/erasableSyntaxOnlyDeclaration.ts] //// | ||
|
||
=== decl.d.ts === | ||
class MyClassErr { | ||
>MyClassErr : Symbol(MyClassErr, Decl(decl.d.ts, 0, 0)) | ||
|
||
// No parameter properties | ||
constructor(public foo: string); | ||
>foo : Symbol(MyClassErr.foo, Decl(decl.d.ts, 2, 16)) | ||
} | ||
|
||
namespace IllegalBecauseInstantiated { | ||
>IllegalBecauseInstantiated : Symbol(IllegalBecauseInstantiated, Decl(decl.d.ts, 3, 1)) | ||
|
||
export const m = 1; | ||
>m : Symbol(m, Decl(decl.d.ts, 6, 16)) | ||
} | ||
|
||
namespace AlsoIllegalBecauseInstantiated { | ||
>AlsoIllegalBecauseInstantiated : Symbol(AlsoIllegalBecauseInstantiated, Decl(decl.d.ts, 7, 1)) | ||
|
||
class PrivateClass { | ||
>PrivateClass : Symbol(PrivateClass, Decl(decl.d.ts, 9, 42)) | ||
|
||
} | ||
} | ||
|
||
enum NotLegalEnum { | ||
>NotLegalEnum : Symbol(NotLegalEnum, Decl(decl.d.ts, 13, 1)) | ||
|
||
B = 1 | ||
>B : Symbol(NotLegalEnum.B, Decl(decl.d.ts, 15, 19)) | ||
} | ||
|
||
const enum NotLegalConstEnum { | ||
>NotLegalConstEnum : Symbol(NotLegalConstEnum, Decl(decl.d.ts, 17, 1)) | ||
|
||
C = 2 | ||
>C : Symbol(NotLegalConstEnum.C, Decl(decl.d.ts, 19, 30)) | ||
} | ||
|
||
// No errors after this point | ||
class MyClassOk { | ||
>MyClassOk : Symbol(MyClassOk, Decl(decl.d.ts, 21, 1)) | ||
|
||
// Not a parameter property, ok | ||
constructor(foo: string); | ||
>foo : Symbol(foo, Decl(decl.d.ts, 26, 16)) | ||
} | ||
namespace NotInstantiated { | ||
>NotInstantiated : Symbol(NotInstantiated, Decl(decl.d.ts, 27, 1)) | ||
|
||
export interface JustAType { } | ||
>JustAType : Symbol(JustAType, Decl(decl.d.ts, 28, 27)) | ||
|
||
export type ATypeInANamespace = {}; | ||
>ATypeInANamespace : Symbol(ATypeInANamespace, Decl(decl.d.ts, 29, 34)) | ||
} | ||
declare namespace AmbientIsNotInstantiated { | ||
>AmbientIsNotInstantiated : Symbol(AmbientIsNotInstantiated, Decl(decl.d.ts, 31, 1)) | ||
|
||
export const stillOk = 12; | ||
>stillOk : Symbol(stillOk, Decl(decl.d.ts, 33, 16)) | ||
} | ||
|
||
declare enum LegalEnum { | ||
>LegalEnum : Symbol(LegalEnum, Decl(decl.d.ts, 34, 1)) | ||
|
||
A = 1 | ||
>A : Symbol(LegalEnum.A, Decl(decl.d.ts, 36, 24)) | ||
} | ||
|
||
declare namespace AmbientStuff { | ||
>AmbientStuff : Symbol(AmbientStuff, Decl(decl.d.ts, 38, 1)) | ||
|
||
namespace Nested { | ||
>Nested : Symbol(Nested, Decl(decl.d.ts, 40, 32)) | ||
|
||
export const stillOk = 12; | ||
>stillOk : Symbol(stillOk, Decl(decl.d.ts, 42, 20)) | ||
} | ||
enum EnumInAmbientContext { | ||
>EnumInAmbientContext : Symbol(EnumInAmbientContext, Decl(decl.d.ts, 43, 5)) | ||
|
||
B = 1 | ||
>B : Symbol(EnumInAmbientContext.B, Decl(decl.d.ts, 44, 31)) | ||
} | ||
} | ||
|
121 changes: 121 additions & 0 deletions
121
tests/baselines/reference/erasableSyntaxOnlyDeclaration.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
//// [tests/cases/compiler/erasableSyntaxOnlyDeclaration.ts] //// | ||
|
||
=== decl.d.ts === | ||
class MyClassErr { | ||
>MyClassErr : MyClassErr | ||
> : ^^^^^^^^^^ | ||
|
||
// No parameter properties | ||
constructor(public foo: string); | ||
>foo : string | ||
> : ^^^^^^ | ||
} | ||
|
||
namespace IllegalBecauseInstantiated { | ||
>IllegalBecauseInstantiated : typeof IllegalBecauseInstantiated | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
export const m = 1; | ||
>m : 1 | ||
> : ^ | ||
>1 : 1 | ||
> : ^ | ||
} | ||
|
||
namespace AlsoIllegalBecauseInstantiated { | ||
>AlsoIllegalBecauseInstantiated : typeof AlsoIllegalBecauseInstantiated | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
class PrivateClass { | ||
>PrivateClass : PrivateClass | ||
> : ^^^^^^^^^^^^ | ||
|
||
} | ||
} | ||
|
||
enum NotLegalEnum { | ||
>NotLegalEnum : NotLegalEnum | ||
> : ^^^^^^^^^^^^ | ||
|
||
B = 1 | ||
>B : NotLegalEnum.B | ||
> : ^^^^^^^^^^^^^^ | ||
>1 : 1 | ||
> : ^ | ||
} | ||
|
||
const enum NotLegalConstEnum { | ||
>NotLegalConstEnum : NotLegalConstEnum | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
C = 2 | ||
>C : NotLegalConstEnum.C | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>2 : 2 | ||
> : ^ | ||
} | ||
|
||
// No errors after this point | ||
class MyClassOk { | ||
>MyClassOk : MyClassOk | ||
> : ^^^^^^^^^ | ||
|
||
// Not a parameter property, ok | ||
constructor(foo: string); | ||
>foo : string | ||
> : ^^^^^^ | ||
} | ||
namespace NotInstantiated { | ||
export interface JustAType { } | ||
export type ATypeInANamespace = {}; | ||
>ATypeInANamespace : ATypeInANamespace | ||
> : ^^^^^^^^^^^^^^^^^ | ||
} | ||
declare namespace AmbientIsNotInstantiated { | ||
>AmbientIsNotInstantiated : typeof AmbientIsNotInstantiated | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
export const stillOk = 12; | ||
>stillOk : 12 | ||
> : ^^ | ||
>12 : 12 | ||
> : ^^ | ||
} | ||
|
||
declare enum LegalEnum { | ||
>LegalEnum : LegalEnum | ||
> : ^^^^^^^^^ | ||
|
||
A = 1 | ||
>A : LegalEnum.A | ||
> : ^^^^^^^^^^^ | ||
>1 : 1 | ||
> : ^ | ||
} | ||
|
||
declare namespace AmbientStuff { | ||
>AmbientStuff : typeof AmbientStuff | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
|
||
namespace Nested { | ||
>Nested : typeof Nested | ||
> : ^^^^^^^^^^^^^ | ||
|
||
export const stillOk = 12; | ||
>stillOk : 12 | ||
> : ^^ | ||
>12 : 12 | ||
> : ^^ | ||
} | ||
enum EnumInAmbientContext { | ||
>EnumInAmbientContext : EnumInAmbientContext | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
B = 1 | ||
>B : EnumInAmbientContext.B | ||
> : ^^^^^^^^^^^^^^^^^^^^^^ | ||
>1 : 1 | ||
> : ^ | ||
} | ||
} | ||
|