Skip to content

feat(parser): add syntax errors for constructor declarations#18220

Merged
graphite-app[bot] merged 1 commit intomainfrom
feat/parser-constructor-errors
Jan 19, 2026
Merged

feat(parser): add syntax errors for constructor declarations#18220
graphite-app[bot] merged 1 commit intomainfrom
feat/parser-constructor-errors

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 19, 2026

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

Copilot AI review requested due to automatic review settings January 19, 2026 07:48
@github-actions github-actions bot added A-parser Area - Parser C-enhancement Category - New feature or request labels Jan 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 declare modifier 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-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing feat/parser-constructor-errors (8442de9) with main (a95b9bb)1

Summary

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks2

Footnotes

  1. No successful run was found on main (312da18) during the generation of this report, so a95b9bb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen force-pushed the feat/parser-constructor-errors branch 2 times, most recently from e549dbe to b5c25f5 Compare January 19, 2026 08:19
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
Copy link
Member Author

Boshen commented Jan 19, 2026

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)
@graphite-app graphite-app bot force-pushed the feat/parser-constructor-errors branch from 8442de9 to 8a1cbbd Compare January 19, 2026 08:40
@graphite-app graphite-app bot merged commit 8a1cbbd into main Jan 19, 2026
22 checks passed
@graphite-app graphite-app bot deleted the feat/parser-constructor-errors branch January 19, 2026 08:46
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants