I have the next import statement in my .ts file:
import { IRemoteAudioSource } from "js/Abstractions/Interfaces/AudioSource/IRemoteAudioSource";
Visual studio finds such file, no problems. But when i run my solution i get the error in console:
Uncaught TypeError: Failed to resolve module specifier "js/Abstractions/AbstractClasses/AudioModel". Relative references must start with either "/", "./", or "../".
And when I try to specify the relative path( import { IRemoteAudioSource } from "/js/Abstractions/Interfaces/AudioSource/IRemoteAudioSource";
), visual studio does not find such a file.
What am i doing wrong?
tsconfig.json:
{ "compileOnSave": true, "compilerOptions": { "target": "ES6", "module": "ES6", "sourceMap": false, "watch": false, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, "strictNullChecks": true }, "plugins": [ { "name": "tslint-language-service" } ] }
You have to import starting with "/". Always do a import with folders way.
Like you have to do as -
import { IRemoteAudioSource } from "./js/Abstractions/Interfaces/AudioSource/IRemoteAudioSource";
as error says.
I added this to compiler option
"paths": {
"/*": [ "./*" ]
},
and used relative path for import. These actions solved the problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.