Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templated interface extending another templated interface shouldn't run decorator on their operations #3287

Merged
Merged
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,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
Loading