हिन्दी

रनटाइम त्रुटियों को रोकने और मजबूत, अनुमानित जावास्क्रिप्ट अनुप्रयोगों के लिए ऑब्जेक्ट टाइप सुरक्षा बढ़ाने के लिए टाइपस्क्रिप्ट की अतिरिक्त प्रॉपर्टी जाँच में महारत हासिल करें।

टाइपस्क्रिप्ट अतिरिक्त प्रॉपर्टी जाँच: आपकी ऑब्जेक्ट टाइप सुरक्षा को मजबूत करना

आधुनिक सॉफ्टवेयर डेवलपमेंट के क्षेत्र में, खासकर जावास्क्रिप्ट के साथ, आपके कोड की अखंडता और पूर्वानुमेयता सुनिश्चित करना सर्वोपरि है। जबकि जावास्क्रिप्ट अपार लचीलापन प्रदान करता है, यह कभी-कभी अप्रत्याशित डेटा संरचनाओं या प्रॉपर्टी बेमेल के कारण रनटाइम त्रुटियों का कारण बन सकता है। यहीं पर टाइपस्क्रिप्ट चमकता है, जो स्थिर टाइपिंग क्षमताएं प्रदान करता है जो उत्पादन में प्रकट होने से पहले कई सामान्य त्रुटियों को पकड़ लेता है। टाइपस्क्रिप्ट की सबसे शक्तिशाली लेकिन कभी-कभी गलत समझी जाने वाली विशेषताओं में से एक इसकी अतिरिक्त प्रॉपर्टी जाँच है।

यह पोस्ट टाइपस्क्रिप्ट की अतिरिक्त प्रॉपर्टी जाँच में गहराई से उतरती है, यह समझाती है कि वे क्या हैं, वे ऑब्जेक्ट टाइप सुरक्षा के लिए क्यों महत्वपूर्ण हैं, और अधिक मजबूत और अनुमानित अनुप्रयोगों के निर्माण के लिए उनका प्रभावी ढंग से लाभ कैसे उठाया जाए। हम विभिन्न परिदृश्यों, सामान्य नुकसानों और सर्वोत्तम प्रथाओं का पता लगाएंगे ताकि दुनिया भर के डेवलपर्स को उनकी पृष्ठभूमि की परवाह किए बिना, इस महत्वपूर्ण टाइपस्क्रिप्ट तंत्र का उपयोग करने में मदद मिल सके।

मूल अवधारणा को समझना: अतिरिक्त प्रॉपर्टी जाँच क्या हैं?

इसके मूल में, टाइपस्क्रिप्ट की अतिरिक्त प्रॉपर्टी जाँच एक कंपाइलर तंत्र है जो आपको किसी ऑब्जेक्ट लिटरल को ऐसे वेरिएबल को असाइन करने से रोकता है जिसका प्रकार स्पष्ट रूप से उन अतिरिक्त प्रॉपर्टीज की अनुमति नहीं देता है। सरल शब्दों में, यदि आप एक ऑब्जेक्ट लिटरल परिभाषित करते हैं और इसे एक विशिष्ट प्रकार की परिभाषा (जैसे इंटरफ़ेस या टाइप एलियास) वाले वेरिएबल को असाइन करने का प्रयास करते हैं, और उस लिटरल में परिभाषित प्रकार में घोषित नहीं की गई प्रॉपर्टीज हैं, तो टाइपस्क्रिप्ट इसे संकलन के दौरान एक त्रुटि के रूप में चिह्नित करेगा।

आइए एक बुनियादी उदाहरण के साथ स्पष्ट करें:


interface User {
  name: string;
  age: number;
}

const newUser: User = {
  name: 'Alice',
  age: 30,
  email: 'alice@example.com' // Error: Object literal may only specify known properties, and 'email' does not exist in type 'User'.
};

इस स्निपेट में, हम `User` नामक एक `interface` को दो प्रॉपर्टीज के साथ परिभाषित करते हैं: `name` और `age`। जब हम एक अतिरिक्त प्रॉपर्टी, `email` के साथ एक ऑब्जेक्ट लिटरल बनाने का प्रयास करते हैं, और इसे `User` के रूप में टाइप किए गए एक वेरिएबल को असाइन करते हैं, तो टाइपस्क्रिप्ट तुरंत बेमेल का पता लगाता है। `email` प्रॉपर्टी एक 'अतिरिक्त' प्रॉपर्टी है क्योंकि यह `User` इंटरफ़ेस में परिभाषित नहीं है। यह जाँच विशेष रूप से तब की जाती है जब आप असाइनमेंट के लिए एक ऑब्जेक्ट लिटरल का उपयोग करते हैं।

अतिरिक्त प्रॉपर्टी जाँच क्यों महत्वपूर्ण हैं?

अतिरिक्त प्रॉपर्टी जाँच का महत्व आपके डेटा और उसकी अपेक्षित संरचना के बीच एक अनुबंध को लागू करने की उनकी क्षमता में निहित है। वे कई महत्वपूर्ण तरीकों से ऑब्जेक्ट टाइप सुरक्षा में योगदान करते हैं:

अतिरिक्त प्रॉपर्टी जाँच कब लागू होती हैं?

यह समझना महत्वपूर्ण है कि टाइपस्क्रिप्ट किन विशिष्ट परिस्थितियों में इन जाँचों को करता है। वे मुख्य रूप से ऑब्जेक्ट लिटरल्स पर लागू होते हैं जब उन्हें किसी वेरिएबल को असाइन किया जाता है या किसी फ़ंक्शन में एक तर्क के रूप में पारित किया जाता है।

परिदृश्य 1: वेरिएबल्स को ऑब्जेक्ट लिटरल्स असाइन करना

जैसा कि ऊपर `User` उदाहरण में देखा गया है, एक अतिरिक्त प्रॉपर्टी वाले ऑब्जेक्ट लिटरल का सीधे एक टाइप किए गए वेरिएबल को असाइनमेंट जाँच को ट्रिगर करता है।

परिदृश्य 2: फ़ंक्शंस को ऑब्जेक्ट लिटरल्स पास करना

जब कोई फ़ंक्शन एक विशिष्ट प्रकार के तर्क की अपेक्षा करता है, और आप एक ऑब्जेक्ट लिटरल पास करते हैं जिसमें अतिरिक्त प्रॉपर्टीज होती हैं, तो टाइपस्क्रिप्ट इसे चिह्नित करेगा।


interface Product {
  id: number;
  name: string;
}

function displayProduct(product: Product): void {
  console.log(`Product ID: ${product.id}, Name: ${product.name}`);
}

displayProduct({
  id: 101,
  name: 'Laptop',
  price: 1200 // Error: Argument of type '{ id: number; name: string; price: number; }' is not assignable to parameter of type 'Product'.
             // Object literal may only specify known properties, and 'price' does not exist in type 'Product'.
});

यहाँ, `displayProduct` को पास किए गए ऑब्जेक्ट लिटरल में `price` प्रॉपर्टी एक अतिरिक्त प्रॉपर्टी है, क्योंकि `Product` इंटरफ़ेस इसे परिभाषित नहीं करता है।

अतिरिक्त प्रॉपर्टी जाँच कब लागू *नहीं* होती हैं?

यह समझना कि ये जाँच कब दरकिनार की जाती हैं, भ्रम से बचने और यह जानने के लिए समान रूप से महत्वपूर्ण है कि आपको वैकल्पिक रणनीतियों की आवश्यकता कब हो सकती है।

1. असाइनमेंट के लिए ऑब्जेक्ट लिटरल्स का उपयोग न करने पर

यदि आप एक ऐसे ऑब्जेक्ट को असाइन करते हैं जो ऑब्जेक्ट लिटरल नहीं है (उदाहरण के लिए, एक वेरिएबल जिसमें पहले से ही एक ऑब्जेक्ट है), तो अतिरिक्त प्रॉपर्टी जाँच को आमतौर पर दरकिनार कर दिया जाता है।


interface Config {
  timeout: number;
}

function setupConfig(config: Config) {
  console.log(`Timeout set to: ${config.timeout}`);
}

const userProvidedConfig = {
  timeout: 5000,
  retries: 3 // This 'retries' property is an excess property according to 'Config'
};

setupConfig(userProvidedConfig); // No error!

// Even though userProvidedConfig has an extra property, the check is skipped
// because it's not an object literal being directly passed.
// TypeScript checks the type of userProvidedConfig itself.
// If userProvidedConfig was declared with type Config, an error would occur earlier.
// However, if declared as 'any' or a broader type, the error is deferred.

// A more precise way to show the bypass:
let anotherConfig;

if (Math.random() > 0.5) {
  anotherConfig = {
    timeout: 1000,
    host: 'localhost' // Excess property
  };
} else {
  anotherConfig = {
    timeout: 2000,
    port: 8080 // Excess property
  };
}

setupConfig(anotherConfig as Config); // No error due to type assertion and bypass

// The key is that 'anotherConfig' is not an object literal at the point of assignment to setupConfig.
// If we had an intermediate variable typed as 'Config', the initial assignment would fail.

// Example of intermediate variable:
let intermediateConfig: Config;

intermediateConfig = {
  timeout: 3000,
  logging: true // Error: Object literal may only specify known properties, and 'logging' does not exist in type 'Config'.
};

पहले `setupConfig(userProvidedConfig)` उदाहरण में, `userProvidedConfig` एक ऑब्जेक्ट रखने वाला एक वेरिएबल है। टाइपस्क्रिप्ट यह जाँचता है कि `userProvidedConfig` समग्र रूप से `Config` प्रकार के अनुरूप है या नहीं। यह `userProvidedConfig` पर ही सख्त ऑब्जेक्ट लिटरल जाँच लागू नहीं करता है। यदि `userProvidedConfig` को एक ऐसे प्रकार के साथ घोषित किया गया होता जो `Config` से मेल नहीं खाता, तो उसकी घोषणा या असाइनमेंट के दौरान एक त्रुटि होती। बाईपास इसलिए होता है क्योंकि ऑब्जेक्ट पहले से ही बनाया और एक वेरिएबल को असाइन किया गया है, फ़ंक्शन को पास करने से पहले।

2. टाइप एसर्शन

आप टाइप एसर्शन का उपयोग करके अतिरिक्त प्रॉपर्टी जाँच को दरकिनार कर सकते हैं, हालांकि यह सावधानी से किया जाना चाहिए क्योंकि यह टाइपस्क्रिप्ट की सुरक्षा गारंटियों को ओवरराइड करता है।


interface Settings {
  theme: 'dark' | 'light';
}

const mySettings = {
  theme: 'dark',
  fontSize: 14 // Excess property
} as Settings;

// No error here because of the type assertion.
// We are telling TypeScript: "Trust me, this object conforms to Settings."
console.log(mySettings.theme);
// console.log(mySettings.fontSize); // This would cause a runtime error if fontSize wasn't actually there.

3. टाइप डेफिनिशन में इंडेक्स सिग्नेचर या स्प्रेड सिंटैक्स का उपयोग करना

यदि आपका इंटरफ़ेस या टाइप एलियास स्पष्ट रूप से मनमानी प्रॉपर्टीज की अनुमति देता है, तो अतिरिक्त प्रॉपर्टी जाँच लागू नहीं होगी।

इंडेक्स सिग्नेचर का उपयोग:


interface FlexibleObject {
  id: number;
  [key: string]: any; // Allows any string key with any value
}

const flexibleItem: FlexibleObject = {
  id: 1,
  name: 'Widget',
  version: '1.0.0'
};

// No error because 'name' and 'version' are allowed by the index signature.
console.log(flexibleItem.name);

टाइप डेफिनिशन में स्प्रेड सिंटैक्स का उपयोग (सीधे जाँच को दरकिनार करने के लिए कम आम, संगत प्रकारों को परिभाषित करने के लिए अधिक):

हालांकि यह एक सीधा बाईपास नहीं है, स्प्रेडिंग मौजूदा प्रॉपर्टीज को शामिल करने वाले नए ऑब्जेक्ट बनाने की अनुमति देता है, और जाँच नए बने लिटरल पर लागू होती है।

4. मर्जिंग के लिए `Object.assign()` या स्प्रेड सिंटैक्स का उपयोग करना

जब आप ऑब्जेक्ट्स को मर्ज करने के लिए `Object.assign()` या स्प्रेड सिंटैक्स (`...`) का उपयोग करते हैं, तो अतिरिक्त प्रॉपर्टी जाँच अलग तरह से व्यवहार करती है। यह बनने वाले परिणामी ऑब्जेक्ट लिटरल पर लागू होती है।


interface BaseConfig {
  host: string;
}

interface ExtendedConfig extends BaseConfig {
  port: number;
}

const defaultConfig: BaseConfig = {
  host: 'localhost'
};

const userConfig = {
  port: 8080,
  timeout: 5000 // Excess property relative to BaseConfig, but expected by the merged type
};

// Spreading into a new object literal that conforms to ExtendedConfig
const finalConfig: ExtendedConfig = {
  ...defaultConfig,
  ...userConfig
};

// This is generally okay because 'finalConfig' is declared as 'ExtendedConfig'
// and the properties match. The check is on the type of 'finalConfig'.

// Let's consider a scenario where it *would* fail:

interface SmallConfig {
  key: string;
}

const data1 = { key: 'abc', value: 123 }; // 'value' is extra here
const data2 = { key: 'xyz', status: 'active' }; // 'status' is extra here

// Attempting to assign to a type that doesn't accommodate extras

// const combined: SmallConfig = {
//   ...data1, // Error: Object literal may only specify known properties, and 'value' does not exist in type 'SmallConfig'.
//   ...data2  // Error: Object literal may only specify known properties, and 'status' does not exist in type 'SmallConfig'.
// };

// The error occurs because the object literal formed by the spread syntax
// contains properties ('value', 'status') not present in 'SmallConfig'.

// If we create an intermediate variable with a broader type:

const temp: any = {
  ...data1,
  ...data2
};

// Then assign to SmallConfig, the excess property check is bypassed on the initial literal creation,
// but the type check on assignment might still occur if temp's type is inferred more strictly.
// However, if temp is 'any', no check happens until the assignment to 'combined'.

// Let's refine the understanding of spread with excess property checks:
// The check happens when the object literal created by the spread syntax is assigned
// to a variable or passed to a function that expects a more specific type.

interface SpecificShape { 
  id: number;
}

const objA = { id: 1, extra1: 'hello' };
const objB = { id: 2, extra2: 'world' };

// This will fail if SpecificShape doesn't allow 'extra1' or 'extra2':
// const merged: SpecificShape = {
//   ...objA,
//   ...objB
// };

// The reason it fails is that the spread syntax effectively creates a new object literal.
// If objA and objB had overlapping keys, the later one would win. The compiler
// sees this resulting literal and checks it against 'SpecificShape'.

// To make it work, you might need an intermediate step or a more permissive type:

const tempObj = {
  ...objA,
  ...objB
};

// Now, if tempObj has properties not in SpecificShape, the assignment will fail:
// const mergedCorrected: SpecificShape = tempObj; // Error: Object literal may only specify known properties...

// The key is that the compiler analyzes the shape of the object literal being formed.
// If that literal contains properties not defined in the target type, it's an error.

// The typical use case for spread syntax with excess property checks:

interface UserProfile {
  userId: string;
  username: string;
}

interface AdminProfile extends UserProfile {
  adminLevel: number;
}

const baseUserData: UserProfile = {
  userId: 'user-123',
  username: 'coder'
};

const adminData = {
  adminLevel: 5,
  lastLogin: '2023-10-27'
};

// This is where the excess property check is relevant:
// const adminProfile: AdminProfile = {
//   ...baseUserData,
//   ...adminData // Error: Object literal may only specify known properties, and 'lastLogin' does not exist in type 'AdminProfile'.
// };

// The object literal created by the spread has 'lastLogin', which isn't in 'AdminProfile'.
// To fix this, 'adminData' should ideally conform to AdminProfile or the excess property should be handled.

// Corrected approach:
const validAdminData = {
  adminLevel: 5
};

const adminProfileCorrect: AdminProfile = {
  ...baseUserData,
  ...validAdminData
};

console.log(adminProfileCorrect.userId);
console.log(adminProfileCorrect.adminLevel);

अतिरिक्त प्रॉपर्टी जाँच स्प्रेड सिंटैक्स द्वारा बनाए गए परिणामी ऑब्जेक्ट लिटरल पर लागू होती है। यदि इस परिणामी लिटरल में ऐसी प्रॉपर्टीज हैं जो लक्ष्य प्रकार में घोषित नहीं हैं, तो टाइपस्क्रिप्ट एक त्रुटि की रिपोर्ट करेगा।

अतिरिक्त प्रॉपर्टीज को संभालने की रणनीतियाँ

हालांकि अतिरिक्त प्रॉपर्टी जाँच फायदेमंद होती हैं, ऐसे वैध परिदृश्य भी हैं जहाँ आपके पास अतिरिक्त प्रॉपर्टीज हो सकती हैं जिन्हें आप शामिल करना या अलग तरह से संसाधित करना चाहते हैं। यहाँ सामान्य रणनीतियाँ हैं:

1. टाइप एलियास या इंटरफेस के साथ रेस्ट प्रॉपर्टीज

आप किसी भी शेष प्रॉपर्टी को कैप्चर करने के लिए टाइप एलियास या इंटरफेस के भीतर रेस्ट पैरामीटर सिंटैक्स (`...rest`) का उपयोग कर सकते हैं जो स्पष्ट रूप से परिभाषित नहीं हैं। यह इन अतिरिक्त प्रॉपर्टीज को स्वीकार करने और इकट्ठा करने का एक साफ-सुथरा तरीका है।


interface UserProfile {
  id: number;
  name: string;
}

interface UserWithMetadata extends UserProfile {
  metadata: {
    [key: string]: any;
  };
}

// Or more commonly with a type alias and rest syntax:
type UserProfileWithMetadata = UserProfile & {
  [key: string]: any;
};

const user1: UserProfileWithMetadata = {
  id: 1,
  name: 'Bob',
  email: 'bob@example.com',
  isAdmin: true
};

// No error, as 'email' and 'isAdmin' are captured by the index signature in UserProfileWithMetadata.
console.log(user1.email);
console.log(user1.isAdmin);

// Another way using rest parameters in a type definition:
interface ConfigWithRest {
  apiUrl: string;
  timeout?: number;
  // Capture all other properties into 'extraConfig'
  [key: string]: any;
}

const appConfig: ConfigWithRest = {
  apiUrl: 'https://api.example.com',
  timeout: 5000,
  featureFlags: {
    newUI: true,
    betaFeatures: false
  }
};

console.log(appConfig.featureFlags);

`[key: string]: any;` या इसी तरह के इंडेक्स सिग्नेचर का उपयोग मनमानी अतिरिक्त प्रॉपर्टीज को संभालने का मुहावरेदार तरीका है।

2. रेस्ट सिंटैक्स के साथ डीस्ट्रक्चरिंग

जब आप एक ऑब्जेक्ट प्राप्त करते हैं और बाकी को रखते हुए विशिष्ट प्रॉपर्टीज को निकालने की आवश्यकता होती है, तो रेस्ट सिंटैक्स के साथ डीस्ट्रक्चरिंग अमूल्य है।


interface Employee {
  employeeId: string;
  department: string;
}

function processEmployeeData(data: Employee & { [key: string]: any }) {
  const { employeeId, department, ...otherDetails } = data;

  console.log(`Employee ID: ${employeeId}`);
  console.log(`Department: ${department}`);
  console.log('Other details:', otherDetails);
  // otherDetails will contain any properties not explicitly destructured,
  // like 'salary', 'startDate', etc.
}

const employeeInfo = {
  employeeId: 'emp-789',
  department: 'Engineering',
  salary: 90000,
  startDate: '2022-01-15'
};

processEmployeeData(employeeInfo);

// Even if employeeInfo had an extra property initially, the excess property check
// is bypassed if the function signature accepts it (e.g., using an index signature).
// If processEmployeeData was typed strictly as 'Employee', and employeeInfo had 'salary',
// an error would occur IF employeeInfo was an object literal passed directly.
// But here, employeeInfo is a variable, and the function's type handles extras.

3. सभी प्रॉपर्टीज को स्पष्ट रूप से परिभाषित करना (यदि ज्ञात हो)

यदि आप संभावित अतिरिक्त प्रॉपर्टीज को जानते हैं, तो सबसे अच्छा तरीका यह है कि उन्हें अपने इंटरफ़ेस या टाइप एलियास में जोड़ें। यह सबसे अधिक टाइप सुरक्षा प्रदान करता है।


interface UserProfile {
  id: number;
  name: string;
  email?: string; // Optional email
}

const userWithEmail: UserProfile = {
  id: 2,
  name: 'Charlie',
  email: 'charlie@example.com'
};

const userWithoutEmail: UserProfile = {
  id: 3,
  name: 'David'
};

// If we try to add a property not in UserProfile:
// const userWithExtra: UserProfile = {
//   id: 4,
//   name: 'Eve',
//   phoneNumber: '555-1234'
// }; // Error: Object literal may only specify known properties, and 'phoneNumber' does not exist in type 'UserProfile'.

4. टाइप एसर्शन के लिए `as` का उपयोग करना (सावधानी के साथ)

जैसा कि पहले दिखाया गया है, टाइप एसर्शन अतिरिक्त प्रॉपर्टी जाँच को दबा सकते हैं। इसका उपयोग संयम से करें और केवल तभी करें जब आप ऑब्जेक्ट के आकार के बारे में बिल्कुल निश्चित हों।


interface ProductConfig {
  id: string;
  version: string;
}

// Imagine this comes from an external source or a less strict module
const externalConfig = {
  id: 'prod-abc',
  version: '1.2',
  debugMode: true // Excess property
};

// If you know 'externalConfig' will always have 'id' and 'version' and you want to treat it as ProductConfig:
const productConfig = externalConfig as ProductConfig;

// This assertion bypasses the excess property check on `externalConfig` itself.
// However, if you were to pass an object literal directly:

// const productConfigLiteral: ProductConfig = {
//   id: 'prod-xyz',
//   version: '2.0',
//   debugMode: false
// }; // Error: Object literal may only specify known properties, and 'debugMode' does not exist in type 'ProductConfig'.

5. टाइप गार्ड्स

अधिक जटिल परिदृश्यों के लिए, टाइप गार्ड्स प्रकारों को संकीर्ण करने और प्रॉपर्टीज को सशर्त रूप से संभालने में मदद कर सकते हैं।


interface Shape {
  kind: 'circle' | 'square';
}

interface Circle extends Shape {
  kind: 'circle';
  radius: number;
}

interface Square extends Shape {
  kind: 'square';
  sideLength: number;
}

function calculateArea(shape: Shape) {
  if (shape.kind === 'circle') {
    // TypeScript knows 'shape' is a Circle here
    console.log(Math.PI * shape.radius ** 2);
  } else if (shape.kind === 'square') {
    // TypeScript knows 'shape' is a Square here
    console.log(shape.sideLength ** 2);
  }
}

const circleData = {
  kind: 'circle' as const, // Using 'as const' for literal type inference
  radius: 10,
  color: 'red' // Excess property
};

// When passed to calculateArea, the function signature expects 'Shape'.
// The function itself will correctly access 'kind'.
// If calculateArea were expecting 'Circle' directly and received circleData
// as an object literal, 'color' would be an issue.

// Let's illustrate the excess property check with a function expecting a specific subtype:

function processCircle(circle: Circle) {
  console.log(`Processing circle with radius: ${circle.radius}`);
}

// processCircle(circleData); // Error: Argument of type '{ kind: "circle"; radius: number; color: string; }' is not assignable to parameter of type 'Circle'.
                         // Object literal may only specify known properties, and 'color' does not exist in type 'Circle'.

// To fix this, you can destructure or use a more permissive type for circleData:

const { color, ...circleDataWithoutColor } = circleData;
processCircle(circleDataWithoutColor);

// Or define circleData to include a broader type:

const circleDataWithExtras: Circle & { [key: string]: any } = {
  kind: 'circle',
  radius: 15,
  color: 'blue'
};
processCircle(circleDataWithExtras); // Now it works.

सामान्य नुकसान और उनसे कैसे बचें

अनुभवी डेवलपर्स भी कभी-कभी अतिरिक्त प्रॉपर्टी जाँच से भ्रमित हो सकते हैं। यहाँ सामान्य नुकसान हैं:

वैश्विक विचार और सर्वोत्तम अभ्यास

एक वैश्विक, विविध विकास परिवेश में काम करते समय, प्रकार सुरक्षा के आसपास सुसंगत प्रथाओं का पालन करना महत्वपूर्ण है:

निष्कर्ष

टाइपस्क्रिप्ट की अतिरिक्त प्रॉपर्टी जाँच मजबूत ऑब्जेक्ट टाइप सुरक्षा प्रदान करने की इसकी क्षमता का एक आधारशिला है। यह समझकर कि ये जाँच कब और क्यों होती हैं, डेवलपर्स अधिक अनुमानित, कम त्रुटि-प्रवण कोड लिख सकते हैं।

दुनिया भर के डेवलपर्स के लिए, इस सुविधा को अपनाने का मतलब है रनटाइम में कम आश्चर्य, आसान सहयोग, और अधिक रखरखाव योग्य कोडबेस। चाहे आप एक छोटी उपयोगिता या एक बड़े पैमाने पर उद्यम एप्लिकेशन का निर्माण कर रहे हों, अतिरिक्त प्रॉपर्टी जाँच में महारत हासिल करना निस्संदेह आपके जावास्क्रिप्ट परियोजनाओं की गुणवत्ता और विश्वसनीयता को बढ़ाएगा।

मुख्य बातें:

इन सिद्धांतों को सचेत रूप से लागू करके, आप अपने टाइपस्क्रिप्ट कोड की सुरक्षा और रखरखाव को महत्वपूर्ण रूप से बढ़ा सकते हैं, जिससे अधिक सफल सॉफ्टवेयर विकास परिणाम प्राप्त होंगे।

टाइपस्क्रिप्ट अतिरिक्त प्रॉपर्टी जाँच: आपकी ऑब्जेक्ट टाइप सुरक्षा को मजबूत करना | MLOG