Conversation
Instead of issuing an error for `module X {}`, the parser now always
treats it as `namespace X {}`. Only `declare module "foo"` and
`namespace` syntax are distinguished.
Changes:
- Parser: Always use KindNamespaceKeyword for identifier-named module declarations
- Checker: Remove suggestion diagnostic for module keyword usage
- Checker: Remove unused getNonModifierTokenRangeOfNode utility
- Printer tests: Update expected output for module->namespace conversion
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
|
@copilot the intent is that module is illegal and produces a parse error |
- Parser emits parse error on each identifier name when `module`
keyword is used for namespace declarations (matching TS behavior)
- Dotted names like `module A.B {}` get errors on both `A` and `B`
- AST still uses KindNamespaceKeyword for error recovery
- Baselines now match TypeScript exactly (diff files deleted)
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Updated in e50c1d7. The parser now emits a parse error (TS1540) on each identifier name when |
|
I guess this is fine, though I think I was hoping to hard remove it and not even have this diagnostic, as though |
There was a problem hiding this comment.
Pull request overview
Removes support for module-keyword namespace declarations by turning them into parser errors, aligning behavior and baselines with upstream TypeScript.
Changes:
- Parser now errors on
module X {}(and per-component on dotted names) and usesKindNamespaceKeywordfor recovery. - Checker cleanup: removes now-unreachable suggestion diagnostics and a related utility.
- Updates/removes printer tests and baseline diff artifacts to match TypeScript outputs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/parser/parser.go | Emits parse errors for module-keyword namespace declarations; normalizes AST keyword to namespace for recovery. |
| internal/checker/checker.go | Removes unreachable suggestion diagnostic for module-keyword namespace declarations. |
| internal/checker/utilities.go | Removes unused helper previously used for the suggestion diagnostic span. |
| internal/printer/printer_test.go | Drops printer cases that now fail to parse (module a{}, module a.b{}). |
| testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt.diff | Deletes baseline diff artifact. |
| testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt | Adds/updates baseline error output in the non-diff format. |
| testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt.diff | Deletes baseline diff artifact. |
| testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt | Updates baseline to include the newly parser-emitted TS1540 error. |
It's better to just gracefully parse it for as long as we can and issue a parse error. |
modulekeyword is used for namespace declarationsmodule A.B {}→ errors onAandB)KindNamespaceKeywordfor error recoverygetNonModifierTokenRangeOfNodeutilitymodule a{}andmodule a.b{}tests (now produce parse errors)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.