Here is the tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"target": "es2017",
"outDir": "./js",
"rootDir": "./src",
"baseUrl": "./",
"incremental": true,
}
}
here is the tsconfig.build.json
:
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
Here is the package.json
:
{
"name": "",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "tsc --outDir js --downlevelIteration --target es5 src/main.ts",
"format": "prettier --write "src/**/*.ts" "test/**/*.ts"",
"lint": "eslint "{src}/**/*.ts" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@types/prompts": "^2.4.9",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"commander": "^12.1.0",
"kleur": "^4.1.5",
"prompts": "^2.4.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.1.0",
"typescript": "^4.7.4"
}
}
I’m getting the error in the title when I run npm run build
.
Full error:
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.
I tried updating node
and npm
.
~ node -v
~ v20.14.0
~ npm -v
~ 10.7.0
~ tsc --version
Version 5.4.5
What helped to compile the code without errors was adding the --experimentalDecorators
option. But why? What is wrong here?