question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue 3 TS2322 Error: not assignable to type: ComponentInternalInstance

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
exreplaycommented, Sep 22, 2021

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 vite with the volar extension in vscode.

6reactions
sasknotcommented, Apr 20, 2021

This worked for me:

import { DefineComponent } from 'vue'
import { FontAwesomeIcon, FontAwesomeIconProps } from '@fortawesome/vue-fontawesome'

...

app.component('fa-icon', FontAwesomeIcon as unknown as DefineComponent<FontAwesomeIconProps>)

If you don’t want to write the lib files like @uinio described before.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not assignable errors with Vue 3, Typescript, Composition API
Types of property '__isTeleport' are incompatible. Type 'true' is not assignable to type 'undefined'. This is the component: Copy Code
Read more >
TypeScript error 'Type '($event: any) => void' is not assignable ...
As I understand in this issue we have 2 options: add @types/node: '18.8.0'; wait until this change is merged into a vue 2.7...
Read more >
Argument type 'void' is not assignable to parameter of type
The error "Argument of type 'void' is not assignable to parameter of type" occurs when we forget to return from a function and...
Read more >
编译失败,发布的啥版本呀 - 人人开源社区
src/layout/setting/index.vue:55:31 - error TS2322: Type '() => void' is not ... string>, {}>' is not assignable to type '{ $: ComponentInternalInstance; ...
Read more >
Type errors using properties with Vue3 SFC with TypeScript
( volar complains about the same thing). I've tried a few different approaches with no better luck, these are: Using the <script setup>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found