From 1f4bd79fb0d433204192c748d485e186ec02c68e Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 5 May 2026 13:42:59 -0400 Subject: [PATCH 1/3] Do not emit deprecated-implicit-optionality on op is --- packages/http/src/decorators.ts | 16 ++++++++++++---- packages/http/test/http-decorators.test.ts | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/http/src/decorators.ts b/packages/http/src/decorators.ts index aad49bd3302..7fae391f393 100644 --- a/packages/http/src/decorators.ts +++ b/packages/http/src/decorators.ts @@ -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); } diff --git a/packages/http/test/http-decorators.test.ts b/packages/http/test/http-decorators.test.ts index e629136a67a..6e1d89b2f85 100644 --- a/packages/http/test/http-decorators.test.ts +++ b/packages/http/test/http-decorators.test.ts @@ -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(` + #suppress "@typespec/http/deprecated-implicit-optionality" "testing" + @patch(#{ implicitOptionality: true }) op base(): string; + op derived is base; + `); + + expectDiagnosticEmpty(diagnostics); + }); }); describe("@header", () => { From d6bb5c255a7ef73634d3c6de09a7d9cae449da67 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 5 May 2026 13:43:17 -0400 Subject: [PATCH 2/3] chg --- ...implicit-optionality-no-op-is-warn-2026-4-5-13-43-12.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/fix-implicit-optionality-no-op-is-warn-2026-4-5-13-43-12.md diff --git a/.chronus/changes/fix-implicit-optionality-no-op-is-warn-2026-4-5-13-43-12.md b/.chronus/changes/fix-implicit-optionality-no-op-is-warn-2026-4-5-13-43-12.md new file mode 100644 index 00000000000..eb18d34e897 --- /dev/null +++ b/.chronus/changes/fix-implicit-optionality-no-op-is-warn-2026-4-5-13-43-12.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http" +--- + +Do not emit deprecated-implicit-optionality on op is \ No newline at end of file From d73dae400ec62906751290453a8889e0f78eae12 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 5 May 2026 13:48:50 -0400 Subject: [PATCH 3/3] fix test --- packages/http/test/http-decorators.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http/test/http-decorators.test.ts b/packages/http/test/http-decorators.test.ts index 6e1d89b2f85..f200d5278ae 100644 --- a/packages/http/test/http-decorators.test.ts +++ b/packages/http/test/http-decorators.test.ts @@ -73,9 +73,9 @@ describe("http: decorators", () => { it(`@patch does not emit deprecation warning when inherited via 'op is'`, async () => { const diagnostics = await Tester.diagnose(` - #suppress "@typespec/http/deprecated-implicit-optionality" "testing" + @route("/base") #suppress "@typespec/http/deprecated-implicit-optionality" "testing" @patch(#{ implicitOptionality: true }) op base(): string; - op derived is base; + @route("/derived") op derived is base; `); expectDiagnosticEmpty(diagnostics);