Description
This question was first posted here: https://stackoverflow.com/questions/46827184/typescript-import-function-gets-compiler-error/46827260?noredirect=1#46827260
In my Typescript I am using the import function as described here:
#12933
So my code is like:
import("../myScriptToBeImported").then((module) => {this.dosomethingWithModule(module); }).catch(this.doSomethingWithError.bind(this));
I am running this as part of an MVC project in Visual Studio with Webpack. Webpack compiles the Typescript without any errors and the project runs fine, yet for the above line the following errors are always shown in Visual Studio:
- TS1128 (TS) Declaration or statement expected.
- TS2391 (TS) Function implementation is missing or not immediately following the declaration.
- TS7010 (TS) 'import', which lacks return-type annotation, implicitly has an 'any' return type.
I am using Typescript version 2.4.2. How can I get rid of these errors?
For information, my tsconfig file looks like this:
{ "compilerOptions": { "module": "esnext", "moduleResolution": "node", "noEmitOnError": true, "strict": true, "removeComments": false, "sourceMap": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es6", "dom" ], "baseUrl": ".", "experimentalDecorators": true, "emitDecoratorMetadata": true }, "exclude": [ "node_modules", "wwwroot" ], "compileOnSave": false, "buildOnSave": false }