When working with Typescript, I am utilizing the import function following the instructions provided at:
https://github.com/Microsoft/TypeScript/issues/12933
My implementation looks like this:
import("../myScriptToBeImported").then((module) => {
this.dosomethingWithModule(module);
}).catch(this.doSomethingWithError.bind(this));
I am integrating this into an MVC project in Visual Studio with Webpack. Even though Webpack successfully compiles the Typescript and the project runs smoothly, Visual Studio constantly displays the following errors for the code above:
- 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.
The version of Typescript being used is 2.4.2. How can these errors be resolved?
In case it helps, here is a look at my tsconfig file:
{
"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
}