Skip to content

feat(language-service): set the kind of props inherited from intrinsic elements to Value instead of Field #5315

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

Merged
merged 17 commits into from
Apr 13, 2025
Merged
2 changes: 1 addition & 1 deletion packages/language-service/lib/plugins/vue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export function create(
...attrs.map<ComponentPropInfo>(attr => ({ name: attr })),
]) {

const isGlobal = !propsSet.has(prop.name);
const isGlobal = prop.isAttribute || !propsSet.has(prop.name);
const name = casing.attr === AttrNameCasing.Camel ? prop.name : hyphenateAttr(prop.name);
const isEvent = hyphenateAttr(name).startsWith('on-');

Expand Down
18 changes: 18 additions & 0 deletions packages/typescript-plugin/lib/requests/getComponentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ComponentPropInfo {
name: string;
required?: boolean;
deprecated?: boolean;
isAttribute?: boolean;
commentMarkdown?: string;
values?: string[];
}
Expand Down Expand Up @@ -84,10 +85,27 @@ export function getComponentProps(
}
}

let isAttribute: boolean | undefined;
for (const { parent } of checker.getRootSymbols(prop).flatMap(root => root.declarations ?? [])) {
if (!ts.isInterfaceDeclaration(parent)) {
continue;
}
const { text } = parent.name;
if (
text.endsWith('HTMLAttributes')
|| text === 'AriaAttributes'
|| text === 'SVGAttributes'
) {
isAttribute = true;
break;
}
}

result.set(name, {
name,
required,
deprecated,
isAttribute,
commentMarkdown,
values,
});
Expand Down