From 66a762f59dd7a9df08d3fc684df90616be10aaef Mon Sep 17 00:00:00 2001 From: Isabel Duan Date: Tue, 16 Jul 2024 13:50:17 -0700 Subject: [PATCH] `visitNodesWithoutCopyingPositions` always makes a new `NodeArray` (#59137) --- src/compiler/checker.ts | 2 +- tests/cases/fourslash/nodeArrayCloneCrash.ts | 38 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/nodeArrayCloneCrash.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 945caeac31f85..86702764c9585 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8966,7 +8966,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (result) { if (result.pos !== -1 || result.end !== -1) { if (result === nodes) { - result = factory.createNodeArray(nodes, nodes.hasTrailingComma); + result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma); } setTextRangePosEnd(result, -1, -1); } 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