-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
New --enforceReadonly
compiler option to enforce read-only semantics in type relations
#58296
Open
ahejlsberg
wants to merge
26
commits into
main
Choose a base branch
from
enforceReadonly
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,717
−341
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f8fa8b2
Implement --strictReadonly compiler option
ahejlsberg 453d778
Fix inconsistent 'readonly' modifiers in lib files
ahejlsberg 0b5728a
Accept new baselines
ahejlsberg 170bb5f
Change option name to --enforceReadonly
ahejlsberg 97adafc
Accept new API baselines
ahejlsberg 800c901
More baseline changes
ahejlsberg 8c1ac64
Add tests
ahejlsberg 88c2579
Merge branch 'main' into enforceReadonly
ahejlsberg d7c8851
Remove unused file
ahejlsberg dd6c3a8
Enforce read-only semantics in generic mapped types
ahejlsberg 638e55c
Add more tests
ahejlsberg 6fafe58
Compile APILibCheck.ts with --enforceReadonly
ahejlsberg 4d16813
Accept new API baselines
ahejlsberg f9a132b
Fix formatting
ahejlsberg d616ca0
Fix comment
ahejlsberg 474a34b
Exclude methods from strict checking
ahejlsberg 3ee4e91
Add more tests
ahejlsberg 5afbd2c
Remove test
ahejlsberg dbd7d0b
Accept new baselines
ahejlsberg f3bdc07
Merge branch 'main' into enforceReadonly
ahejlsberg 90ce450
Exclude comparable relation from strict readonly checking
ahejlsberg c8a66e0
Add more tests
ahejlsberg 43cc32f
Align String.raw template parameter with TemplateStringsArray
ahejlsberg 4a668c3
Accept new baselines
ahejlsberg 7494b23
Revert unnecessary change
ahejlsberg adee2e1
Accept new baselines
ahejlsberg 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ interface Map<K, V> { | |
interface MapConstructor { | ||
new (): Map<any, any>; | ||
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>; | ||
readonly prototype: Map<any, any>; | ||
prototype: Map<any, any>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
declare var Map: MapConstructor; | ||
|
||
|
@@ -64,7 +64,7 @@ interface WeakMap<K extends WeakKey, V> { | |
|
||
interface WeakMapConstructor { | ||
new <K extends WeakKey = WeakKey, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>; | ||
readonly prototype: WeakMap<WeakKey, any>; | ||
prototype: WeakMap<WeakKey, any>; | ||
} | ||
declare var WeakMap: WeakMapConstructor; | ||
|
||
|
@@ -96,7 +96,7 @@ interface Set<T> { | |
|
||
interface SetConstructor { | ||
new <T = any>(values?: readonly T[] | null): Set<T>; | ||
readonly prototype: Set<any>; | ||
prototype: Set<any>; | ||
} | ||
declare var Set: SetConstructor; | ||
|
||
|
@@ -124,6 +124,6 @@ interface WeakSet<T extends WeakKey> { | |
|
||
interface WeakSetConstructor { | ||
new <T extends WeakKey = WeakKey>(values?: readonly T[] | null): WeakSet<T>; | ||
readonly prototype: WeakSet<WeakKey>; | ||
prototype: WeakSet<WeakKey>; | ||
} | ||
declare var WeakSet: WeakSetConstructor; |
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
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.
I'm not sure we can take this until the generator is updated to do this, right?
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.
Right, this ultimately needs to be done in the DOM generator. However, without this workaround it's pretty much impossible to compile anything because
lib.dom.d.ts
fails to check properly with--enforceReadonly
: