WebSerial Support
I am trying to use the WebSerial api and i keep getting
How do i use the WebSerial API with Typescript and SolidJS?
24 Replies
That usually happens when the browser doesn't support the api
usually you can do something like
yes, this is what i have done - i am using the newest version of Edge
i only get the error in VSCode - seems i do not have the types installed
do you know what types i need to install for devDeps?
i tried
dom-serial
- but that is outdated and doesn't work for the newest apimmm I don't think types need to be installed but I haven't used the serial api before
you can try this one
https://www.npmjs.com/package/@types/w3c-web-serial
npm
@types/w3c-web-serial
TypeScript definitions for w3c-web-serial. Latest version: 1.0.3, last published: 4 months ago. Start using @types/w3c-web-serial in your project by running
npm i @types/w3c-web-serial
. There are 7 other projects in the npm registry using @types/w3c-web-serial.Typescript is throwing a fit -
this is without any types installed
oh yeah I guess it might be because it's experimental
try the one I sent above
will do 🙂
this one has all of the right API methods - but none of the types are exported
How am i supposed to use this again? Sorry - iam still new.
I've installed it -and confirmed it's api
but i can't import it
nor use the types in a global sense
do i have to manually export the interfaces?
that seems wrong ... and wouldn't work if i put the code on github
mm good point, it might have been an issue on their end for not exporting
i might just have to maintain a local copy for the project xD
if you add
import 'w3c-web-serial'
to the top of the file I think works
🤔tried that
did you reload the ts server?
yeah
oof
I tried it and it worked
i think maybe it might be my eslint or tsconfig file
possibly
yeah, it's eslint
if i do this:
Then
ctrl + click
on the file import it takes me directly to the filenice
so, clearly i need to change some setting
but, its working now
That works - no erorrs, and i can see the methods and types
thank you very much 🙂
🎉
no problem 😄