vue-component-meta 3.0.0-beta.3 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base.js +13 -8
- package/package.json +4 -4
package/lib/base.js
CHANGED
|
@@ -270,8 +270,10 @@ interface ComponentMeta<T> {
|
|
|
270
270
|
const vueDefaults = vueFile && exportName === 'default'
|
|
271
271
|
? (vueFile instanceof vue.VueVirtualCode ? readVueComponentDefaultProps(vueFile, printer, ts) : {})
|
|
272
272
|
: {};
|
|
273
|
-
const tsDefaults = !vueFile
|
|
274
|
-
|
|
273
|
+
const tsDefaults = !vueFile
|
|
274
|
+
? readTsComponentDefaultProps(ts.createSourceFile('/tmp.' + componentPath.slice(componentPath.lastIndexOf('.') + 1), // ts | js | tsx | jsx
|
|
275
|
+
snapshot.getText(0, snapshot.getLength()), ts.ScriptTarget.Latest), exportName, printer, ts)
|
|
276
|
+
: {};
|
|
275
277
|
for (const [propName, defaultExp] of Object.entries({
|
|
276
278
|
...vueDefaults,
|
|
277
279
|
...tsDefaults,
|
|
@@ -460,7 +462,8 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
460
462
|
else {
|
|
461
463
|
subtypeStr = '[';
|
|
462
464
|
for (let i = 1; i < call.parameters.length; i++) {
|
|
463
|
-
subtypeStr += getFullyQualifiedName(typeChecker.getTypeOfSymbolAtLocation(call.parameters[i], symbolNode))
|
|
465
|
+
subtypeStr += getFullyQualifiedName(typeChecker.getTypeOfSymbolAtLocation(call.parameters[i], symbolNode))
|
|
466
|
+
+ ', ';
|
|
464
467
|
}
|
|
465
468
|
subtypeStr = subtypeStr.slice(0, -2) + ']';
|
|
466
469
|
getSchema = () => {
|
|
@@ -530,8 +533,9 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
530
533
|
},
|
|
531
534
|
};
|
|
532
535
|
}
|
|
533
|
-
else if (subtype.getCallSignatures().length === 0
|
|
534
|
-
(subtype.isClassOrInterface() || subtype.isIntersection()
|
|
536
|
+
else if (subtype.getCallSignatures().length === 0
|
|
537
|
+
&& (subtype.isClassOrInterface() || subtype.isIntersection()
|
|
538
|
+
|| subtype.objectFlags & ts.ObjectFlags.Anonymous)) {
|
|
535
539
|
let schema;
|
|
536
540
|
return {
|
|
537
541
|
kind: 'object',
|
|
@@ -642,7 +646,9 @@ function readVueComponentDefaultProps(root, printer, ts) {
|
|
|
642
646
|
for (const defineModel of scriptSetupRanges.defineModel) {
|
|
643
647
|
const obj = defineModel.argNode ? findObjectLiteralExpression(defineModel.argNode) : undefined;
|
|
644
648
|
if (obj) {
|
|
645
|
-
const name = defineModel.name
|
|
649
|
+
const name = defineModel.name
|
|
650
|
+
? sfc.scriptSetup.content.slice(defineModel.name.start, defineModel.name.end).slice(1, -1)
|
|
651
|
+
: 'modelValue';
|
|
646
652
|
result[name] = resolveModelOption(ast, obj, printer, ts);
|
|
647
653
|
}
|
|
648
654
|
}
|
|
@@ -706,8 +712,7 @@ function readTsComponentDefaultProps(ast, exportName, printer, ts) {
|
|
|
706
712
|
// export default { ... }
|
|
707
713
|
if (ts.isObjectLiteralExpression(component)) {
|
|
708
714
|
return component;
|
|
709
|
-
}
|
|
710
|
-
// export default defineComponent({ ... })
|
|
715
|
+
} // export default defineComponent({ ... })
|
|
711
716
|
else if (ts.isCallExpression(component)) {
|
|
712
717
|
if (component.arguments.length) {
|
|
713
718
|
const arg = component.arguments[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/component-meta"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/typescript": "2.4.
|
|
17
|
-
"@vue/language-core": "3.0.0-beta.
|
|
16
|
+
"@volar/typescript": "2.4.15",
|
|
17
|
+
"@vue/language-core": "3.0.0-beta.4",
|
|
18
18
|
"path-browserify": "^1.0.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"@types/path-browserify": "^1.0.1",
|
|
27
27
|
"vue-component-type-helpers": "3.0.0-beta.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "5cb41faacbfe2d9e2d64637c6c1ae8769d9cba3f"
|
|
30
30
|
}
|