From 5c5db0e871616699ae0dd99d60facee96541e17a Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Thu, 14 Mar 2024 10:51:00 -0700 Subject: [PATCH 1/2] fix(compiler): don't validate references for @Prop, @Method and @Event decorator STENCIL-980 --- .../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 | 14 -------------- 4 files changed, 20 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..3e543e702bd 100644 --- a/src/compiler/transformers/transform-utils.ts +++ b/src/compiler/transformers/transform-utils.ts @@ -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 From a6da43ed2363f660a4bc4be2a9ca6b027a453a0d Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Thu, 14 Mar 2024 11:06:19 -0700 Subject: [PATCH 2/2] remove imports --- src/compiler/transformers/transform-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/transformers/transform-utils.ts b/src/compiler/transformers/transform-utils.ts index 3e543e702bd..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 = () => {