microsoft / TypeScript-DOM-lib-generator

Tool for generating dom related TypeScript and JavaScript library files
Apache License 2.0
617 stars 418 forks source link

@types/audioworklet + DOM API #1574

Open h-a-n-n-e-s opened 1 year ago

h-a-n-n-e-s commented 1 year ago

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.

saschanaz commented 1 year ago

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

h-a-n-n-e-s commented 1 year ago

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.

saschanaz commented 1 year ago

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?

h-a-n-n-e-s commented 1 year ago

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 commented 1 year ago

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?

Krivega commented 1 year ago

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

h-a-n-n-e-s commented 1 year ago

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.)