I am trying to move my NodeJs app from Java Script to TypeScript to take advantage of some of the avail benefits. But while doing so i fail at the most simple taks..
I have this simple code below in my index.ts file. I want to import express and then start a basic listener on the port from the config file.
import {express} from 'express'; import {config} from './config/config'; const app = express(); const http = require('http'); const secure = http.createServer(app).listen(config.port ,()=>{ console.log(`listening on Port ${config.port}`) })
when i run "npm run-script build" i get the below output
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const express_1 = require("express"); const config_1 = require("./config/config"); const app = express_1.express(); const http = require('http'); var secure = http.createServer(app).listen(config_1.config.port, () => { console.log(`listening on Port ${config_1.config.port}`); });
why does it prefix express and config with _1 ? The express_1.express seems to brake it. Hope someone can tell my why and how to avoid in future.
https://stackoverflow.com/questions/66978062/strange-behavior-when-converting-typescript-to-java-script April 07, 2021 at 08:17AM
没有评论:
发表评论