Мой проект построен на Nodejs с TypeScript
Я получаю эту ошибку компиляции в своем приложении Node.js:
E:\NodeProjects\esshop-mongodb-nodejs\node_modules\ts-node\src\index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
TSError: ⨯ Unable to compile TypeScript:
src/posts/post.dto.ts:5:10 - error TS1219: Experimental support for decorators is a feature that is
subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
5 public author: string;
источник/сообщения/post.dto.ts
import { IsString } from 'class-validator';
class CreatePostDto {
@IsString()
public author: string;
@IsString()
public content: string;
@IsString()
public title: string;
}
export default CreatePostDto;
мой tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"target": "ES6",
"outDir": "./dist",
"baseUrl": "./src",
"alwaysStrict": true,
"noImplicitAny": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Я установил последнюю версию: [ts-node, typescript]
репозиторий проекта на гитхабе: https://github.com/barrytestfl/esshop-mongodb-nodejs





Моя проблема решена путем изменения этих параметров в tsconfig.json:
"esModuleInterop": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true
Это сработало для меня
мой файл tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"target": "es2019",
"outDir": "./dist",
"baseUrl": "./src",
"alwaysStrict": true,
"noImplicitAny": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}