I am trying to combine Angular1.5 + Typescript. Installed required types:
npm install @types/angularjs
but still see the error:
TS2307 error: cannot find module 'angular'
Already tried different options:
import 'angular';
import 'angularjs'; //that is name inside @types
import angular from 'angularjs';
import * as angular from 'angular';
I use:
"ts-loader": "1.0.0",
"typescript": "2.0.7",
"webpack": "1.13.3",
"webpack-dev-server": "1.16.2"
tsconfig is pretty standard:
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": false,
"sourceMap": false,
"lib": ["es6", "dom"],
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules"]
}
already simplified webpack configuration as much as possible: var webpack = new require ('webpack');
module.exports = {
context: __dirname + '/src',
entry: './index.ts',
output: {
path: './dist',
filename: 'app.bundle.js'
},
module: {loaders: [{test: /\.tsx?$/, loader: 'ts-loader'},]},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js'],
},
plugins: [new webpack.NoErrorsPlugin()],
devtool: 'source-map',
devServer: {
contentBase: './dist',
historyApiFallback: true,
inline: true
}
};
And I also simplified index.ts to focus only on type import:
import * as angular from 'angular';
angular.module('testmodule', []);
UPD : tsconfig.json. Added typeRoots option.
Now we get new errors:
... / node_modules/@types/angularjs/angular -mocks.d.ts(6,26): TS2307: 'angular'.
... / node_modules/@types/angularjs/angular -mocks.d.ts(65,49): TS2304: "IServiceProvider".
... / node_modules/@types/angularjs/angular -mocks.d.ts(122,62): TS2304: "IScope".
... / node_modules/@types/angularjs/index.d.ts(66,43): TS2304: "JQuery".