Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): don't validate references for @Prop, @Method and @Event decorator #5475

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading