Typescript: 2 Kompilierungsfehler erhalten

Erstellt am 25. Okt. 2018  ·  1Kommentar  ·  Quelle: microsoft/TypeScript

Erwartetes Verhalten:
Ich erwarte, dass mein Code fehlerfrei kompiliert wird
Und erwarten, dass die Importanweisung funktioniert

Tatsächliches Verhalten:
Wenn ich tsc app.ts ausführe, wird folgende Fehlermeldung angezeigt:
../node_modules/@types/bluebird/index.d.ts:750:72 - Fehler TS2583: Name 'Map' kann nicht gefunden werden. Müssen Sie Ihre Zielbibliothek ändern? Versuchen Sie, die Compileroption lib auf es2015 oder höher zu ändern.

750 statische Requisiten(Karte: Auflösbar>>): Bluebird>;
Spielplatz Link:

Ich erhalte auch einen weiteren Fehler in meinem Code-Editor:
Die Datei '/Users/harry.gothold/Documents/api-call-weather/src/app.ts' ist kein Modul.

Dies ist der Test, den ich ausführen möchte:
`
* als App aus '../src/app' importieren;
// importiere * als Chai von 'Chai';
// {result} aus '../app' importieren;
var chai = erfordern ('chai');
var sinon = erfordern ('sinon');
const await = chai.expect;

beschreiben ('Ergebnis', Funktion () {
it ('sollte mit weatherDescription aufgerufen werden', (done) => {
erwarten (Ergebnis) .zu.eventuell.gleich ('klarer Himmel');
getan();
});
}); `

Dies ist der ursprüngliche ts-Code:
`let request = require ('request');
lass versprechen = erfordern ('Bluebird');

Funktion getData () {
neues Versprechen zurückgeben ((Entschlossenheit: beliebig, Ablehnung: beliebig) => {
Anfrage ('https://api.openweathermap.org/data/2.5/forecast?id=2643743&APPID=99eaec08987344591490f9a6ee213155', {json: true},
(err: any, res: any, body: any) => {
auflösen (body.list [0] .weather [0] .description);
ablehnen (err, 'Entschuldigung, beim Abrufen der Daten ist ein Fehler aufgetreten');
});
});
};

Funktionsergebnis (Wetterbeschreibung: beliebig) {
console.log ( The weather today is ${weatherDescription} );
}}

Daten bekommen()
.then ((weatherDescription: any) => {
Ergebnis (Wetterbeschreibung)
})
.catch ((err: any) => {
werfen (err)
});

module.exports = {
getData: function () {},
Ergebnis: function () {}
} `

Und das ist meine tsconfig-Datei:
`{
"compilerOptions": {
/ * Grundlegende Optionen /"target": "es6", / Geben Sie die ECMAScript-Zielversion an: 'ES3' (Standard), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018' oder 'ESNEXT'. /."module": "commonjs", / Geben Sie die Generierung des Modulcodes an: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015' oder 'ESNext'. /."lib": ["es5", "es6", "dom"], / Geben Sie die Bibliotheksdateien an, die in die Kompilierung aufgenommen werden sollen. /.// "allowJs": true, / Ermöglicht das Kompilieren von Javascript-Dateien. /.// "checkJs": true, / Fehler in .js-Dateien melden. /.// "jsx": "bewahren", / JSX-Codegenerierung /.// "Deklaration": true, / Erzeugt die entsprechende '.d.ts'-Datei. /.// " declareMap /.// "sourceMap": true, / Erzeugt die entsprechende '.map'-Datei. /.// "outFile": "./", / Verkettet und gibt die Ausgabe an eine einzelne Datei aus. /.// "outDir": "./", / Umleitungsstruktur in das Verzeichnis /.// "rootDir": "./", / Geben Sie das Stammverzeichnis der Eingabedateien an. Verwenden Sie diese Option, um die Struktur des Ausgabeverzeichnisses mit --outDir zu steuern. /.// "zusammengesetzt": true, / Projektzusammenstellung aktivieren /// "removeComments": true, / Keine Kommentare zur Ausgabe ausgeben. /.// "noEmit": true, / Keine Ausgaben ausgeben. /.// "importHelpers": true, / Import emitiert Helfer von 'tslib'. /.// "downlevelIteration": true, / Bietet volle Unterstützung für Iterables in 'for-of', Spread und Destructuring, wenn Sie auf 'ES5' oder 'ES3' abzielen. /.// "isolationModules": true, / Transpile jede Datei als separates Modul (ähnlich wie '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

>Alle Kommentare

Bitte richten Sie Fragen wie diese an Stack Overflow.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

DanielRosenwasser picture DanielRosenwasser  ·  3Kommentare

jbondc picture jbondc  ·  3Kommentare

MartynasZilinskas picture MartynasZilinskas  ·  3Kommentare

manekinekko picture manekinekko  ·  3Kommentare

blendsdk picture blendsdk  ·  3Kommentare