-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue 3 TS2322 Error: not assignable to type: ComponentInternalInstance #295
Comments
We are getting the same error when using vitejs with vue-ts template. It uses vue-tsc to do the checking and it fails with that error. At the moment I'm skipping the vue-tsc when doing a build because of that error but would really like to enable it again. |
We are open to PRs to fix this. But we don't use TS so this is pretty low on our priority list. |
That's really a bummer... for multiple reasons:
|
If you can provide a reproducible test case we'll take a look. Because that's always our challenge with the TS issues. It's not that we don't want to fix them but we don't even know where to start. |
@robmadole here you go: https://github.com/pingustar/vite-vue-fontawesome Steps to reproduceClone repo and run then build the project with -> build fails with error: |
I expect index.d.ts should export the components using the When I change |
I looked into the typing issue but don't know how to test it properly. I don't get the error after changing index.d.ts and matching the vue version to the one in my test app. Using the current peer dependency and vue version doesn't seem to work. I'm not used to creating libraries and I don't want to break anything by changing versions when it's not needed. Most of my time was spent adding reactivity support so I didn't spend too much time on this issue. |
fix import { DefineComponent } from 'vue'
declare const FontAwesomeIcon: DefineComponent<FontAwesomeIconProps>
declare const FontAwesomeLayers: DefineComponent<FontAwesomeLayersProps>
declare const FontAwesomeLayersText: DefineComponent<FontAwesomeLayersTextProps> |
This worked for me:
If you don't want to write the lib files like @uinio described before. |
To have typings for global components, the following worked for me: // components.d.ts
import { DefineComponent } from 'vue';
import { FontAwesomeIconProps } from '@fortawesome/vue-fontawesome';
declare module 'vue' {
export interface GlobalComponents {
FontAwesomeIcon: DefineComponent<Partial<FontAwesomeIconProps>>;
}
}
export {}; I'm using |
When specifying the TS loader for webpack configuration, you can turn off this error.
|
Describe the bug
On development server the icon works (without HMR though) but when building the project I get this TypeScript error:
error TS2322: Type '{ icon: string; }' is not assignable to type '{ $: ComponentInternalInstance; $data: {}; $props: FontAwesomeIconProps; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 7 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<...> | undefined): WatchStopHandle; } & ... 5 more ... & Record<...>'. Type '{ icon: string; }' is missing the following properties from type '{ $: ComponentInternalInstance; $data: {}; $props: FontAwesomeIconProps; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 7 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<...> | undefined): WatchStopHandle; }': $, $data, $props, $attrs, and 10 more.
Versions
"@fortawesome/vue-fontawesome": "^3.0.0-3",
"vue": "^3.0.7",
"typescript": "^4.2.3",
"vite": "^2.1.0",
Is there at least a way to ignore the error since the icons do show up on the dev server?
The text was updated successfully, but these errors were encountered: