Skip to content
Merged
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
4 changes: 4 additions & 0 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ func (n *Node) Initializer() *Node {
return n.AsForInOrOfStatement().Initializer
case KindJsxAttribute:
return n.AsJsxAttribute().Initializer
case KindCommonJSExport:
return n.AsCommonJSExport().Initializer
}
panic("Unhandled case in Node.Initializer")
}
Expand Down Expand Up @@ -806,6 +808,8 @@ func (m *mutableNode) SetInitializer(initializer *Node) {
n.AsForInOrOfStatement().Initializer = initializer
case KindJsxAttribute:
n.AsJsxAttribute().Initializer = initializer
case KindCommonJSExport:
n.AsCommonJSExport().Initializer = initializer
default:
panic("Unhandled case in mutableNode.SetInitializer")
}
Expand Down
5 changes: 3 additions & 2 deletions internal/parser/reparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node)
}
}
case ast.KindVariableDeclaration,
ast.KindCommonJSExport, ast.KindExportAssignment, ast.KindJSExportAssignment,
ast.KindCommonJSExport,
ast.KindPropertyDeclaration, ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment:
if parent.Initializer() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil {
parent.AsMutable().SetInitializer(p.makeNewCast(
Expand All @@ -366,7 +366,8 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node)
false /*isAssertion*/))
p.finishMutatedNode(parent)
}
case ast.KindReturnStatement, ast.KindParenthesizedExpression:
case ast.KindReturnStatement, ast.KindParenthesizedExpression,
ast.KindExportAssignment, ast.KindJSExportAssignment:
if parent.Expression() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil {
parent.AsMutable().SetExpression(p.makeNewCast(
p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//// [tests/cases/compiler/panicSatisfiesOnExportEqualsDeclaration.ts] ////

=== panicSatisfiesOnExportEqualsDeclaration.js ===
/**
* @satisfies {Record<string, never>}
*/
module.exports = {};
>module.exports : Symbol(export=, Decl(panicSatisfiesOnExportEqualsDeclaration.js, 0, 0))
>module : Symbol(module.exports)
>exports : Symbol(export=, Decl(panicSatisfiesOnExportEqualsDeclaration.js, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/panicSatisfiesOnExportEqualsDeclaration.ts] ////

=== panicSatisfiesOnExportEqualsDeclaration.js ===
/**
* @satisfies {Record<string, never>}
*/
module.exports = {};
>module.exports = {} : {}
>module.exports : {}
>module : { "export=": {}; }
>exports : {}
>{} : {}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @module: commonjs
// @lib: esnext,dom,dom.iterable
// @Filename: panicSatisfiesOnExportEqualsDeclaration.js

/**
* @satisfies {Record<string, never>}
*/
module.exports = {};
Loading