Skip to content

Commit

Permalink
fix(compiler): don't validate references for @prop, @method and @event
Browse files Browse the repository at this point in the history
…decorator (#5475)

* fix(compiler): don't validate references for @prop, @method and @event decorator

STENCIL-980

* remove imports
  • Loading branch information
christian-bromann committed Mar 15, 2024
1 parent ab97fdf commit 3e45a82
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
resolveType,
retrieveTsDecorators,
serializeSymbol,
validateReferences,
} from '../transform-utils';
import { getDecoratorParameters, isDecoratorNamed } from './decorator-utils';

Expand Down Expand Up @@ -76,7 +75,6 @@ const parseEventDecorator = (
docs: serializeSymbol(typeChecker, symbol),
complexType: getComplexType(typeChecker, program, prop),
};
validateReferences(diagnostics, eventMeta.complexType.references, prop.type);
return eventMeta;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
retrieveTsDecorators,
retrieveTsModifiers,
typeToString,
validateReferences,
} from '../transform-utils';
import { isDecoratorNamed } from './decorator-utils';

Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
serializeSymbol,
tsPropDeclNameAsString,
typeToString,
validateReferences,
} from '../transform-utils';
import { getDecoratorParameters, isDecoratorNamed } from './decorator-utils';

Expand Down Expand Up @@ -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') {
Expand Down
18 changes: 2 additions & 16 deletions src/compiler/transformers/transform-utils.ts
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3e45a82

Please sign in to comment.