feat(parser): add syntax errors for constructor declarations#18220
feat(parser): add syntax errors for constructor declarations#18220graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds two TypeScript syntax error checks for invalid constructor declarations: TS1031 for the declare modifier on constructors and TS1093 for return type annotations on constructors.
Changes:
- Added validation to reject
declaremodifier on constructor declarations (TS1031) - Added validation to reject return type annotations on constructor declarations (TS1093)
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tasks/coverage/snapshots/parser_typescript.snap | Updated test results showing 2 additional negative tests now passing (parserConstructorDeclaration4.ts and parserConstructorDeclaration10.ts) |
| crates/oxc_parser/src/js/class.rs | Added error check for declare modifier in parse_constructor_declaration and error check for return type in check_method_definition_constructor |
| crates/oxc_parser/src/diagnostics.rs | Added two new diagnostic functions: declare_constructor (TS1031) and constructor_return_type (TS1093) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
e549dbe to
b5c25f5
Compare
Merge activity
|
## Summary
- Add TS1031 error for `declare` modifier on constructor: `declare constructor() {}`
- Add TS1093 error for return type annotation on constructor: `constructor(): number {}`
## Test plan
- Parser conformance tests updated
- Negative Passed: 1498 → 1500 (+2 tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
8442de9 to
8a1cbbd
Compare
Summary
declaremodifier on constructor:declare constructor() {}constructor(): number {}Test plan
🤖 Generated with Claude Code