Disallow 'readonly' modifier in ambient module import attributes types - #64181
Open
erantianantha wants to merge 2 commits into
Open
Disallow 'readonly' modifier in ambient module import attributes types#64181erantianantha wants to merge 2 commits into
erantianantha wants to merge 2 commits into
Conversation
microsoft#64143) Ambient module import attributes types should not accept the 'readonly' modifier. Adds diagnostic TS1558 ("An import attributes property cannot have a 'readonly' modifier.") and checks for modifiers in checkGrammarImportAttributesType. Fixes microsoft#64143.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The modifier check incorrectly reports non-readonly modifiers as readonly.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds validation rejecting readonly properties in ambient-module import attribute types.
Changes:
- Adds TS1558 and grammar validation.
- Adds compiler regression coverage and baseline.
File summaries
| File | Description |
|---|---|
grammarchecks.go |
Validates attribute property modifiers. |
diagnosticMessages.json |
Defines TS1558. |
diagnostics_generated.go |
Registers generated diagnostic. |
importAttributeTypeReadonly.ts |
Adds regression cases. |
importAttributeTypeReadonly.errors.txt |
Records expected diagnostics. |
Review details
Files not reviewed (1)
- tsc/internal/diagnostics/diagnostics_generated.go: Generated file
- Files reviewed: 4/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+2210
to
+2212
| if propertySignature.Modifiers() != nil { | ||
| return c.grammarErrorOnNode(propertySignature.Modifiers().Nodes[0], diagnostics.An_import_attributes_property_cannot_have_a_readonly_modifier) | ||
| } |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #64143
Description
Support for import attributes on ambient module declarations (
declare module "*.css" with { type: "css" }) was added in #63931. However,readonlymodifier on attribute properties was previously accepted without error becausecheckGrammarModifiersskipsreadonlyfor property signatures (as it is normally valid on type literal properties).This PR:
readonly) on property signatures incheckGrammarImportAttributesType.readonlyattributes and valid non-readonlyattributes.