-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Export type definitions #48
Comments
By the way, ts-loader is awesome. I am so happy with webpack and ts-loader right now. This is the closest we have come to finally resolving our TS library issues! Thanks for all of your work! 😄 |
This is related to #45. Basically it probably wouldn't be crazy hard to support I'm open to exploring the simple case, but does that actually solve your problem? Also, thank you for the kind words 😁 |
I totally understand. Combining multiple external modules into a single file (module) is kind of a hairy problem no matter how you cut it. I agree, let's see how the TS team handles it first. I think this will ultimately only have value if we intended to code split and deploy the library dynamically to the client. At this point we'll probably be bundling it with the client (using webpack / ts-loader), so this won't be an issue. |
Resolution was to wait and see what the TypeScript team does with export of type definitions for external modules. |
@jbrantly I think supporting --declaration for now would be nice. At least then we can generate single .d.ts files, which with other modules can be combined into one. That would solve my use-case for now at least. |
I would like this as well. If I can just get access to the .d.ts EmitOutput from within a loader, I can output the .d.ts files myself. Simple loaders and plugins are so easy to write, I don't mind putting a few lines of code together, and you can still wait to implement proper .d.ts bundling. |
Yup, going to reopen this to track adding individual file .d.ts output so at least other tools can consume them. |
Great! |
This functionality has been merged to master. Please try it out and let me know how it works out. @cspotcode Just for fun I tried your scenario of accessing the .d.ts files from another loader. Unfortunately I was not successful. It seems that when a loader adds extra files to the output those files are not made available to other loaders. (if you dig deeper and figure out a way to do this I'd love to hear about it) |
@jbrantly tnx! I downloaded the master branch and succesfully got separate .d.ts output files. Could you publish this to npm? I played around a while with the different options of combining declaration files (like dts-generator), but ended up writing my own small WebpackPlugin in typescript because I want to combine the files in a certain way. It's defenitly not usable as-is for others, but if anyone wants to see how to do that check the npm library dacore-webpack-declarations Other usefull information in this context: Typescript 1.8 will support generating one single declaration file for certain types of modules. The combination of compiler options |
Apologies for the delay, this has been published in v0.8.0. |
I also tried it and it did generate the definitions 👍. However, I ran into one issue and wanted to see if you had thoughts on a fix. I like to create files that just have interface definitions that are shared and then import those definitions into the files that need the types. Alas, when I do that, no type definitions are generated for those files. Typescript correctly generates them using "declaration": true, but ts-loader is not. Perhaps ts-loader somehow sees no code is in the file and then does not generate the definition? Here's an example of a type only file:
Thoughts? Thanks! |
I'm also trying to generate definitions files for interfaces from ts-loader, but ran into the same problem. Had a look at the declaration-bundler-webpack-plugin by @flyon but don't see any interface files coming from the compiler 'emit' callback. Any suggestions? |
created issue (#174) and pull request (#175) for resolving missing d.ts files for interface objects referenced by @pillowsoft |
If I try to bundle a typescript project into a commonjs library for reuse, webpack with ts-loader will spit out beautiful javascript commonjs code for the library, but I have to use
tsc
in order to generate the declaration files.Have you considered trying to support export of type definitions next to a bundle via ts-loader?
For reference:
https://github.com/SonofNun15/typescript-library-test/blob/master/README.md
The text was updated successfully, but these errors were encountered: