Skip to content

Commit

Permalink
Do not run decorators on cloned type if the original type wasn't fini…
Browse files Browse the repository at this point in the history
…shed (#3566)

In the same way we have this logic for `cloneTypeForSymbol`
  • Loading branch information
timotheeguerin authored Jun 11, 2024
1 parent ac93dfa commit 1f82d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion packages/compiler/src/core/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6512,7 +6512,10 @@ export function createChecker(program: Program): Checker {
* recursively by the caller.
*/
function cloneType<T extends Type>(type: T, additionalProps: Partial<T> = {}): 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);
Expand Down

0 comments on commit 1f82d65

Please sign in to comment.