Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hard coded reference to src in dist/index.d.ts #10

Open
dfober opened this issue Jun 23, 2020 · 5 comments
Open

hard coded reference to src in dist/index.d.ts #10

dfober opened this issue Jun 23, 2020 · 5 comments

Comments

@dfober
Copy link
Member

dfober commented Jun 23, 2020

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

@dfober
Copy link
Member Author

dfober commented Jun 23, 2020

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

@Fr0stbyteR
Copy link

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.

@dfober
Copy link
Member Author

dfober commented Jun 24, 2020

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.

@Fr0stbyteR
Copy link

I tried: tsc ./src/index.ts --emitDeclarationOnly -d --target ES6 will generate .d.ts file for each ts file.

@dfober
Copy link
Member Author

dfober commented Jun 25, 2020

Yes, I already tried...
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants