What is the best practice for this scenario:
I have created an Angular2 project using angular-cli
(i.e. using ng new
)
I want to include TypeScript types from definitely typed
For example, should I use typings to install the types? How do I make sure the types are included in the ng build
?
If you answer is that I should hack the webpack
settings somehow, please include how I would do that, since I only have the angular-cli.json
file
TypeScript is a primary language for Angular application development. It is a superset of JavaScript with design-time support for type safety and tooling.
Typings describes contract of libraries you use. This allows the TypeScript compiler that what you use exist (classes, properties, ...). You can install typings from a repository using the typings command or let the compiler find out them leveraging the strategy specified in the tsconfig.
Knowledge of TypeScript is helpful, but not required. Angular requires an active LTS or maintenance LTS version of Node.js. For information about specific version requirements, see the engines key in the package.json file. For more information on installing Node.js, see nodejs.org.
Angular is a modern framework built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. The Angular documentation not only supports TypeScript as a first-class citizen, but uses it as its primary language.
Angular-cli uses typescript 2.0, you just need to search for the typings on npm, say you want jquery types, just install them:
npm install --save @types/jquery
And that's it. More info here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With