こんにちは私は最近のすべてのリリースでtypescript/jquery/webpackアプリを持っています。すべてがうまくいきます。 私はそれにaws-sdkを導入したかったのです。私は仕事をする '_'のような他のライブラリをインポートするために私が使ったパターンに従った。typescript/jquery/webpackアプリでaws-sdkを使用する
ERROR in .../code-projects/.../tsconfig.json
error TS2318: Cannot find global type 'Number'.
ERROR in .../code-projects/.../tsconfig.json
error TS2318: Cannot find global type 'Object'.
ERROR in .../code-projects/.../tsconfig.json
error TS2318: Cannot find global type 'RegExp'.
ERROR in .../code-projects/.../tsconfig.json
error TS2318: Cannot find global type 'String'.
が、私はその後、typescriptですためaws-sdk instructionsに従っ:私はそれを実行するために行くときに何が起こるか
import * as _ from '../node_modules/lodash-es/lodash';
は、私はこのようなエラーの束を取得することです。
と同じ結果です。
輸入私たちは以下の通りです:
import * as AWS from '../node_modules/aws-sdk/dist/aws-sdk';
とwebstormは文句はありませんし、オートコンプリート作品。
これが役立つ場合は、私のwebpackが含まれています。
質問:このタイプのフレームワークにaws-sdkを含める適切な方法は何ですか。
const webpack = require('webpack');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: [
"bootstrap-webpack",
'./src/index.ts'
],
module: {
rules: [
// the url-loader uses DataUrls.
// the file-loader emits files.
{
test: /\.html$/,
loader: 'raw-loader',
options: {
minimize: true
}
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{test: require.resolve("jquery"), use: "imports-loader?$=jquery"},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream'},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'},
{
test: /\.png$/,
exclude: /node_modules/,
loader: 'url-loader'
},
{
test: /\.gif/,
exclude: /node_modules/,
loader: 'url-loader'
},
{
test: /\.jpg/,
exclude: /node_modules/,
loader: 'url-loader'
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: "style-loader!css-loader"
},
{test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/},
{
test: /.json$/,
loaders: ['json']
}
]
},
resolve: {
extensions: ['.js', '.ts']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
hash: true
}),
new webpack.LoaderOptionsPlugin({
debug: true
}),
new CleanWebpackPlugin(['dist/*.*'], {})
]
};