-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
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
--erasableSyntaxOnly
#61011
Merged
RyanCavanaugh
merged 14 commits into
microsoft:main
from
RyanCavanaugh:erasableSyntaxOnly
Jan 23, 2025
+832
−3
Merged
--erasableSyntaxOnly
#61011
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
69f5ded
Implementation of erasableSyntaxOnly
RyanCavanaugh 8ee35e5
Test + baseline
RyanCavanaugh ac1bb33
Other baseline changes
RyanCavanaugh 6aee14c
Add noEmit to test
RyanCavanaugh 52a5578
Add declaration file version of this test
RyanCavanaugh 173c785
Also ban `import =`
RyanCavanaugh 213d91b
Update test
RyanCavanaugh c0cdb9a
Update other test
RyanCavanaugh 5042fc1
Update tests/cases/compiler/erasableSyntaxOnly.ts
RyanCavanaugh 7d031d9
Merge branch 'main' of https://github.com/microsoft/TypeScript into e…
RyanCavanaugh 313beee
Update tests/cases/compiler/erasableSyntaxOnly.ts
RyanCavanaugh af6ab8d
Merge branch 'erasableSyntaxOnly' of https://github.com/RyanCavanaugh…
RyanCavanaugh be992fa
Update tests
RyanCavanaugh 0d6a34e
tabs lol
RyanCavanaugh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
...rence/config/showConfig/Shows tsconfig for single option/erasableSyntaxOnly/tsconfig.json
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,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"erasableSyntaxOnly": true | ||
} | ||
} |
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,67 @@ | ||
erasableSyntaxOnly.ts(3,17): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
erasableSyntaxOnly.ts(6,11): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
erasableSyntaxOnly.ts(10,11): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
erasableSyntaxOnly.ts(16,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
erasableSyntaxOnly.ts(20,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
|
||
|
||
==== erasableSyntaxOnly.ts (5 errors) ==== | ||
class MyClassErr { | ||
// No parameter properties | ||
constructor(public foo: string) { } | ||
~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
} | ||
|
||
namespace IllegalBecauseInstantiated { | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
export const m = 1; | ||
} | ||
|
||
namespace AlsoIllegalBecauseInstantiated { | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
class PrivateClass { | ||
|
||
} | ||
} | ||
|
||
enum NotLegalEnum { | ||
~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
B = 1 | ||
} | ||
|
||
const enum NotLegalConstEnum { | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. | ||
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 | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
JSX?
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.
Open to suggestions 🤷
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.
I'd vote no since that would curse anyone trying to use this for "purist" purposes to not being able to use JSX at all; you're already going to get an error from Node, and in other runtimes or with a loader, it might even work just fine....
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.
Yeah, the fact that you already have to put JSX content in a
.?sx
file means you can't possibly make the mistake of "not realizing enum is special" or whatever.I thought Daniel wanted the text to say something different, which technically JSX is a non-ES runtime construct, but the phrasing would maybe get super awkward
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.
Ohh that interpretation makes a lot more sense, oops
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.
Well you could make the same argument about all of these features right?
Well we permit JSX in JS files 😄
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.
Overall I think it is fine either way, just a slightly weird distinction.