TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

@types/audioworklet + DOM API

Open h-a-n-n-e-s opened this issue 2 years ago • 7 comments

Is there a proper way to use @types/audioworklet while keeping "lib": ["DOM",...] ? (In the installation notes it says: Update your tsconfig.json to avoid clashing with the DOM APIs... You should remove "dom")

For doing front-end development while using AudioWorkletProcessor that would be really helpful.

h-a-n-n-e-s avatar Jun 17 '23 04:06 h-a-n-n-e-s

What's the use case here? Are you creating a script that works as a normal script and also as a worklet script?

saschanaz avatar Jun 19 '23 14:06 saschanaz

I'm writing a web app (that's what I need the DOM for) which uses webAudio including the AudioWorkletProcessor class. The types of that class are unknown by default (I wonder why?) so I have to use a JS file to make use of the class. I would like to use TS for that class as well.

h-a-n-n-e-s avatar Jun 19 '23 15:06 h-a-n-n-e-s

That doesn't answer the question. Can you move your worklet script to a subdirectory and add another tsconfig.json to apply another set of lib? Why would you need both in one tsconfig?

saschanaz avatar Jun 19 '23 18:06 saschanaz

Ok, that would be a solution. I didn't know that one can have more than one tsconfig.json, so I did some search and found this feature "project references". Do you mean that? I hope there is another way, because I just spent an hour trying to get this "references" thing to work, but it doesn't. (For example, I get this problem)

h-a-n-n-e-s avatar Jun 20 '23 15:06 h-a-n-n-e-s

So I guess it is only possible with "project references".

Coming back to the original issue, I just tried to add @types-audioworklet without deleting "DOM" from "lib" in the (one and only) tsconfig.json and everything works fine!

Could somebody give an example of how a "clashing with the DOM APIs" could happen?

h-a-n-n-e-s avatar Jun 21 '23 08:06 h-a-n-n-e-s

So I guess it is only possible with "project references".

Coming back to the original issue, I just tried to add @types-audioworklet without deleting "DOM" from "lib" in the (one and only) tsconfig.json and everything works fine!

Could somebody give an example of how a "clashing with the DOM APIs" could happen?

"lib": ["DOM", "ESNext"],
"compilerOptions": {
    "types": [ "audioworklet"]
  },

image

Krivega avatar Sep 06 '23 12:09 Krivega

Sorry for asking very basic questions, but why do I need "types": [ "audioworklet"] in "compilerOptions"? For me everything works fine without it. (And with it nothing changes.)

h-a-n-n-e-s avatar Sep 08 '23 09:09 h-a-n-n-e-s