-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy patherasableSyntaxOnly.js
129 lines (109 loc) · 2.83 KB
/
erasableSyntaxOnly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//// [tests/cases/compiler/erasableSyntaxOnly.ts] ////
//// [index.ts]
class MyClassErr {
// No parameter properties
constructor(public foo: string) { }
}
namespace IllegalBecauseInstantiated {
export const m = 1;
}
namespace AlsoIllegalBecauseInstantiated {
class PrivateClass {
}
}
namespace IllegalBecauseNestedInstantiated {
namespace Nested {
export const m = 1;
}
}
enum NotLegalEnum {
B = 1
}
import NoGoodAlias = NotLegalEnum.B;
const enum NotLegalConstEnum {
C = 2
}
// No errors after this point
class MyClassOk {
// Not a parameter property, ok
constructor(foo: string) { }
}
// Note for implementors: This should not be an error
// as this entire namespace block is fully erased
namespace NotInstantiated {
export interface JustAType { }
export type ATypeInANamespace = {};
namespace Nested {
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
}
import FineAlias = EnumInAmbientContext.B;
}
//// [commonjs.cts]
import foo = require("./other.cjs");
export = foo;
//// [other.d.cts]
declare function foo(): void;
export = foo;
//// [esm.mts]
const foo = 1234;
export default foo;
//// [index.js]
var MyClassErr = /** @class */ (function () {
// No parameter properties
function MyClassErr(foo) {
this.foo = foo;
}
return MyClassErr;
}());
var IllegalBecauseInstantiated;
(function (IllegalBecauseInstantiated) {
IllegalBecauseInstantiated.m = 1;
})(IllegalBecauseInstantiated || (IllegalBecauseInstantiated = {}));
var AlsoIllegalBecauseInstantiated;
(function (AlsoIllegalBecauseInstantiated) {
var PrivateClass = /** @class */ (function () {
function PrivateClass() {
}
return PrivateClass;
}());
})(AlsoIllegalBecauseInstantiated || (AlsoIllegalBecauseInstantiated = {}));
var IllegalBecauseNestedInstantiated;
(function (IllegalBecauseNestedInstantiated) {
var Nested;
(function (Nested) {
Nested.m = 1;
})(Nested || (Nested = {}));
})(IllegalBecauseNestedInstantiated || (IllegalBecauseNestedInstantiated = {}));
var NotLegalEnum;
(function (NotLegalEnum) {
NotLegalEnum[NotLegalEnum["B"] = 1] = "B";
})(NotLegalEnum || (NotLegalEnum = {}));
var NoGoodAlias = NotLegalEnum.B;
// No errors after this point
var MyClassOk = /** @class */ (function () {
// Not a parameter property, ok
function MyClassOk(foo) {
}
return MyClassOk;
}());
//// [commonjs.cjs]
"use strict";
var foo = require("./other.cjs");
module.exports = foo;
//// [esm.mjs]
var foo = 1234;
export default foo;