@vue.ts/complex-types 0.5.0 → 0.6.0
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/README.md +16 -16
- package/dist/astro.cjs +1 -1
- package/dist/astro.mjs +1 -1
- package/dist/index.cjs +16 -6
- package/dist/index.mjs +16 -6
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vue.ts/complex-types
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@vue.ts/complex-types)
|
|
4
4
|
|
|
5
5
|
Use [`@vue/language-core`](https://github.com/vuejs/language-tools/tree/master/packages/language-core) to support complex types for Vue Macros.
|
|
6
6
|
|
|
@@ -9,9 +9,9 @@ For example: fixes https://github.com/vuejs/core/issues/8286.
|
|
|
9
9
|
## 📦 Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
$ npm install -D
|
|
13
|
-
$ yarn add -D
|
|
14
|
-
$ pnpm add -D
|
|
12
|
+
$ npm install -D @vue.ts/complex-types
|
|
13
|
+
$ yarn add -D @vue.ts/complex-types
|
|
14
|
+
$ pnpm add -D @vue.ts/complex-types
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## TODOs
|
|
@@ -25,7 +25,7 @@ $ pnpm add -D unplugin-vue-complex-types
|
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
// vite.config.ts
|
|
28
|
-
import VueComplexTypes from "
|
|
28
|
+
import VueComplexTypes from "@vue.ts/complex-types/vite";
|
|
29
29
|
|
|
30
30
|
export default defineConfig({
|
|
31
31
|
plugins: [
|
|
@@ -43,7 +43,7 @@ export default defineConfig({
|
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
45
|
// rollup.config.js
|
|
46
|
-
import VueComplexTypes from "
|
|
46
|
+
import VueComplexTypes from "@vue.ts/complex-types/rollup";
|
|
47
47
|
|
|
48
48
|
export default {
|
|
49
49
|
plugins: [
|
|
@@ -65,7 +65,7 @@ export default {
|
|
|
65
65
|
module.exports = {
|
|
66
66
|
/* ... */
|
|
67
67
|
plugins: [
|
|
68
|
-
require("
|
|
68
|
+
require("@vue.ts/complex-types/webpack")({
|
|
69
69
|
/* options */
|
|
70
70
|
}),
|
|
71
71
|
],
|
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
|
82
82
|
module.exports = {
|
|
83
83
|
/* ... */
|
|
84
84
|
plugins: [
|
|
85
|
-
require("
|
|
85
|
+
require("@vue.ts/complex-types/rspack")({
|
|
86
86
|
/* options */
|
|
87
87
|
}),
|
|
88
88
|
],
|
|
@@ -97,7 +97,7 @@ module.exports = {
|
|
|
97
97
|
```ts
|
|
98
98
|
// nuxt.config.ts
|
|
99
99
|
export default defineNuxtConfig({
|
|
100
|
-
modules: ["
|
|
100
|
+
modules: ["@vue.ts/complex-types/nuxt"],
|
|
101
101
|
complexTypes: {
|
|
102
102
|
/* options */
|
|
103
103
|
},
|
|
@@ -114,7 +114,7 @@ export default defineNuxtConfig({
|
|
|
114
114
|
module.exports = {
|
|
115
115
|
configureWebpack: {
|
|
116
116
|
plugins: [
|
|
117
|
-
require("
|
|
117
|
+
require("@vue.ts/complex-types/webpack")({
|
|
118
118
|
/* options */
|
|
119
119
|
}),
|
|
120
120
|
],
|
|
@@ -132,7 +132,7 @@ module.exports = {
|
|
|
132
132
|
module.exports = {
|
|
133
133
|
vitePlugins: [
|
|
134
134
|
[
|
|
135
|
-
"
|
|
135
|
+
"@vue.ts/complex-types/vite",
|
|
136
136
|
{
|
|
137
137
|
/* options */
|
|
138
138
|
},
|
|
@@ -143,12 +143,12 @@ module.exports = {
|
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
145
|
// quasar.conf.js [Webpack]
|
|
146
|
-
const VueComplexTypesPlugin = require("
|
|
146
|
+
const VueComplexTypesPlugin = require("@vue.ts/complex-types/webpack");
|
|
147
147
|
|
|
148
148
|
module.exports = {
|
|
149
149
|
build: {
|
|
150
150
|
chainWebpack(chain) {
|
|
151
|
-
chain.plugin("
|
|
151
|
+
chain.plugin("@vue.ts/complex-types").use(
|
|
152
152
|
VueComplexTypesPlugin({
|
|
153
153
|
/* options */
|
|
154
154
|
}),
|
|
@@ -170,7 +170,7 @@ import { build } from "esbuild";
|
|
|
170
170
|
build({
|
|
171
171
|
/* ... */
|
|
172
172
|
plugins: [
|
|
173
|
-
require("
|
|
173
|
+
require("@vue.ts/complex-types/esbuild")({
|
|
174
174
|
/* options */
|
|
175
175
|
}),
|
|
176
176
|
],
|
|
@@ -184,7 +184,7 @@ build({
|
|
|
184
184
|
|
|
185
185
|
```ts
|
|
186
186
|
// astro.config.mjs
|
|
187
|
-
import VueComplexTypes from "
|
|
187
|
+
import VueComplexTypes from "@vue.ts/complex-types/astro";
|
|
188
188
|
|
|
189
189
|
export default defineConfig({
|
|
190
190
|
integrations: [
|
package/dist/astro.cjs
CHANGED
package/dist/astro.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,11 @@ class Printer {
|
|
|
42
42
|
const parts = ["{"];
|
|
43
43
|
for (const member of node.members) {
|
|
44
44
|
if (ts__default.isPropertySignature(member)) {
|
|
45
|
-
const stringBaseType = member.type ? this.checker.typeToString(
|
|
45
|
+
const stringBaseType = member.type ? this.checker.typeToString(
|
|
46
|
+
this.getBaseType(member.type),
|
|
47
|
+
void 0,
|
|
48
|
+
ts__default.TypeFormatFlags.NoTruncation
|
|
49
|
+
) : "any";
|
|
46
50
|
parts.push(
|
|
47
51
|
[
|
|
48
52
|
member.name.getText(),
|
|
@@ -67,7 +71,9 @@ class Printer {
|
|
|
67
71
|
for (const property of properties) {
|
|
68
72
|
const valueType = this.checker.getTypeOfSymbol(property);
|
|
69
73
|
const stringValueType = this.checker.typeToString(
|
|
70
|
-
this.getBaseType(valueType)
|
|
74
|
+
this.getBaseType(valueType),
|
|
75
|
+
void 0,
|
|
76
|
+
ts__default.TypeFormatFlags.NoTruncation
|
|
71
77
|
);
|
|
72
78
|
parts.push(
|
|
73
79
|
`${this.checker.symbolToString(
|
|
@@ -89,7 +95,7 @@ class Printer {
|
|
|
89
95
|
return this.printByType(node);
|
|
90
96
|
} else {
|
|
91
97
|
console.error(
|
|
92
|
-
`[
|
|
98
|
+
`[@vue.ts/complex-types] \`${ts__default.SyntaxKind[node.kind]}\` is not supported.`
|
|
93
99
|
);
|
|
94
100
|
return node.getText();
|
|
95
101
|
}
|
|
@@ -98,7 +104,11 @@ class Printer {
|
|
|
98
104
|
return callSignatures.map((c) => {
|
|
99
105
|
const parameters = c.getParameters();
|
|
100
106
|
const event = parameters[0];
|
|
101
|
-
return this.checker.typeToString(
|
|
107
|
+
return this.checker.typeToString(
|
|
108
|
+
this.checker.getTypeOfSymbol(event),
|
|
109
|
+
void 0,
|
|
110
|
+
ts__default.TypeFormatFlags.NoTruncation
|
|
111
|
+
);
|
|
102
112
|
});
|
|
103
113
|
}
|
|
104
114
|
printEventsByMembers(members) {
|
|
@@ -111,7 +121,7 @@ class Printer {
|
|
|
111
121
|
const members = type.getProperties();
|
|
112
122
|
if (callSignatures.length > 0 && members.length > 0) {
|
|
113
123
|
throw new Error(
|
|
114
|
-
"[
|
|
124
|
+
"[@vue.ts/complex-types] You may not use old style `defineEmits` and `defineEmits` shorthand together."
|
|
115
125
|
);
|
|
116
126
|
}
|
|
117
127
|
if (members.length > 0) {
|
|
@@ -145,7 +155,7 @@ const transformDefineEmits = (printer, s, id) => {
|
|
|
145
155
|
}
|
|
146
156
|
if (defineEmitsRuntimeArg) {
|
|
147
157
|
throw new Error(
|
|
148
|
-
"[
|
|
158
|
+
"[@vue.ts/complex-types] `defineEmits` cannot accept both runtime argument and type argument."
|
|
149
159
|
);
|
|
150
160
|
}
|
|
151
161
|
const tokens = defineEmitsNode.getChildren(scriptSetupAst);
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,11 @@ class Printer {
|
|
|
35
35
|
const parts = ["{"];
|
|
36
36
|
for (const member of node.members) {
|
|
37
37
|
if (ts.isPropertySignature(member)) {
|
|
38
|
-
const stringBaseType = member.type ? this.checker.typeToString(
|
|
38
|
+
const stringBaseType = member.type ? this.checker.typeToString(
|
|
39
|
+
this.getBaseType(member.type),
|
|
40
|
+
void 0,
|
|
41
|
+
ts.TypeFormatFlags.NoTruncation
|
|
42
|
+
) : "any";
|
|
39
43
|
parts.push(
|
|
40
44
|
[
|
|
41
45
|
member.name.getText(),
|
|
@@ -60,7 +64,9 @@ class Printer {
|
|
|
60
64
|
for (const property of properties) {
|
|
61
65
|
const valueType = this.checker.getTypeOfSymbol(property);
|
|
62
66
|
const stringValueType = this.checker.typeToString(
|
|
63
|
-
this.getBaseType(valueType)
|
|
67
|
+
this.getBaseType(valueType),
|
|
68
|
+
void 0,
|
|
69
|
+
ts.TypeFormatFlags.NoTruncation
|
|
64
70
|
);
|
|
65
71
|
parts.push(
|
|
66
72
|
`${this.checker.symbolToString(
|
|
@@ -82,7 +88,7 @@ class Printer {
|
|
|
82
88
|
return this.printByType(node);
|
|
83
89
|
} else {
|
|
84
90
|
console.error(
|
|
85
|
-
`[
|
|
91
|
+
`[@vue.ts/complex-types] \`${ts.SyntaxKind[node.kind]}\` is not supported.`
|
|
86
92
|
);
|
|
87
93
|
return node.getText();
|
|
88
94
|
}
|
|
@@ -91,7 +97,11 @@ class Printer {
|
|
|
91
97
|
return callSignatures.map((c) => {
|
|
92
98
|
const parameters = c.getParameters();
|
|
93
99
|
const event = parameters[0];
|
|
94
|
-
return this.checker.typeToString(
|
|
100
|
+
return this.checker.typeToString(
|
|
101
|
+
this.checker.getTypeOfSymbol(event),
|
|
102
|
+
void 0,
|
|
103
|
+
ts.TypeFormatFlags.NoTruncation
|
|
104
|
+
);
|
|
95
105
|
});
|
|
96
106
|
}
|
|
97
107
|
printEventsByMembers(members) {
|
|
@@ -104,7 +114,7 @@ class Printer {
|
|
|
104
114
|
const members = type.getProperties();
|
|
105
115
|
if (callSignatures.length > 0 && members.length > 0) {
|
|
106
116
|
throw new Error(
|
|
107
|
-
"[
|
|
117
|
+
"[@vue.ts/complex-types] You may not use old style `defineEmits` and `defineEmits` shorthand together."
|
|
108
118
|
);
|
|
109
119
|
}
|
|
110
120
|
if (members.length > 0) {
|
|
@@ -138,7 +148,7 @@ const transformDefineEmits = (printer, s, id) => {
|
|
|
138
148
|
}
|
|
139
149
|
if (defineEmitsRuntimeArg) {
|
|
140
150
|
throw new Error(
|
|
141
|
-
"[
|
|
151
|
+
"[@vue.ts/complex-types] `defineEmits` cannot accept both runtime argument and type argument."
|
|
142
152
|
);
|
|
143
153
|
}
|
|
144
154
|
const tokens = defineEmitsNode.getChildren(scriptSetupAst);
|
package/dist/nuxt.cjs
CHANGED
package/dist/nuxt.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue.ts/complex-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (@so1ve)",
|
|
5
5
|
"description": "Resolve complex types in Vue SFCs.",
|
|
6
6
|
"keywords": [
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@nuxt/kit": "^3.8.1",
|
|
86
86
|
"magic-string": "^0.30.5",
|
|
87
87
|
"unplugin": "^1.5.0",
|
|
88
|
-
"@vue.ts/common": "0.
|
|
89
|
-
"@vue.ts/language": "0.
|
|
88
|
+
"@vue.ts/common": "0.6.0",
|
|
89
|
+
"@vue.ts/language": "0.6.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@nuxt/schema": "^3.8.1",
|