Skip to content

Commit

Permalink
spetial treatment for .vue default imports
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve committed May 6, 2024
1 parent 8cbc242 commit 6bb8018
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/language-core/lib/utils/parseBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function parseBindings(ts: typeof import('typescript'), sourceFile: ts.So
if (ts.isTypeLiteralNode(typeNode)) {
for (const prop of typeNode.members) {
if (ts.isPropertySignature(prop)) {
bindingTypes.set(prop.name.getText(), BindingTypes.NoUnref);
bindingTypes.set(_getNodeText(prop.name), BindingTypes.NoUnref);
}
}
}
Expand All @@ -46,7 +46,7 @@ export function parseBindings(ts: typeof import('typescript'), sourceFile: ts.So
if (ts.isObjectLiteralExpression(arg)) {
for (const prop of arg.properties) {
if (ts.isPropertyAssignment(prop)) {
bindingTypes.set(prop.name.getText(), BindingTypes.NoUnref);
bindingTypes.set(_getNodeText(prop.name), BindingTypes.NoUnref);
}
}
}
Expand Down Expand Up @@ -117,7 +117,12 @@ export function parseBindings(ts: typeof import('typescript'), sourceFile: ts.So
if (node.importClause.name) {
const nodeText = _getNodeText(node.importClause.name);
bindingRanges.push(_getStartEnd(node.importClause.name));
bindingTypes.set(nodeText, BindingTypes.NeedUnref);
if (ts.isStringLiteral(node.moduleSpecifier) && _getNodeText(node.moduleSpecifier).endsWith('.vue')) {
bindingTypes.set(nodeText, BindingTypes.NoUnref);
}
else {
bindingTypes.set(nodeText, BindingTypes.NeedUnref);
}
}
if (node.importClause.namedBindings) {
if (ts.isNamedImports(node.importClause.namedBindings)) {
Expand Down Expand Up @@ -189,7 +194,7 @@ export function getNodeText(
// if (ts.isTypeLiteralNode(typeNode)) {
// for (const prop of typeNode.members) {
// if (ts.isPropertySignature(prop)) {
// bindings.set(prop.name.getText(), BindingTypes.NoUnref);
// bindings.set(_getNodeText(prop.name), BindingTypes.NoUnref);
// }
// }
// }
Expand All @@ -199,7 +204,7 @@ export function getNodeText(
// if (ts.isObjectLiteralExpression(arg)) {
// for (const prop of arg.properties) {
// if (ts.isPropertyAssignment(prop)) {
// bindings.set(prop.name.getText(), BindingTypes.NoUnref);
// bindings.set(_getNodeText(prop.name), BindingTypes.NoUnref);
// }
// }
// }
Expand Down

0 comments on commit 6bb8018

Please sign in to comment.