Skip to content

Restore JSDoc namespace declarations#4073

Open
ahejlsberg wants to merge 10 commits into
mainfrom
fix-3842
Open

Restore JSDoc namespace declarations#4073
ahejlsberg wants to merge 10 commits into
mainfrom
fix-3842

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR completes work that was started by @jakebailey. Specifically, it simplifies a few functions and adds proper remapping of reparsed nodes such that Quick Info, Find-all-refs, Rename, etc. on namespaced JSDoc names work in the language service.

Fixes #3842.

Copilot AI review requested due to automatic review settings May 28, 2026 23:18
Copy link
Copy Markdown
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

Completes restoration of JSDoc dotted-name (NS.T) @typedef and @callback support. The parser now produces a JSDocFullName (Identifier | nested ModuleDeclaration) for the names of @typedef/@callback, and the reparser wraps the resulting type alias in a chain of (exported) namespace declarations so that names like NS.MyCallback resolve and participate in declaration emit, find-all-refs, rename, etc.

Changes:

  • New parseJSDocTypeNameWithNamespace produces a nested ModuleDeclaration chain for dotted @typedef/@callback names; JSDocCallbackTag.FullName is renamed to name and typed as JSDocFullName.
  • Reparser wraps reparsed type aliases in synthetic namespace ModuleDeclarations (wrapInJSDocNamespace), with inner namespaces explicitly exported and the outer one relying on IsImplicitlyExportedJSDocDeclaration (renamed from IsImplicitlyExportedJSTypeAlias) for module visibility.
  • EmitResolver.determineIfDeclarationIsVisible now handles KindExportSpecifier (re-export without module specifier) as visible; someSymbolTableInScope looks up reparsed nodes; declareSourceFileMember narrows from IsExternalOrCommonJSModule to IsExternalModule; CHANGES.md drops the JSDoc-namespace limitation; many submodule baselines updated.

Reviewed changes

Copilot reviewed 55 out of 58 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/parser/jsdoc.go Parse JSDoc dotted name into nested ModuleDeclaration.
internal/parser/reparser.go Wrap reparsed type alias in namespace chain; export-modifier helper.
internal/ast/utilities.go Rename helper to IsImplicitlyExportedJSDocDeclaration, include reparsed ModuleDeclaration.
internal/ast/nodeflags.go Add NodeFlagsIdentifierIsInJSDocNamespace, NodeFlagsNestedNamespace.
internal/ast/ast.go TypeExpression() now handles JSDocCallbackTag.
internal/ast/ast_generated.go JSDocCallbackTag.FullName → private name *JSDocFullName; JSDocTypedefTag.name retyped.
internal/binder/binder.go Use renamed helper; declareSourceFileMember uses IsExternalModule.
internal/checker/symbolaccessibility.go Resolve via GetReparsedNodeForNode in scope traversal.
internal/checker/emitresolver.go Treat ExportSpecifier re-exports as visible; use new helper.
internal/transformers/declarations/transform.go Use renamed helper for export modifier.
internal/ls/importTracker.go Use renamed helper.
internal/api/encoder/* Regenerated for renamed field.
_packages/native-preview/src/... Regenerated TS bindings for JSDocFullName/renamed field.
_scripts/ast.json AST schema updates.
CHANGES.md Remove JSDoc-namespace limitation note.
testdata/tests/cases/compiler/jsDocTypedefTagNamespace.ts New compiler test.
testdata/baselines/reference/... Updated baselines / removed obsolete diffs.
testdata/submoduleAccepted.txt Drop now-converged callbackTagNamespace.types.diff.
Files not reviewed (3)
  • internal/api/encoder/decoder_generated.go: Language not supported
  • internal/api/encoder/encoder_generated.go: Language not supported
  • internal/ast/ast_generated.go: Language not supported

Comment thread internal/parser/reparser.go Outdated
if fullName == nil || !ast.IsModuleDeclaration(fullName) {
return statement
}
// Recursively wrap from outermost to innerpost. Inner namespaces always get an export modifier
Comment thread internal/parser/reparser.go Outdated
}
// Recursively wrap from outermost to innerpost. Inner namespaces always get an export modifier
// so members are accessible via dotted access from outside. The outermost namespace is treated as
// exported only in module files via IsImplicitlyExportedJSTypeAlias (in the binder), so it does
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing support for namespaces in JSDoc types

3 participants