diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 6c277479a509c..573d65d27d7a1 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -1174,8 +1174,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode if (elements.transformFlags === undefined) { aggregateChildrenFlags(elements as MutableNodeArray); } - Debug.attachNodeArrayDebugInfo(elements); - return elements; } // This *was* a `NodeArray`, but the `hasTrailingComma` option differs. Recreate the @@ -1184,7 +1182,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode const array = elements.slice() as MutableNodeArray; array.pos = elements.pos; array.end = elements.end; - array.hasTrailingComma = hasTrailingComma; + array.hasTrailingComma = hasTrailingComma ?? elements.hasTrailingComma; array.transformFlags = elements.transformFlags; Debug.attachNodeArrayDebugInfo(array); return array; diff --git a/tests/cases/fourslash/nodeArrayCloneCrash.ts b/tests/cases/fourslash/nodeArrayCloneCrash.ts new file mode 100644 index 0000000000000..d18a2d7bf8fab --- /dev/null +++ b/tests/cases/fourslash/nodeArrayCloneCrash.ts @@ -0,0 +1,38 @@ +/// + +// @module: preserve + +// @Filename: /TLLineShape.ts +//// import { createShapePropsMigrationIds } from "./TLShape"; +//// createShapePropsMigrationIds/**/ + +// @Filename: /TLShape.ts +//// import { T } from "@tldraw/validate"; +//// +//// /** +//// * @public +//// */ +//// export function createShapePropsMigrationIds(): { [k in keyof T]: any } { +//// return; +//// } + +verify.completions({ + marker: "", + includes: [ + { + name: "createShapePropsMigrationIds", + text: "(alias) function createShapePropsMigrationIds(): { [k in keyof T]: any; }\nimport createShapePropsMigrationIds", + tags: [{ name: "public", text: undefined }] + } + ] +}); + +goTo.file("/TLShape.ts"); +verify.organizeImports( +` +/** + * @public + */ +export function createShapePropsMigrationIds(): { [k in keyof T]: any } { + return; +}`); \ No newline at end of file