Skip to content

Commit

Permalink
Templated interface extending another templated interface shouldn't r…
Browse files Browse the repository at this point in the history
…un decorator on their operations (#3287)

fix #3286
  • Loading branch information
timotheeguerin authored May 6, 2024
1 parent fef1c39 commit d8c26b1
Show file tree
Hide file tree
Showing 3 changed files with 30 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"
---

Templated interface extending another templated interface shouldn't run decorator on their operations
4 changes: 3 additions & 1 deletion packages/compiler/src/core/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4724,7 +4724,9 @@ export function createChecker(program: Program): Checker {
clone.decorators.push(dec);
}
}
clone = finishType(clone);
if (type.isFinished) {
clone = finishType(clone);
}
compilerAssert(clone.kind === type.kind, "cloneType must not change type kind");
return clone;
}
Expand Down
19 changes: 19 additions & 0 deletions packages/compiler/test/checker/interface.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,25 @@ describe("compiler: interfaces", () => {
expect($track).not.toHaveBeenCalled();
});

it("templated interface extending another templated interface doesn't run decorator on extended interface operations", async () => {
const $track = vi.fn();
testHost.addJsFile("dec.js", { $track });
testHost.addTypeSpecFile(
"main.tsp",
`
import "./dec.js";
interface Base<T> {
@track bar(): T;
}
interface Foo<T> extends Base<T> {}
`
);
await testHost.compile("./");
expect($track).not.toHaveBeenCalled();
});

it("emit warning if shadowing parent templated type", async () => {
const diagnostics = await runner.diagnose(`
interface Base<A> {
Expand Down

0 comments on commit d8c26b1

Please sign in to comment.