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: add class generic type param in manifest #3292

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
17 changes: 14 additions & 3 deletions tools/manifest/custom-elements-manifest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const overrideTypeKey = 'overrideType';
const classGenericsTypeKey = 'classGenerics';

/**
* Docs: https://custom-elements-manifest.open-wc.org/analyzer/getting-started/
Expand Down Expand Up @@ -96,6 +97,19 @@ export function createManifestConfig(library = '') {
}

if (ts.isClassDeclaration(node)) {
const classDeclaration = moduleDoc.declarations.find(
(declaration) => declaration.name === node.name.getText(),
);

/**
* If the class uses a generic type parameter, add it to the class declaration.
* It will be used in the Angular wrapper to correctly generate classes.
* Mainly used for datepicker and calendar components.
*/
if (node.typeParameters && node.typeParameters.length > 0) {
classDeclaration[classGenericsTypeKey] = node.typeParameters[0].getText();
}

/**
* When a generic T type is used in a superclass declaration, it overrides the type defined in derived class
* during the doc generation (as the `value` property in the `SbbFormAssociatedMixinType`).
Expand All @@ -109,9 +123,6 @@ export function createManifestConfig(library = '') {
// eslint-disable-next-line lyne/local-name-rule
if (tag.tagName.getText() === overrideTypeKey) {
const [memberName, memberOverrideType] = tag.comment.split(' - ');
const classDeclaration = moduleDoc.declarations.find(
(declaration) => declaration.name === node.name.getText(),
);
if (!classDeclaration[overrideTypeKey]) {
classDeclaration[overrideTypeKey] = [{ memberName, memberOverrideType }];
} else {
Expand Down
Loading