How to compile typescript to JavaScript

Viewed 36

I have a .ts file in which there are imports referring to sibling files as follows,

 import { settings } from "../rc-apps-chat-api/config/Settings1";
 import { UrgencyEndpoints } from "./endpoints/UrgencyEndpoints";
 import { appActionButtonHandler } from "./handler/actionButtonHandler";
 import { appPostLivechatRoomClosed } from "./handler/postLivechatRoomClosed";
 import { appPostMessageSent } from "./handler/postMessageSent";
 import { appPreMessageSentPrevent } from "./handler/preMessageSentPrevent";
 import { onSettingUpdated } from "./handler/onSettingUpdated";

When I build the code then, it throws the following error,

 RcAppsChatApp.js:9:38: error: Could not resolve "./handler/actionButtonHandler"
9 │ const actionButtonHandler_1 = require("./handler/actionButtonHandler");
  ╵                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> RcAppsChatApp.js:10:41: error: Could not resolve "./handler/postLivechatRoomClosed"
10 │ const postLivechatRoomClosed_1 = require("./handler/postLivechatRoomClosed");
   ╵                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> RcAppsChatApp.js:11:34: error: Could not resolve "./handler/postMessageSent"
11 │ const postMessageSent_1 = require("./handler/postMessageSent");
   ╵                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~

> RcAppsChatApp.js:12:40: error: Could not resolve "./handler/preMessageSentPrevent"
12 │ const preMessageSentPrevent_1 = require("./handler/preMessageSentPrevent");
   ╵                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I thought the import statement in JS is being converted to require in JS and referring to a module. Though the path is correct still it does not find the path and failing to build (I am using Windows OS). Can anyone please help. Thanks.

0 Answers
Related