Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/mutator-framework"
---

Add regression tests for alternate type dual-edge mutation (ARM + client paths) in mutator-framework
9 changes: 7 additions & 2 deletions packages/http-canonicalization/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ export class ModelHttpCanonicalization
if (referenceTypes.length === 0) {
return engine.mutate(union, options, halfEdge, { isSynthetic: true });
} else {
return engine.replaceAndMutateReference(referenceTypes[0], union, options, halfEdge);
return engine.replaceAndMutateReference(
referenceTypes[0],
union,
options,
halfEdge,
) as any as UnionHttpCanonicalization;
}
}

Expand All @@ -142,7 +147,7 @@ export class ModelHttpCanonicalization
effectiveModel,
options,
halfEdge,
);
) as any as ModelHttpCanonicalization;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,18 @@ it("clones synthetic mutation nodes", async () => {
expect(propNode.mutatedType.type === model).toBe(false);
expect(propNode.mutatedType.type === typeNode.mutatedType).toBe(true);
});

it("creates a literal mutation node for StringTemplate types", async () => {
const { Foo, program } = await runner.compile(t.code`
model ${t.model("Foo")} {
prop: "Start \${123} end";
}
`);
const engine = getEngine(program);
const prop = Foo.properties.get("prop")!;

expect(prop.type.kind).toBe("StringTemplate");
const node = engine.getMutationNode(prop.type);
expect(node).toBeDefined();
expect(node.sourceType).toBe(prop.type);
});
Loading
Loading