Skip to content

Commit 4f60101

Browse files
authored
feat(language-service): set the kind of props inherited from intrinsic elements to Value instead of Field (#5315)
1 parent cdb4f5c commit 4f60101

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/language-service/lib/plugins/vue-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export function create(
327327
...attrs.map<ComponentPropInfo>(attr => ({ name: attr })),
328328
]) {
329329

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

packages/typescript-plugin/lib/requests/getComponentProps.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ComponentPropInfo {
77
name: string;
88
required?: boolean;
99
deprecated?: boolean;
10+
isAttribute?: boolean;
1011
commentMarkdown?: string;
1112
values?: string[];
1213
}
@@ -84,10 +85,27 @@ export function getComponentProps(
8485
}
8586
}
8687

88+
let isAttribute: boolean | undefined;
89+
for (const { parent } of checker.getRootSymbols(prop).flatMap(root => root.declarations ?? [])) {
90+
if (!ts.isInterfaceDeclaration(parent)) {
91+
continue;
92+
}
93+
const { text } = parent.name;
94+
if (
95+
text.endsWith('HTMLAttributes')
96+
|| text === 'AriaAttributes'
97+
|| text === 'SVGAttributes'
98+
) {
99+
isAttribute = true;
100+
break;
101+
}
102+
}
103+
87104
result.set(name, {
88105
name,
89106
required,
90107
deprecated,
108+
isAttribute,
91109
commentMarkdown,
92110
values,
93111
});

0 commit comments

Comments
 (0)