Skip to content
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,7 @@
---
changeKind: internal
packages:
- "@typespec/http"
---

Do not emit deprecated-implicit-optionality on op is
16 changes: 12 additions & 4 deletions packages/http/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,18 @@ export const $patch: PatchDecorator = (

if (options) {
if (options.implicitOptionality === true) {
reportDiagnostic(context.program, {
code: "deprecated-implicit-optionality",
target: entity,
});
// Only emit the deprecation warning on the original use of the decorator,
// not when inherited via `op is`.
const decoratorNode = context.decoratorTarget as any;
if (
decoratorNode.kind !== SyntaxKind.DecoratorExpression ||
decoratorNode.parent === entity.node
) {
reportDiagnostic(context.program, {
code: "deprecated-implicit-optionality",
target: entity,
});
}
}
setPatchOptions(context.program, entity, options);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/http/test/http-decorators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ describe("http: decorators", () => {

expectDiagnosticEmpty(diagnostics);
});

it(`@patch does not emit deprecation warning when inherited via 'op is'`, async () => {
const diagnostics = await Tester.diagnose(`
@route("/base") #suppress "@typespec/http/deprecated-implicit-optionality" "testing"
@patch(#{ implicitOptionality: true }) op base(): string;
@route("/derived") op derived is base;
`);

expectDiagnosticEmpty(diagnostics);
});
});

describe("@header", () => {
Expand Down
Loading