faust2webaudio
faust2webaudio copied to clipboard
hard coded reference to src in dist/index.d.ts
As far as I can understand, the dist folder contains everything to run Faust: it is self-contained from code and resource viewpoint. However, index.d.ts makes reference to the src folder, which makes the dist folder not sufficient for development.
In addition, dist/index.d.ts makes only imports from various files located in the src folder, which is not very declarative and more or less useless for the developer.
Could it be possible to have a 'real' interface e.g. a faust.d.ts file that declares all the public types and interfaces without reference to the src folder? (and hides internal dependencies) It seems it almost exists in the src files.
But maybe there are good reasons to proceed this way...
Related to this topic:
the html examples (from the test folder) make reference to Faust2WebAudio, which is not declared anywhere, apart from the webpack config file. You have first to find it (outside the dist and src folders), and next to look at src/index.ts to discover that it's a kind of namespace that covers the Faust and FaustAudioWorkletNode imports (if I'm right).
And of course, typescript complains about Faust2WebAudio type...
Hi @dfober
Actually, the dist/index.d.ts will be detected and used automatically when the package is installed as a NPM package:
import { Faust, FaustAudioWorkletNode, FaustScriptProcessorNode } from "faust2webaudio";
Here, as the src/ folder is also included in the NPM package, the imported types will be resolved. And no need to re-declare the Faust interface, which is redundant and harder to maintain.
It is also possible, I believe, to generate an .d.ts file that contains all the types by tsc --emitDeclarationOnly. But I don't feel necessary...
For the second question. The package is now wrapped as an UMD module, which means it will detect current environment and make the module work for. If the module is included in a <script />, It will expose Faust2WebAudio as its namespace (defined in webpack.config.js), if it is imported in a Node.js dev environment, There will be nothing exposed.
I'll try the import strategy. However, it doesn't solve my main problem: looking at the package, it's quite impossible to figure out what are the available types, classes et methods, unless I browse all the source code. Note also that I don't use webpack, only typescript.
I tried: tsc ./src/index.ts --emitDeclarationOnly -d --target ES6 will generate .d.ts file for each ts file.
Yes, I already tried... Thanks