-
Notifications
You must be signed in to change notification settings - Fork 3
Known issues with NPM modules
- Libraries that use the
export =
syntax for exporting don't work in Typescript
workaround: add"allowSyntheticDefaultImports": true
to your tsconfig.json and import your libary using the syntaximport * as name from 'some-npm-module'
- The
awesome-typescript-loader
used in webpack builds and tests cannot correctly handle theconst enum
inlining, so the"preserveConstEnums"
should be set totrue
. We want to have them preserved anyways so consumers of the modules can import and use those enums.
- If you're using typescript, don't use the per-module packages, as they don't have proper typings available. Instead use the full lodash npm module and import using
import ... from 'lodash/module'
syntax. For typings see the tricks section below.
Sinon is not in our boilerplate by default but we will often include it for detecting function calls in unit tests.
- Sinon does not work well with webpack
workaround: use the sinon 2.0.0 prerelease
- karma-remap-istanbul (for source mapping in our test coverage report) fails on the first run with the following message:
WARN [reporter.remap-istanbul]: Could not find any specified files, exiting without doing anything.
When the output files are already there the error will disappear on the second run.
See: https://github.com/marcules/karma-remap-istanbul/issues/3
Typings have different sources for definitions. By default it fetches them from its own npm registry: https://github.com/typings/registry/tree/master/npm.
You could change source: typings install dt~[definition-name]
In this case Typings will fetch the latest definition file numbered version from DefinitelyTyped. Sometimes DefinitelyTyped is not consistent with version numbers, keeping the lastest version without any version number at all like lodash.d.ts
instead of lodash-4.0.0.d.ts
.
In these cases, if you want to load the latest updated definition file you need to specify a version number 0.0.0 like:
typings install dt~[definition-name]@0.0.0
(e.g: typings install [email protected]
)
Sometimes unit tests can be difficult to debug when an error occurs, because source maps for errors do not work yet. To debug the output JS, you can add karma as a run configuration in webstorm and run that configuration in debug mode. Make sure to turn on the breakpoint for all uncaught exceptions.