-
Notifications
You must be signed in to change notification settings - Fork 0
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
Global Typings - can / should I add them to npm package? #24
Comments
Hey! Sorry for the delayed response, it's sometimes hard to get back to you when it's a huge question without a clear answer. As the module you want to type is not an external module, you can not use the |
No problem for delay, I'm just grateful you were able to given time pressures. So, basically I cheated by making my global type declaration "look like" an external module to the typescript compiler (my first point)! The trouble is that my cheat works in practice. The consumer can write: \\ import the AppInsights class
import { AppInsights } from "angular-cc-appinsights"; The compiler is satisfied. At runtime it also works. This is because the consumer will only ever use the type interfaces to declare the type of variables. The consumer will be an angular application and so angular will be injecting the actual instances of these types. Question: So my cheat works, but what negative consequences will I be inadvertently introducing? |
There's only really two issues:
There are some features in TypeScript 2.0 that may help you - such as being able to specify some types in |
Got it. The new features you're referring to, that looks like it obsoletes typings tool and maybe the typings registry. I also see that you've weighed in on some issues that discuss these proposals, for example microsoft/TypeScript#7125 and microsoft/TypeScript#9184 Questions:
|
You can probably find answers from me in other places, but basically:
|
OK, thanks for the heads up. BTW, useless platitudes of course, but thanks for all that you're doing to help sort out these painful areas of typescript. |
Not useless to me 😄 Thank you! |
I've published an npm package: angular-cc-appinsights.
The package is targeting front-end angular 1 developers and will therefore be loaded as a script tag from the the locally installed node_modules directory.
The package is written in typescript and compiled to JavaScript with declaration files.
Reading the examples of how to publish my typings, I seem to fall into both example 2 and 5.
I have gone with option 5: include in the npm package the compiled JS and declaration files.
I suspect packaging global typings might be wrong...
At first blush, this seems to be the right thing to do. Certainly when I go and install my package into an angular application written in typescript the typescript language service picks up my typings from the npm package.
However, I have a nagging feeling I'm not doing things correctly or at least not in keeping with the spirit of the typings project.
My doubts are two fold:
1. I had to manually amend the d.ts file produced to include:
2. My definitions expose dependencies from the angular (1) typings installed from definitely typed.
This I believe is a problem as I should somehow be describing which specific version of angular typings I'm depending on
Can you guys point me to the correct approach?
Thanks
Christian
The text was updated successfully, but these errors were encountered: