From e7c2c19c47ecdea0e2037a7ce223fc7ed3649ff4 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 11 Jun 2024 14:52:12 -0700 Subject: [PATCH 1/2] Do not run decorators on cloned type if the original type wasn't finished --- packages/compiler/src/core/checker.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/compiler/src/core/checker.ts b/packages/compiler/src/core/checker.ts index 8beba6c45f..37f2edcfad 100644 --- a/packages/compiler/src/core/checker.ts +++ b/packages/compiler/src/core/checker.ts @@ -6512,7 +6512,10 @@ export function createChecker(program: Program): Checker { * recursively by the caller. */ function cloneType(type: T, additionalProps: Partial = {}): T { - const clone = finishType(initializeClone(type, additionalProps)); + let clone = initializeClone(type, additionalProps); + if (type.isFinished) { + clone = finishType(clone); + } const projection = projectionsByType.get(type); if (projection) { projectionsByType.set(clone, projection); From 2811084bd8931912ed44e681b90644dd7ad4bc83 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 11 Jun 2024 14:55:14 -0700 Subject: [PATCH 2/2] Create fix-clone-type-donot-finish-unfinished-2024-5-11-21-54-41.md --- ...one-type-donot-finish-unfinished-2024-5-11-21-54-41.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/fix-clone-type-donot-finish-unfinished-2024-5-11-21-54-41.md diff --git a/.chronus/changes/fix-clone-type-donot-finish-unfinished-2024-5-11-21-54-41.md b/.chronus/changes/fix-clone-type-donot-finish-unfinished-2024-5-11-21-54-41.md new file mode 100644 index 0000000000..947d8feafe --- /dev/null +++ b/.chronus/changes/fix-clone-type-donot-finish-unfinished-2024-5-11-21-54-41.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/compiler" +--- + +[API] Do not run decorators on cloned type if the original type wasn't finished