This repo contains a set of unplugin plugins for Vue.js 3, including the following:
- @vue.ts/complex-types - Use @vue/language-core to support complex types for Vue Macros.
- @vue.ts/tsx-auto-props - Add props for your tsx components automatically.
Enhance your Vue.js experience with TypeScript
License: MIT License
This repo contains a set of unplugin plugins for Vue.js 3, including the following:
Hi, I can't seem to get complex-types working for my Vue/Vite/Typescript project build, am currently still noticing the error mentioned in the vue core #8286 issue during the vite build
step. Wondering if it could be an issue with my vite configuration which you can see below.
One thing I'm a little confused about is which version of complex-types
I should be using in my Vite config, since I'm expecting complex-types
to be applied during the build step, and Vite uses rollup for the build step. I'm currently including complex-types
as a rollup plugin in my vite.config.ts
error during build:
Error: [vite:vue] [@vue/compiler-sfc] Failed to resolve extends base type.
If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
interface Props extends /* @vue-ignore */ Base {}
Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.
/workspace/src/Button/MyButton.vue
6 | import { ButtonHTMLAttributes } from "vue";
7 |
8 | interface MyButtonProps extends ButtonHTMLAttributes {
| ^^^^^^^^^^^^^^^^^^^^
9 | label: string;
10 | }
file: /workspace/src/Button/MyButton.vue
at ScriptCompileContext.error (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:15575:11)
at resolveInterfaceMembers (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:18036:13)
at innerResolveTypeElements (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17813:14)
at resolveTypeElements (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17799:20)
at innerResolveTypeElements (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17866:16)
at resolveTypeElements (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17799:20)
at resolveRuntimePropsFromType (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19324:20)
at extractRuntimeProps (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19300:17)
at genRuntimeProps (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:19288:18)
at Object.compileScript (/workspace/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:20384:21)
{
"name": "vue-vite-component-library",
"version": "1.0.0",
"description": "JavaScript and TypeScript example starter project",
"type": "module",
"scripts": {
"build": "vue-tsc --p ./tsconfig.build.json && vite build"
},
"dependencies": {
"vue": "^3.4.21"
},
"devDependencies": {
"@types/node": "^20.11.30",
"@vitejs/plugin-vue": "^5.0.4",
"@vue.ts/complex-types": "^0.5.0",
"sass": "^1.72.0",
"sass-loader": "^14.1.1",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-plugin-dts": "^3.7.3",
"vue-tsc": "^2.0.6"
}
}
import { defineConfig } from "vite";
import { resolve } from "path";
import complexTypesRollup from "@vue.ts/complex-types/rollup";
import vue from "@vitejs/plugin-vue";
import dts from "vite-plugin-dts";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), dts({ tsconfigPath: "tsconfig.build.json" })],
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
formats: ["es"],
},
rollupOptions: {
external: ["vue"],
plugins: [
complexTypesRollup({
tsconfigPath: resolve(__dirname, "tsconfig.build.json"),
}),
],
},
},
});
https://codesandbox.io/p/devbox/rrzs2y
N/A
13:36:08 [vite] Internal server error: ts.isIntersectionTypeNode is not a function
Plugin: unplugin-vue-complex-types
File: E:/git/vue3-modal-demo/src/components/CommandDialog.vue
at Printer.print (file:///E:/git/vue3-modal-demo/node_modules/unplugin-vue-complex-types/dist/index.mjs:224:12)
at transform (file:///E:/git/vue3-modal-demo/node_modules/unplugin-vue-complex-types/dist/index.mjs:254:31)
at TransformContext.transform (file:///E:/git/vue3-modal-demo/node_modules/unplugin-vue-complex-types/dist/index.mjs:272:12)
at Object.transform (file:///E:/git/vue3-modal-demo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44352:62)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async loadAndTransform (file:///E:/git/vue3-modal-demo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55026:29)
at async viteTransformMiddleware (file:///E:/git/vue3-modal-demo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:64430:32)
only import
System:
OS: Windows 10 10.0.19042
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Memory: 5.49 GB / 15.85 GB
Binaries:
Node: 16.14.0
Yarn: 1.22.19
npm: 9.7.1
pnpm: 8.6.1
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (114.0.1823.43)
Internet Explorer: 11.0.19041.1202
yarn
I have a union with about 120 strings in it. Setting aside whether a 120 string union is a good idea or not. When it gets expanded by complex types it prints out truncated with ... 95 more ...
inserted into the code handed to vue causing a syntax error.
[vite] Internal server error: [vue/compiler-sfc] Unexpected token (8:200)
D:/programming/streamstuff/castmate2/plugins/input/renderer/src/components/KeyboardKeyView.vue
13 | const props = defineProps<
14 | {
15 | modelValue: "Space" | "Escape" | "Tab" | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | "F13" | "F14" | "F15" | "F16" | "F17" | "F18" | "F19" | "F20" | "F21" | ... 95 more ... | undefined
| ^
16 | schema: SchemaKeyboardKey
17 | } & {
Poking through the typescript compiler I think NodeBuilderFlags.NoTruncation
is the flag that stops this from happening. But I could be wrong.
No response
interface Props {
foo?: number // Optional
bar: "a" | "b" // union types, should be converted to string
}
N/A
pnpm
unnecessary
N/A
yarn
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These branches will be created by Renovate only once you click their checkbox below.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@types/node
, @volar/typescript
, @vue-macros/better-define
, @vue/language-core
, bumpp
, pnpm
, rollup
, typescript
, vite
, vue
).github/workflows/autofix-ci.yml
actions/checkout v3
actions/setup-node v3
autofix-ci/action ea32e3a12414e6d3183163c3424a7d7a8631ad84
.github/workflows/ci.yml
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
.github/workflows/lock.yml
dessant/lock-threads v4
.github/workflows/release.yml
actions/checkout v3
actions/setup-node v3
package.json
@antfu/ni ^0.21.8
@so1ve/eslint-config ^2.0.0
@so1ve/prettier-config ^2.0.0
@types/node ^20.8.10
@vue-macros/test-utils ^1.4.0
bumpp ^9.2.0
eslint ^8.57.0
prettier ^3.2.5
typescript ^5.2.2
unbuild ^2.0.0
vite ^5.0.2
vite-tsconfig-paths ^4.2.1
vitest ^0.34.6
vue ^3.4.21
pnpm 8.15.6
packages/common/package.json
@rollup/pluginutils ^5.0.5
packages/complex-types/package.json
@nuxt/kit ^3.8.1
magic-string ^0.30.5
unplugin ^1.5.0
@nuxt/schema ^3.8.1
@vue-macros/better-define ^1.6.12
rollup ^4.3.0
unbuild ^2.0.0
vite ^5.0.2
webpack ^5.89.0
typescript ^5.2.2
vue ^3.3.7
packages/language/package.json
@volar/typescript ~2.1.6
@vue/language-core 2.0.7
packages/tsx-auto-props/package.json
@nuxt/kit ^3.8.1
magic-string ^0.30.5
unplugin ^1.5.0
@nuxt/schema ^3.8.1
rollup ^4.3.0
unbuild ^2.0.0
vite ^5.0.2
webpack ^5.89.0
typescript ^5.2.2
vue ^3.3.7
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.