I am working on creating a Vue component library, but I encountered an error with my type checking. I attempted to update TypeScript as mentioned here, but it did not resolve the issue. Here is a snippet of my code and `package.json` file.
My component code has been exported as a `Button
`
<template>
button
>{{ children }}</button>
</template>
<script lang="tsx">
declare type IconMode =
| {
iconMode?: "without-icon";
}
| {
iconMode: "with-icon" | "icon-only";
iconName: string;
};
...
</script>
The rollup.config.js setup is:
import commonjs from "@rollup/plugin-commonjs";
import vue from "rollup-plugin-vue";
import buble from "@rollup/plugin-buble";
import typescript from "@rollup/plugin-typescript";
export default {
input: "src/index.ts",
output: {
name: "Button",
exports: "named"
},
plugins: [
typescript(),
vue({
css: true,
compileTemplate: true
}),
commonjs()
]
};
Unfortunately, when running this setup, I received the following error in the terminal:
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/Components/Button.vue?vue&type=script&lang.tsx (18:8)
18 declare type IconMode =
^
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
I would greatly appreciate any assistance with resolving this issue.