Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Feb 3, 2024
1 parent 26d33a0 commit e375792
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export default {
const { factory } = ts
const nodeStart = node.pos + node.getLeadingTriviaWidth()
const varName = declaration.name.text
changesTracker.insertNodeAt(
sourceFile,
nodeStart,
factory.createVariableDeclarationList(
[factory.createVariableDeclaration(factory.createIdentifier(varName), undefined, typeNode)],
ts.NodeFlags.Let,
),
)
const isJs = !!(node.flags & ts.NodeFlags.JavaScriptFile)
const variableDeclaration = factory.createVariableDeclaration(factory.createIdentifier(varName), undefined, isJs ? undefined : typeNode)
changesTracker.insertNodeAt(sourceFile, nodeStart, factory.createVariableDeclarationList([variableDeclaration], ts.NodeFlags.Let))
if (isJs && typeNode) {
const typeTag = factory.createJSDocTypeTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined)
changesTracker.addJSDocTags(sourceFile, node, [typeTag as any])
}
changesTracker.replaceNode(
sourceFile,
node,
Expand Down

0 comments on commit e375792

Please sign in to comment.