Fix to preserve types using structuredClone (#3113)

This commit is contained in:
Jonathan Tran
2024-07-25 20:11:46 -04:00
committed by GitHub
parent 0e5d88df0b
commit e3b8807d6f
17 changed files with 76 additions and 87 deletions

View File

@ -725,7 +725,7 @@ export function moveValueIntoNewVariablePath(
programMemory,
pathToNode
)
let _node = JSON.parse(JSON.stringify(ast))
let _node = structuredClone(ast)
const boop = replacer(_node, variableName)
if (trap(boop)) return { modifiedAst: ast }
@ -757,7 +757,7 @@ export function moveValueIntoNewVariable(
programMemory,
sourceRange
)
let _node = JSON.parse(JSON.stringify(ast))
let _node = structuredClone(ast)
const replaced = replacer(_node, variableName)
if (trap(replaced)) return { modifiedAst: ast }
@ -782,7 +782,7 @@ export function deleteSegmentFromPipeExpression(
code: string,
pathToNode: PathToNode
): Program | Error {
let _modifiedAst: Program = JSON.parse(JSON.stringify(modifiedAst))
let _modifiedAst = structuredClone(modifiedAst)
dependentRanges.forEach((range) => {
const path = getNodePathFromSourceRange(_modifiedAst, range)
@ -899,7 +899,7 @@ export async function deleteFromSelection(
getFaceDetails: (id: string) => Promise<Models['FaceIsPlanar_type']> = () =>
({} as any)
): Promise<Program | Error> {
const astClone = JSON.parse(JSON.stringify(ast))
const astClone = structuredClone(ast)
const range = selection.range
const path = getNodePathFromSourceRange(ast, range)
const varDec = getNodeFromPath<VariableDeclarator>(