Hata: TypeScript'ten JavaScript'e göreli yol ile ilgili modül bulunamıyor
Otomasyon testimizde Protractor'ı Typescript ile kullanıyoruz. Bu nedenle görece yoldan kaçınmak istiyoruz. Bu yüzden Typescript'te görece yolu çözmek için baseURL ve Path kullanıyoruz ve derleme sorunsuz şekilde gerçekleşiyor.
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"declaration": false,
"removeComments": false,
"noImplicitAny": false,
"emitDecoratorMetadata":true,
"experimentalDecorators": true,
"outDir": "jsout",
"types": ["jasmine", "node"],
"allowJs": true,
"baseUrl": ".",
"paths": {
"factory/*":["factories/*"]
}
import{FactoryRegistry} from 'factory/FactoryRegistry.ts'
However, when we are running our spec file, the run time error is thrown
E/launcher - Error: Error: Cannot find module 'factory/FactoryRegistry.ts'
Bunun nedeni, TS Spec dosyasında çözümlenen yolun JS Spec dosyasında çözümlenmemesidir. JS spec dosyasında bunun gibi bir şey yazıyor
var FactoryRegistry_ts_1 = require("factory/FactoryRegistry.ts");
"./../../../factories/FactoryRegistry" yerine
Peki bunu TS'den JS'ye çevirirken nasıl çözebiliriz