TypeScript संकलन करते समय चेतावनी "Experimental decorators"
सभी को नमस्कार! मैंने अभी TypeScript सीखना शुरू किया है और एक अजीब समस्या का सामना किया। मैं एक डेकोरेटर के साथ एक सरल क्लास लिख रहा हूँ, लेकिन संकलन करते समय मुझे चेतावनी मिलती है: "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 फ़ाइल में मेरे पास केवल बुनियादी सेटिंग्स हैं, मैंने डेकोरेटर के बारे में कुछ नहीं जोड़ा।