From 3e45a823534a2e36ac51cbc701ecff074c7c842d Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Fri, 15 Mar 2024 08:03:18 -0700 Subject: [PATCH] fix(compiler): don't validate references for @Prop, @Method and @Event decorator (#5475) * fix(compiler): don't validate references for @Prop, @Method and @Event decorator STENCIL-980 * remove imports --- .../decorators-to-static/event-decorator.ts | 2 -- .../decorators-to-static/method-decorator.ts | 2 -- .../decorators-to-static/prop-decorator.ts | 2 -- src/compiler/transformers/transform-utils.ts | 18 ++---------------- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/compiler/transformers/decorators-to-static/event-decorator.ts b/src/compiler/transformers/decorators-to-static/event-decorator.ts index 4e3ad523d2a..598682c1c98 100644 --- a/src/compiler/transformers/decorators-to-static/event-decorator.ts +++ b/src/compiler/transformers/decorators-to-static/event-decorator.ts @@ -9,7 +9,6 @@ import { resolveType, retrieveTsDecorators, serializeSymbol, - validateReferences, } from '../transform-utils'; import { getDecoratorParameters, isDecoratorNamed } from './decorator-utils'; @@ -76,7 +75,6 @@ const parseEventDecorator = ( docs: serializeSymbol(typeChecker, symbol), complexType: getComplexType(typeChecker, program, prop), }; - validateReferences(diagnostics, eventMeta.complexType.references, prop.type); return eventMeta; }; diff --git a/src/compiler/transformers/decorators-to-static/method-decorator.ts b/src/compiler/transformers/decorators-to-static/method-decorator.ts index 02f2ff9fce6..b12c39194e9 100644 --- a/src/compiler/transformers/decorators-to-static/method-decorator.ts +++ b/src/compiler/transformers/decorators-to-static/method-decorator.ts @@ -12,7 +12,6 @@ import { retrieveTsDecorators, retrieveTsModifiers, typeToString, - validateReferences, } from '../transform-utils'; import { isDecoratorNamed } from './decorator-utils'; @@ -111,7 +110,6 @@ const parseMethodDecorator = ( tags: mapJSDocTagInfo(signature.getJsDocTags()), }, }; - validateReferences(diagnostics, methodMeta.complexType.references, method.type || method.name); const staticProp = ts.factory.createPropertyAssignment( ts.factory.createStringLiteral(methodName), diff --git a/src/compiler/transformers/decorators-to-static/prop-decorator.ts b/src/compiler/transformers/decorators-to-static/prop-decorator.ts index 20bc7fda990..9924785ce99 100644 --- a/src/compiler/transformers/decorators-to-static/prop-decorator.ts +++ b/src/compiler/transformers/decorators-to-static/prop-decorator.ts @@ -14,7 +14,6 @@ import { serializeSymbol, tsPropDeclNameAsString, typeToString, - validateReferences, } from '../transform-utils'; import { getDecoratorParameters, isDecoratorNamed } from './decorator-utils'; @@ -102,7 +101,6 @@ const parsePropDecorator = ( optional: prop.questionToken !== undefined, docs: serializeSymbol(typeChecker, symbol), }; - validateReferences(diagnostics, propMeta.complexType.references, prop.type); // prop can have an attribute if type is NOT "unknown" if (typeStr !== 'unknown') { diff --git a/src/compiler/transformers/transform-utils.ts b/src/compiler/transformers/transform-utils.ts index 4e7be7440ef..8672b3cc7c2 100644 --- a/src/compiler/transformers/transform-utils.ts +++ b/src/compiler/transformers/transform-utils.ts @@ -1,8 +1,8 @@ -import { augmentDiagnosticWithNode, buildError, normalizePath, readOnlyArrayHasStringMember } from '@utils'; +import { normalizePath } from '@utils'; import ts from 'typescript'; import type * as d from '../../declarations'; -import { MEMBER_DECORATORS_TO_REMOVE, StencilStaticGetter } from './decorators-to-static/decorators-constants'; +import { StencilStaticGetter } from './decorators-to-static/decorators-constants'; import { addToLibrary, findTypeWithName, getHomeModule, getOriginalTypeName } from './type-library'; export const getScriptTarget = () => { @@ -457,20 +457,6 @@ export const getAllTypeReferences = (checker: ts.TypeChecker, node: ts.Node): Re return referencedTypes; }; -export const validateReferences = ( - diagnostics: d.Diagnostic[], - references: d.ComponentCompilerTypeReferences, - node: ts.Node, -) => { - Object.keys(references).forEach((refName) => { - const ref = references[refName]; - if (ref.path === '@stencil/core' && readOnlyArrayHasStringMember(MEMBER_DECORATORS_TO_REMOVE, refName)) { - const err = buildError(diagnostics); - augmentDiagnosticWithNode(err, node); - } - }); -}; - /** * Determine where a TypeScript type reference originates from. This is accomplished by interrogating the AST node in * which the type's name appears