javascripttypescriptvuejs3webcam

Vue3 webcam typescript support


i'm looking for component webcam for my vue3 project, currently i found https://www.npmjs.com/package/vue-camera-lib this package, but the problem is this package don't support typescript, i got this error when i try to import to my project

error screenshot

import { WebCamUI } from 'vue-camera-lib'

I'm thinking about 2 approach :

  1. add type for that library but i don't know how to start
  2. using similar library with typescript support but i cannot find one

Any help will appreciate, thankyou

i expect can solve the type support issue, or find similar library that i can use


Solution

  • Not supporting TypeScript doesn't prevent use of the library. Remember, TypeScript doesn't run in the browser, JavaScript does, so TypeScript errors/warnings aren't usually blockers as long as the transpiled JavaScript is still sound. The error's suggestion is enough to correct the issue when it says:

    ... or add a new declaration (.d.ts) file containing declare module 'vue-camera-lib';

    Simply add to any existing .dt.s file or create new one, e.g. index.d.ts:

    declare module 'vue-camera-lib'
    

    After saving, the error will no longer appear.