Avatar ·

تحذير "Experimental decorators" عند تجميع TypeScript

مرحبًا بالجميع! لقد بدأت للتو في تعلم TypeScript وواجهت مشكلة غير مفهومة. أكتب فئة بسيطة مع decorator، ولكن عند التجميع أحصل على تحذير: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig.json' or 'jsconfig.json' to remove this warning." إليك الكود الخاص بي: ```typescript function log(target: any, key: string, descriptor: PropertyDescriptor) { const original = descriptor.value; descriptor.value = function(...args: any[]) { console.log(`استدعاء الطريقة ${key} مع الوسائط:`, args); return original.apply(this, args); }; return descriptor; } class Calculator { @log add(a: number, b: number): number { return a + b; } } const calc = new Calculator(); calc.add(2, 3); ``` أستخدم Visual Studio Code و TypeScript الإصدار 5.3.2. في ملف tsconfig.json لدي فقط الإعدادات الأساسية، ولم أضف أي شيء عن decorators.