From 32a26c5e2070b6230dc453a767a17e0412a7593c Mon Sep 17 00:00:00 2001 From: Will Temple Date: Wed, 8 Jan 2025 17:24:03 -0500 Subject: [PATCH] Revert "[core] Widen signature of isTemplateDeclaration/isTemplateDeclarationOrInstance" (#5538) Reverts microsoft/typespec#5527 --- ...le-msft-widen-template-detect-sig-2025-0-8-20-22-59.md | 8 ++++++++ ...le-msft-widen-template-detect-sig-2025-0-8-11-34-58.md | 2 +- packages/compiler/src/core/type-utils.ts | 8 +++----- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .chronus/changes/revert-5527-witemple-msft-widen-template-detect-sig-2025-0-8-20-22-59.md diff --git a/.chronus/changes/revert-5527-witemple-msft-widen-template-detect-sig-2025-0-8-20-22-59.md b/.chronus/changes/revert-5527-witemple-msft-widen-template-detect-sig-2025-0-8-20-22-59.md new file mode 100644 index 0000000000..88bb496492 --- /dev/null +++ b/.chronus/changes/revert-5527-witemple-msft-widen-template-detect-sig-2025-0-8-20-22-59.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: internal +packages: + - "@typespec/compiler" +--- + +Revert "[core] Widen signature of isTemplateDeclaration/isTemplateDeclarationOrInstance" diff --git a/.chronus/changes/witemple-msft-widen-template-detect-sig-2025-0-8-11-34-58.md b/.chronus/changes/witemple-msft-widen-template-detect-sig-2025-0-8-11-34-58.md index aff240ad85..69dfc4489d 100644 --- a/.chronus/changes/witemple-msft-widen-template-detect-sig-2025-0-8-11-34-58.md +++ b/.chronus/changes/witemple-msft-widen-template-detect-sig-2025-0-8-11-34-58.md @@ -1,5 +1,5 @@ --- -changeKind: feature +changeKind: internal packages: - "@typespec/compiler" --- diff --git a/packages/compiler/src/core/type-utils.ts b/packages/compiler/src/core/type-utils.ts index 8d23868bc4..30a28ef545 100644 --- a/packages/compiler/src/core/type-utils.ts +++ b/packages/compiler/src/core/type-utils.ts @@ -120,7 +120,7 @@ export function isDeclaredType(type: Type): boolean { * Resolve if the type is a template type declaration(Non initialized template type). */ export function isTemplateDeclaration( - type: Type, + type: TemplatedType, ): type is TemplatedType & { node: TemplateDeclarationNode } { if (type.node === undefined) { return false; @@ -129,16 +129,14 @@ export function isTemplateDeclaration( return ( node.templateParameters && node.templateParameters.length > 0 && - (type as TemplatedType).templateMapper === undefined + type.templateMapper === undefined ); } /** * Resolve if the type was created from a template type or is a template type declaration. */ -export function isTemplateDeclarationOrInstance( - type: Type, -): type is TemplatedType & { node: TemplateDeclarationNode } { +export function isTemplateDeclarationOrInstance(type: TemplatedType): boolean { if (type.node === undefined) { return false; }