Typescript: 2つのコンパイルエラーが発生する

作成日 2018年10月25日  ·  1コメント  ·  ソース: microsoft/TypeScript

期待される動作:
コードがエラーなしでコンパイルされることを期待しています
そして、インポートステートメントが機能することを期待しています

実際の動作:
tsc app.tsを実行すると、次のエラーが発生します。
../node_modules/@types/bluebird/index.d.ts:750:72-エラーTS2583:名前「マップ」が見つかりません。 ターゲットライブラリを変更する必要がありますか? libコンパイラオプションをes2015以降に変更してみてください。

750の静的小道具(マップ:解決可能>>):ブルーバード>;
遊び場リンク:

また、コードエディタで別のエラーが発生します。
ファイル '/Users/harry.gothold/Documents/api-call-weather/src/app.ts'はモジュールではありません。

これは私が実行しようとしているテストです:
`
import * as app from '../ src / app';
// 'chai'から*をchaiとしてインポートします;
//インポート{結果} from '../ app';
var chai = require( 'chai');
var sinon = require( 'sinon');
const expect = chai.expect;

describe( 'result'、function(){
it( 'weatherDescriptionで呼び出される必要があります'、(完了)=> {
expect(result).to.eventually.equal( 'clear sky');
done();
});
}); `

これは元のtsコードです:
`let request = require( 'request');
let promise = require( 'bluebird');

関数getData(){
新しいpromise((resolve:any、reject:any)を返す)=> {
request( 'https://api.openweathermap.org/data/2.5/forecast?id=2643743&APPID=99eaec08987344591490f9a6ee213155'、{json:true}、
(err:any、res:any、body:any)=> {
resolve(body.list [0] .weather [0] .description);
require(err、 '申し訳ありませんが、データのフェッチ中にエラーが発生しました');
});
});
};

関数result(weatherDescription:any){
console.log( The weather today is ${weatherDescription} );
}

getData()
.then((weatherDescription:any)=> {
結果(weatherDescription)
})
.catch((err:any)=> {
throw(err)
});

module.exports = {
getData:function(){}、
結果:function(){}
} `

そしてこれは私のtsconfigファイルです:
`{
"compilerOptions":{
/ *基本オプション/"target": "es6"、/ ECMAScriptターゲットバージョンを指定: 'ES3'(デフォルト)、 'ES5'、 'ES2015'、 'ES2016'、 'ES2017'、 'ES2018'または 'ESNEXT'。 /"module": "commonjs"、/モジュールコード生成を指定します: 'none'、 'commonjs'、 'amd'、 'system'、 'umd'、 'es2015'、または 'ESNext'。 /"lib":["es5"、 "es6"、 "dom"]、/コンパイルに含めるライブラリファイルを指定します。 /// "allowJs":true、/ javascriptファイルのコンパイルを許可します。 /// "checkJs":true、/。jsファイルのエラーを報告します。 /// "jsx": "preserve"、/ JSXコード生成を指定します: 'preserve'、 'react-native'、または 'react'。 /// "declaration":true、/対応する '.d.ts'ファイルを生成します。 /// "declarationMap":true、/対応する「.d.ts」ファイルごとにソースマップを生成します。 /// "sourceMap":true、/対応する '.map'ファイルを生成します。 /// "outFile": "./"、/出力を連結して単一のファイルに出力します。 /// "outDir": "./"、/出力構造をディレクトリにリダイレクトします。 /// "rootDir": "./"、/入力ファイルのルートディレクトリを指定します。 --outDirを使用して出力ディレクトリ構造を制御するために使用します。 /// "composite":true、/プロジェクトのコンパイルを有効にする/// "removeComments":true、/出力にコメントを出力しません。 /// "noEmit":true、/出力を出力しません。 /// "importHelpers":true、/インポートは 'tslib'からヘルパーを/// "downlevelIteration":true、/ 'ES5'または 'ES3'をターゲットにする場合、 'for-of'、spread、およびdestructuringの反復可能オブジェクトを完全にサポートします。 /// "isolatedModules":true、/各ファイルを個別のモジュールとしてトランスパイルします( 'ts.transpileModule'と同様)。 * /

/* Strict Type-Checking Options */
"strict": true,                           /* Enable all strict type-checking options. */
// "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true,              /* Enable strict null checks. */
// "strictFunctionTypes": true,           /* Enable strict checking of function types. */
// "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true,                /* Report errors on unused locals. */
// "noUnusedParameters": true,            /* Report errors on unused parameters. */
// "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
// "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [],                       /* List of folders to include type definitions from. */
// "types": [],                           /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "",                      /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "",                         /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */

}
} `

Question

>すべてのコメント

このような質問はStackOverflowに送信してください。

このページは役に立ちましたか?
0 / 5 - 0 評価