Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ However, if you see **_incorrect_** `.d.ts` output from a `.js` file, **please f
| Identifier-named typedefs |<pre><code>`/** @typedef {T} */ typeName;</pre></code> | <pre><code>/** @typedef {T} typeName */</pre></code> | Closure feature. |
| Closure function type syntax | <pre><code>/* @type {function(string): void} */</pre></code> | <pre><code>/* @type {(s: string) => void} */</pre></code> | |
| Automatic typeof insertion | <pre><code>const o = { a: 1 };</code><br/><code>/\** @type {o} */</code><br/><code>var o2 = { a: 1 };</code></pre> | <pre><code>const o = { a: 1 };</code><br/><code>/\** @type {typeof o} */</code><br/><code>var o2 = { a: 1 };</code></pre> | |
| `@typedef` nested names | <pre><code>/** @typedef {1} NS.T */</pre></code> | Translate to .d.ts file. | Also applies to `@callback`. |

## Expando declarations

Expand Down
3 changes: 0 additions & 3 deletions _packages/native-preview/src/api/node/node.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,6 @@ export class RemoteNode extends RemoteNodeBase implements Node {
get finallyBlock(): RemoteNode | undefined {
return this.getNamedChild("finallyBlock") as RemoteNode;
}
get fullName(): RemoteNode | undefined {
return this.getNamedChild("fullName") as RemoteNode;
}
get head(): RemoteNode | undefined {
return this.getNamedChild("head") as RemoteNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const childProperties: Readonly<Partial<Record<SyntaxKind, readonly (stri
[SyntaxKind.JSDocThrowsTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocThisTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocImportTag]: ["tagName", "importClause", "moduleSpecifier", "attributes", "comment"],
[SyntaxKind.JSDocCallbackTag]: ["tagName", "typeExpression", "fullName", "comment"],
[SyntaxKind.JSDocCallbackTag]: ["tagName", "typeExpression", "name", "comment"],
[SyntaxKind.JSDocOverloadTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocTypedefTag]: ["tagName", "typeExpression", "name", "comment"],
[SyntaxKind.JSDocSignature]: ["typeParameters", "parameters", "type"],
Expand Down
5 changes: 3 additions & 2 deletions _packages/native-preview/src/ast/ast.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ export interface JSDocImportTag extends JSDocTagBase {
export interface JSDocCallbackTag extends JSDocTagBase {
readonly kind: SyntaxKind.JSDocCallbackTag;
readonly typeExpression: TypeNode;
readonly fullName?: Node;
readonly name?: JSDocFullName;
}
export interface JSDocOverloadTag extends JSDocTagBase {
readonly kind: SyntaxKind.JSDocOverloadTag;
Expand All @@ -1251,7 +1251,7 @@ export interface JSDocOverloadTag extends JSDocTagBase {
export interface JSDocTypedefTag extends JSDocTagBase {
readonly kind: SyntaxKind.JSDocTypedefTag;
readonly typeExpression?: Node;
readonly name?: Identifier;
readonly name?: JSDocFullName;
}
export interface JSDocSignature extends JSDocTypeBase, FunctionLikeBase {
readonly kind: SyntaxKind.JSDocSignature;
Expand Down Expand Up @@ -1342,6 +1342,7 @@ export type ModuleName = Identifier | StringLiteral;
export type ModuleExportName = Identifier | StringLiteral;
export type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral;
export type ModuleBody = ModuleBlock | ModuleDeclaration;
export type JSDocFullName = Identifier | ModuleDeclaration;
export type ForInitializer = Expression | MissingDeclaration | VariableDeclarationList;
export type ModuleReference = Identifier | QualifiedName | ExternalModuleReference;
export type NamedImportBindings = NamespaceImport | NamedImports;
Expand Down
20 changes: 9 additions & 11 deletions _packages/native-preview/src/ast/factory.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import type {
JSDocCallbackTag,
JSDocComment,
JSDocDeprecatedTag,
JSDocFullName,
JSDocImplementsTag,
JSDocImportTag,
JSDocLink,
Expand Down Expand Up @@ -400,9 +401,6 @@ export class NodeObject {
get finallyBlock(): any {
return this._data?.finallyBlock;
}
get fullName(): any {
return this._data?.fullName;
}
get head(): any {
return this._data?.head;
}
Expand Down Expand Up @@ -1010,7 +1008,7 @@ function cloneNodeData(node: Node): any {
case SyntaxKind.JSDocImportTag:
return { tagName: n.tagName, importClause: n.importClause, moduleSpecifier: n.moduleSpecifier, attributes: n.attributes, comment: n.comment };
case SyntaxKind.JSDocCallbackTag:
return { tagName: n.tagName, typeExpression: n.typeExpression, fullName: n.fullName, comment: n.comment };
return { tagName: n.tagName, typeExpression: n.typeExpression, name: n.name, comment: n.comment };
case SyntaxKind.JSDocOverloadTag:
return { tagName: n.tagName, typeExpression: n.typeExpression, comment: n.comment };
case SyntaxKind.JSDocTypedefTag:
Expand Down Expand Up @@ -1531,7 +1529,7 @@ const forEachChildTable: Record<number, ForEachChildFunction> = {
[SyntaxKind.JSDocCallbackTag]: (data, cbNode, cbNodes) =>
visitNode(cbNode, data.tagName) ||
visitNode(cbNode, data.typeExpression) ||
visitNode(cbNode, data.fullName) ||
visitNode(cbNode, data.name) ||
visitNodes(cbNode, cbNodes, data.comment),
[SyntaxKind.JSDocOverloadTag]: (data, cbNode, cbNodes) =>
visitNode(cbNode, data.tagName) ||
Expand Down Expand Up @@ -2860,11 +2858,11 @@ export function createJSDocImportTag(tagName: Identifier, importClause: ImportCl
}) as unknown as JSDocImportTag;
}

export function createJSDocCallbackTag(tagName: Identifier, typeExpression: TypeNode, fullName?: Node, comment?: readonly JSDocComment[]): JSDocCallbackTag {
export function createJSDocCallbackTag(tagName: Identifier, typeExpression: TypeNode, name?: JSDocFullName, comment?: readonly JSDocComment[]): JSDocCallbackTag {
return new NodeObject(SyntaxKind.JSDocCallbackTag, {
tagName,
typeExpression,
fullName,
name,
comment: comment ? createNodeArray(comment) : undefined,
}) as unknown as JSDocCallbackTag;
}
Expand All @@ -2877,7 +2875,7 @@ export function createJSDocOverloadTag(tagName: Identifier, typeExpression: Type
}) as unknown as JSDocOverloadTag;
}

export function createJSDocTypedefTag(tagName: Identifier, typeExpression?: Node, name?: Identifier, comment?: readonly JSDocComment[]): JSDocTypedefTag {
export function createJSDocTypedefTag(tagName: Identifier, typeExpression?: Node, name?: JSDocFullName, comment?: readonly JSDocComment[]): JSDocTypedefTag {
return new NodeObject(SyntaxKind.JSDocTypedefTag, {
tagName,
typeExpression,
Expand Down Expand Up @@ -3651,15 +3649,15 @@ export function updateJSDocImportTag(node: JSDocImportTag, tagName: Identifier,
return node.tagName !== tagName || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier || node.attributes !== attributes || node.comment !== comment ? createJSDocImportTag(tagName, importClause, moduleSpecifier, attributes, comment) : node;
}

export function updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier, typeExpression: TypeNode, fullName?: Node, comment?: readonly JSDocComment[]): JSDocCallbackTag {
return node.tagName !== tagName || node.typeExpression !== typeExpression || node.fullName !== fullName || node.comment !== comment ? createJSDocCallbackTag(tagName, typeExpression, fullName, comment) : node;
export function updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier, typeExpression: TypeNode, name?: JSDocFullName, comment?: readonly JSDocComment[]): JSDocCallbackTag {
return node.tagName !== tagName || node.typeExpression !== typeExpression || node.name !== name || node.comment !== comment ? createJSDocCallbackTag(tagName, typeExpression, name, comment) : node;
}

export function updateJSDocOverloadTag(node: JSDocOverloadTag, tagName: Identifier, typeExpression: TypeNode, comment?: readonly JSDocComment[]): JSDocOverloadTag {
return node.tagName !== tagName || node.typeExpression !== typeExpression || node.comment !== comment ? createJSDocOverloadTag(tagName, typeExpression, comment) : node;
}

export function updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier, typeExpression?: Node, name?: Identifier, comment?: readonly JSDocComment[]): JSDocTypedefTag {
export function updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier, typeExpression?: Node, name?: JSDocFullName, comment?: readonly JSDocComment[]): JSDocTypedefTag {
return node.tagName !== tagName || node.typeExpression !== typeExpression || node.name !== name || node.comment !== comment ? createJSDocTypedefTag(tagName, typeExpression, name, comment) : node;
}

Expand Down
5 changes: 5 additions & 0 deletions _packages/native-preview/src/ast/is.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import type {
JSDocCallbackTag,
JSDocComment,
JSDocDeprecatedTag,
JSDocFullName,
JSDocImplementsTag,
JSDocImportTag,
JSDocLink,
Expand Down Expand Up @@ -1143,6 +1144,10 @@ export function isModuleBody(node: Node): node is ModuleBody {
return node.kind === SyntaxKind.ModuleBlock || node.kind === SyntaxKind.ModuleDeclaration;
}

export function isJSDocFullName(node: Node): node is JSDocFullName {
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ModuleDeclaration;
}

export function isModuleReference(node: Node): node is ModuleReference {
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.ExternalModuleReference;
}
Expand Down
7 changes: 4 additions & 3 deletions _packages/native-preview/src/ast/visitor.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ import {
isImportAttributeName,
isImportAttributes,
isImportClause,
isJSDocFullName,
isJsxAttributeName,
isJsxAttributes,
isJsxAttributeValue,
Expand Down Expand Up @@ -1306,9 +1307,9 @@ const visitEachChildTable: Record<number, VisitEachChildFunction> = {
[SyntaxKind.JSDocCallbackTag]: (node: JSDocCallbackTag, visitor: Visitor): JSDocCallbackTag => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _fullName = visitNode(node.fullName, visitor);
const _name = visitNode(node.name, visitor, isJSDocFullName);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocCallbackTag(node, _tagName, _typeExpression, _fullName, _comment);
return updateJSDocCallbackTag(node, _tagName, _typeExpression, _name, _comment);
},
[SyntaxKind.JSDocOverloadTag]: (node: JSDocOverloadTag, visitor: Visitor): JSDocOverloadTag => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
Expand All @@ -1319,7 +1320,7 @@ const visitEachChildTable: Record<number, VisitEachChildFunction> = {
[SyntaxKind.JSDocTypedefTag]: (node: JSDocTypedefTag, visitor: Visitor): JSDocTypedefTag => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _name = visitNode(node.name, visitor, isJSDocFullName);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocTypedefTag(node, _tagName, _typeExpression, _name, _comment);
},
Expand Down
2 changes: 2 additions & 0 deletions _packages/native-preview/src/enums/nodeFlags.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ export enum NodeFlags {
TypeExcludesFlags = YieldContext | AwaitContext,
PermanentlySetIncrementalFlags = PossiblyContainsDynamicImport | PossiblyContainsImportMeta,
IdentifierHasExtendedUnicodeEscape = ContainsThis,
IdentifierIsInJSDocNamespace = HasAsyncFunctions,
NestedNamespace = OptionalChain,
}
2 changes: 2 additions & 0 deletions _packages/native-preview/src/enums/nodeFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ export var NodeFlags: any;
NodeFlags[NodeFlags["TypeExcludesFlags"] = 10240] = "TypeExcludesFlags";
NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags";
NodeFlags[NodeFlags["IdentifierHasExtendedUnicodeEscape"] = 128] = "IdentifierHasExtendedUnicodeEscape";
NodeFlags[NodeFlags["IdentifierIsInJSDocNamespace"] = 262144] = "IdentifierIsInJSDocNamespace";
NodeFlags[NodeFlags["NestedNamespace"] = 32] = "NestedNamespace";
})(NodeFlags || (NodeFlags = {}));
11 changes: 8 additions & 3 deletions _scripts/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -4664,8 +4664,9 @@
"type": "TypeNode"
},
{
"name": "FullName",
"type": "Node",
"name": "name",
"type": "JSDocFullName",
"private": true,
"optional": true
},
{
Expand Down Expand Up @@ -4709,7 +4710,7 @@
},
{
"name": "name",
"type": "Identifier",
"type": "JSDocFullName",
"private": true,
"optional": true
},
Expand Down Expand Up @@ -5177,6 +5178,10 @@
"ModuleBlock",
"ModuleDeclaration"
],
"JSDocFullName": [
"Identifier",
"ModuleDeclaration"
],
"ForInitializer": [
"Expression",
"MissingDeclaration",
Expand Down
4 changes: 2 additions & 2 deletions internal/api/encoder/decoder_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/api/encoder/encoder_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ func (n *Node) TypeExpression() *Node {
return n.AsJSDocTypeTag().TypeExpression
case KindJSDocTypedefTag:
return n.AsJSDocTypedefTag().TypeExpression
case KindJSDocCallbackTag:
return n.AsJSDocCallbackTag().TypeExpression
case KindJSDocSatisfiesTag:
return n.AsJSDocSatisfiesTag().TypeExpression
case KindJSDocThrowsTag:
Expand Down
31 changes: 18 additions & 13 deletions internal/ast/ast_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading