| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| //// [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; | ||
|
|
||
|
|
||
| //// [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; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,120 +1,135 @@ | ||
| //// [tests/cases/compiler/erasableSyntaxOnly.ts] //// | ||
|
|
||
| === erasableSyntaxOnly.ts === | ||
| === index.ts === | ||
| class MyClassErr { | ||
| >MyClassErr : Symbol(MyClassErr, Decl(erasableSyntaxOnly.ts, 0, 0)) | ||
| >MyClassErr : Symbol(MyClassErr, Decl(index.ts, 0, 0)) | ||
|
|
||
| // No parameter properties | ||
| constructor(public foo: string) { } | ||
| >foo : Symbol(MyClassErr.foo, Decl(erasableSyntaxOnly.ts, 2, 16)) | ||
| >foo : Symbol(MyClassErr.foo, Decl(index.ts, 2, 16)) | ||
| } | ||
|
|
||
| namespace IllegalBecauseInstantiated { | ||
| >IllegalBecauseInstantiated : Symbol(IllegalBecauseInstantiated, Decl(erasableSyntaxOnly.ts, 3, 1)) | ||
| >IllegalBecauseInstantiated : Symbol(IllegalBecauseInstantiated, Decl(index.ts, 3, 1)) | ||
|
|
||
| export const m = 1; | ||
| >m : Symbol(m, Decl(erasableSyntaxOnly.ts, 6, 16)) | ||
| >m : Symbol(m, Decl(index.ts, 6, 16)) | ||
| } | ||
|
|
||
| namespace AlsoIllegalBecauseInstantiated { | ||
| >AlsoIllegalBecauseInstantiated : Symbol(AlsoIllegalBecauseInstantiated, Decl(erasableSyntaxOnly.ts, 7, 1)) | ||
| >AlsoIllegalBecauseInstantiated : Symbol(AlsoIllegalBecauseInstantiated, Decl(index.ts, 7, 1)) | ||
|
|
||
| class PrivateClass { | ||
| >PrivateClass : Symbol(PrivateClass, Decl(erasableSyntaxOnly.ts, 9, 42)) | ||
| >PrivateClass : Symbol(PrivateClass, Decl(index.ts, 9, 42)) | ||
|
|
||
| } | ||
| } | ||
|
|
||
| namespace IllegalBecauseNestedInstantiated { | ||
| >IllegalBecauseNestedInstantiated : Symbol(IllegalBecauseNestedInstantiated, Decl(erasableSyntaxOnly.ts, 13, 1)) | ||
| >IllegalBecauseNestedInstantiated : Symbol(IllegalBecauseNestedInstantiated, Decl(index.ts, 13, 1)) | ||
|
|
||
| namespace Nested { | ||
| >Nested : Symbol(Nested, Decl(erasableSyntaxOnly.ts, 15, 44)) | ||
| >Nested : Symbol(Nested, Decl(index.ts, 15, 44)) | ||
|
|
||
| export const m = 1; | ||
| >m : Symbol(m, Decl(erasableSyntaxOnly.ts, 17, 20)) | ||
| >m : Symbol(m, Decl(index.ts, 17, 20)) | ||
| } | ||
| } | ||
|
|
||
| enum NotLegalEnum { | ||
| >NotLegalEnum : Symbol(NotLegalEnum, Decl(erasableSyntaxOnly.ts, 19, 1)) | ||
| >NotLegalEnum : Symbol(NotLegalEnum, Decl(index.ts, 19, 1)) | ||
|
|
||
| B = 1 | ||
| >B : Symbol(NoGoodAlias, Decl(erasableSyntaxOnly.ts, 21, 19)) | ||
| >B : Symbol(NoGoodAlias, Decl(index.ts, 21, 19)) | ||
| } | ||
|
|
||
| import NoGoodAlias = NotLegalEnum.B; | ||
| >NoGoodAlias : Symbol(NoGoodAlias, Decl(erasableSyntaxOnly.ts, 23, 1)) | ||
| >NotLegalEnum : Symbol(NotLegalEnum, Decl(erasableSyntaxOnly.ts, 19, 1)) | ||
| >B : Symbol(NoGoodAlias, Decl(erasableSyntaxOnly.ts, 21, 19)) | ||
| >NoGoodAlias : Symbol(NoGoodAlias, Decl(index.ts, 23, 1)) | ||
| >NotLegalEnum : Symbol(NotLegalEnum, Decl(index.ts, 19, 1)) | ||
| >B : Symbol(NoGoodAlias, Decl(index.ts, 21, 19)) | ||
|
|
||
| const enum NotLegalConstEnum { | ||
| >NotLegalConstEnum : Symbol(NotLegalConstEnum, Decl(erasableSyntaxOnly.ts, 25, 36)) | ||
| >NotLegalConstEnum : Symbol(NotLegalConstEnum, Decl(index.ts, 25, 36)) | ||
|
|
||
| C = 2 | ||
| >C : Symbol(NotLegalConstEnum.C, Decl(erasableSyntaxOnly.ts, 27, 30)) | ||
| >C : Symbol(NotLegalConstEnum.C, Decl(index.ts, 27, 30)) | ||
| } | ||
|
|
||
| // No errors after this point | ||
| class MyClassOk { | ||
| >MyClassOk : Symbol(MyClassOk, Decl(erasableSyntaxOnly.ts, 29, 1)) | ||
| >MyClassOk : Symbol(MyClassOk, Decl(index.ts, 29, 1)) | ||
|
|
||
| // Not a parameter property, ok | ||
| constructor(foo: string) { } | ||
| >foo : Symbol(foo, Decl(erasableSyntaxOnly.ts, 34, 16)) | ||
| >foo : Symbol(foo, Decl(index.ts, 34, 16)) | ||
| } | ||
|
|
||
| // Note for implementors: This should not be an error | ||
| // as this entire namespace block is fully erased | ||
| namespace NotInstantiated { | ||
| >NotInstantiated : Symbol(NotInstantiated, Decl(erasableSyntaxOnly.ts, 35, 1)) | ||
| >NotInstantiated : Symbol(NotInstantiated, Decl(index.ts, 35, 1)) | ||
|
|
||
| export interface JustAType { } | ||
| >JustAType : Symbol(JustAType, Decl(erasableSyntaxOnly.ts, 39, 27)) | ||
| >JustAType : Symbol(JustAType, Decl(index.ts, 39, 27)) | ||
|
|
||
| export type ATypeInANamespace = {}; | ||
| >ATypeInANamespace : Symbol(ATypeInANamespace, Decl(erasableSyntaxOnly.ts, 40, 34)) | ||
| >ATypeInANamespace : Symbol(ATypeInANamespace, Decl(index.ts, 40, 34)) | ||
|
|
||
| namespace Nested { | ||
| >Nested : Symbol(Nested, Decl(erasableSyntaxOnly.ts, 41, 39)) | ||
| >Nested : Symbol(Nested, Decl(index.ts, 41, 39)) | ||
|
|
||
| export type ATypeInANamespace = {}; | ||
| >ATypeInANamespace : Symbol(ATypeInANamespace, Decl(erasableSyntaxOnly.ts, 42, 22)) | ||
| >ATypeInANamespace : Symbol(ATypeInANamespace, Decl(index.ts, 42, 22)) | ||
| } | ||
| } | ||
| declare namespace AmbientIsNotInstantiated { | ||
| >AmbientIsNotInstantiated : Symbol(AmbientIsNotInstantiated, Decl(erasableSyntaxOnly.ts, 45, 1)) | ||
| >AmbientIsNotInstantiated : Symbol(AmbientIsNotInstantiated, Decl(index.ts, 45, 1)) | ||
|
|
||
| export const stillOk = 12; | ||
| >stillOk : Symbol(stillOk, Decl(erasableSyntaxOnly.ts, 47, 16)) | ||
| >stillOk : Symbol(stillOk, Decl(index.ts, 47, 16)) | ||
| } | ||
|
|
||
| declare enum LegalEnum { | ||
| >LegalEnum : Symbol(LegalEnum, Decl(erasableSyntaxOnly.ts, 48, 1)) | ||
| >LegalEnum : Symbol(LegalEnum, Decl(index.ts, 48, 1)) | ||
|
|
||
| A = 1 | ||
| >A : Symbol(LegalEnum.A, Decl(erasableSyntaxOnly.ts, 50, 24)) | ||
| >A : Symbol(LegalEnum.A, Decl(index.ts, 50, 24)) | ||
| } | ||
|
|
||
| declare namespace AmbientStuff { | ||
| >AmbientStuff : Symbol(AmbientStuff, Decl(erasableSyntaxOnly.ts, 52, 1)) | ||
| >AmbientStuff : Symbol(AmbientStuff, Decl(index.ts, 52, 1)) | ||
|
|
||
| namespace Nested { | ||
| >Nested : Symbol(Nested, Decl(erasableSyntaxOnly.ts, 54, 32)) | ||
| >Nested : Symbol(Nested, Decl(index.ts, 54, 32)) | ||
|
|
||
| export const stillOk = 12; | ||
| >stillOk : Symbol(stillOk, Decl(erasableSyntaxOnly.ts, 56, 20)) | ||
| >stillOk : Symbol(stillOk, Decl(index.ts, 56, 20)) | ||
| } | ||
| enum EnumInAmbientContext { | ||
| >EnumInAmbientContext : Symbol(EnumInAmbientContext, Decl(erasableSyntaxOnly.ts, 57, 5)) | ||
| >EnumInAmbientContext : Symbol(EnumInAmbientContext, Decl(index.ts, 57, 5)) | ||
|
|
||
| B = 1 | ||
| >B : Symbol(FineAlias, Decl(erasableSyntaxOnly.ts, 58, 31)) | ||
| >B : Symbol(FineAlias, Decl(index.ts, 58, 31)) | ||
| } | ||
|
|
||
| import FineAlias = EnumInAmbientContext.B; | ||
| >FineAlias : Symbol(FineAlias, Decl(erasableSyntaxOnly.ts, 60, 5)) | ||
| >EnumInAmbientContext : Symbol(EnumInAmbientContext, Decl(erasableSyntaxOnly.ts, 57, 5)) | ||
| >B : Symbol(FineAlias, Decl(erasableSyntaxOnly.ts, 58, 31)) | ||
| >FineAlias : Symbol(FineAlias, Decl(index.ts, 60, 5)) | ||
| >EnumInAmbientContext : Symbol(EnumInAmbientContext, Decl(index.ts, 57, 5)) | ||
| >B : Symbol(FineAlias, Decl(index.ts, 58, 31)) | ||
| } | ||
|
|
||
| === commonjs.cts === | ||
| import foo = require("./other.cjs"); | ||
| >foo : Symbol(foo, Decl(commonjs.cts, 0, 0)) | ||
|
|
||
| export = foo; | ||
| >foo : Symbol(foo, Decl(commonjs.cts, 0, 0)) | ||
|
|
||
|
|
||
| === other.d.cts === | ||
| declare function foo(): void; | ||
| >foo : Symbol(foo, Decl(other.d.cts, 0, 0)) | ||
|
|
||
| export = foo; | ||
| >foo : Symbol(foo, Decl(other.d.cts, 0, 0)) | ||
|
|
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOh no, this means that CJS isn't even erasable because we assume strict and always insert it
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.