Ошибка экспериментального декоратора в TypeScript
Получаю ошибку
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.
tsconfig.json
{
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
}
Настройки VsCode
Непосредственно код
import { Client } from 'discord.js';
import { DynamicMessage, OnReaction } from 'discord-dynamic-messages';
export class NumericEmojiMessage extends DynamicMessage {
private counter = 0;
@OnReaction(':one:')
public increment() {
this.counter = 1;
}
@OnReaction(':two:')
public decrement() {
this.counter = 2;
}
public render() {
return `Number: ${this.counter}`;
}
}
const client = new Client();
client.on('ready', () => {
client.on('message', (message) => {
if (message.channel !== null){
new NumericEmojiMessage().sendTo(message.channel);
}
});
});
client.login("Njg1MTA2MjQwNjgxOTM0OTcw.Xm-1HA.eRnzxS6hEB5Z7XoHLlTqjgsdqYk");
Ответы (1 шт):
Автор решения: Exploding Kitten
→ Ссылка
В tscofig.json добавьте:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
// ...
}
}
Ну или используйте, тот который лежит в репозитории: tsconfig.json.
Это необходимо из-за того, что для Method Decorator нужен PropertyDescriptor, который был добавлен только в ES5 (Docs).

