Skip to content
Draft
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: 1 addition & 3 deletions src/compiler/factory/nodeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
if (elements.transformFlags === undefined) {
aggregateChildrenFlags(elements as MutableNodeArray<T>);
}
Debug.attachNodeArrayDebugInfo(elements);
return elements;
Comment on lines -1177 to -1178
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels bit scary to me; I do think we need to think about how we should be defining what this function is actually supposed to do, i.e. come up with create and update separately or something (what you mention in #59137).

}

// This *was* a `NodeArray`, but the `hasTrailingComma` option differs. Recreate the
Expand All @@ -1184,7 +1182,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
const array = elements.slice() as MutableNodeArray<T>;
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;
Expand Down
38 changes: 38 additions & 0 deletions tests/cases/fourslash/nodeArrayCloneCrash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// <reference path="fourslash.ts" />

// @module: preserve

// @Filename: /TLLineShape.ts
//// import { createShapePropsMigrationIds } from "./TLShape";
//// createShapePropsMigrationIds/**/

// @Filename: /TLShape.ts
//// import { T } from "@tldraw/validate";
////
//// /**
//// * @public
//// */
//// export function createShapePropsMigrationIds<T>(): { [k in keyof T]: any } {
//// return;
//// }

verify.completions({
marker: "",
includes: [
{
name: "createShapePropsMigrationIds",
text: "(alias) function createShapePropsMigrationIds<T>(): { [k in keyof T]: any; }\nimport createShapePropsMigrationIds",
tags: [{ name: "public", text: undefined }]
}
]
});

goTo.file("/TLShape.ts");
verify.organizeImports(
`
/**
* @public
*/
export function createShapePropsMigrationIds<T>(): { [k in keyof T]: any } {
return;
}`);