Reputation: 5149
The raven documentation for Angular 2 mentions the following es6 code snippet:
import Raven = require('raven-js'); // NOTE: "require" not "from"
They explicitly mentioned the require however I am not sure what this statement actually does and where it is documented.
Upvotes: 2
Views: 650
Reputation: 29814
import Raven = require('raven-js');
is the original Typescript import syntax.
The new ES6 style import is now preferred (since TS 1.5)
import * as Raven from 'raven-js'
These two syntaxes import an external library/module for which type definitions must be available, either as separate definition files referenced in tsconfig.json
or as part of the library with a reference to them in the typings
entry of its package.json
(the ///<reference
syntax should be avoided).
Please note that, in a 'require' environment, such as commonjs,
const Raven = require('raven-js');
will make Raven
available to the rest of the code as any
(i.e. definitions will not be imported). This may be handy when trying to use a JS library for which you do not have (or do do want to craft) the definitions.
Upvotes: 1