... | ... | @@ -9,7 +9,7 @@ You want type enforcement in your javascript? Cuz this is how you get type enfor |
|
|
- _if_ this is not feasible for some reason, go ahead and use the `any` type, sparingly
|
|
|
|
|
|
#### Typings
|
|
|
Most any library has typings available, which will make the typescript compiler (tsc, webpack ts-loader, atom-typescript, etc) aware of necessary types. For example, defining types for global variables, like `setTimeout` or `_`
|
|
|
Most any library has typings available, which will make the typescript compiler (tsc, webpack ts-loader, atom-typescript, etc) aware of necessary types for objects imported from those libraries; i.e. the `_`object or `window`object
|
|
|
* these are kept in `<repo>/typings/` and listed in `typings.json`, so that when the npm postinstall script runs (see package.json), the `typings install` command has something to go off of, similar to the dependencies list in package.json
|
|
|
* to install a new typing and save it to typings.json at the same time, it looks like this: `typings install --save --global dt~lodash` (where lodash is the name of the particular typings package, in this case lodash. `global` doesn't mean the same thing it does with npm modules; you'll usually want the global flag when installing)
|
|
|
* the `declare` ts keyword is available for a variety of uses, including when there are issues with global variables
|
... | ... | |