Я следовал инструкциям на этом сайте
, и он отлично работает.
Вы установили @ types / express как зависимость dev?
npm i --save-dev @types/express
my index.ts:
import express, {Application} from 'express';
const app: Application = express()
app.listen(5000, ()=>{
console.log('server runnning')
})
my tsconfig. json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
my tslint. json:
{
"defaultSeverity": "warning",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"trailing-comma": [ false ]
},
"rulesDirectory": []
}
и наконец, мой пакет. json
{
"name": "tsnjs",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
"build": "tsc",
"prestart": "npm run build",
"start": "node .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"@types/express": "^4.17.2",
"tslint": "^6.0.0",
"typescript": "^3.8.2"
}
}
узел -v v13.9.0