Declaration Maps की जानकारी
In this page:
{
"compilerOptions": {
"declaration": true,
"declarationMap": true
}
}
Declaration Maps क्या करते हैं
जब declarationMap enable होता है, TypeScript specifically इसकी .d.ts declaration files के लिए source maps generate करता है, तो एक editor या debugger एक generated type declaration से सीधे original .ts source पर वापस jump कर सकता है।
उदाहरण: What Declaration Maps Do
// tsconfig.json
// { "compilerOptions": { "declaration": true, "declarationMap": true } }
console.log("declarationMap lets editors jump from .d.ts back to the original .ts");
Declaration Files
declaration compiler option वे .d.ts files generate करता है जो एक project की public type information describe करती हैं — यही वह है जो दूसरे TypeScript projects को आपके compiled JavaScript को import और type-check करने देता है।
उदाहरण: Declaration Files
// tsconfig.json
// { "compilerOptions": { "declaration": true } }
console.log("declaration generates the .d.ts files describing public types");
Libraries के लिए Declaration Maps
Library projects को declaration maps से विशेष रूप से फायदा होता है, क्योंकि एक imported type पर "go to definition" उपयोग करने वाले consumers इसके बिना एक readable original source के बजाय एक auto-generated .d.ts file में land होते।
उदाहरण: Declaration Maps for Libraries
// Without declarationMap, "go to definition" lands in generated .d.ts.
// With it, it lands in the original readable .ts source instead.
console.log("Library consumers benefit most from declaration maps");
Declaration Maps और Composite Projects
Declaration maps composite projects और project references के साथ naturally जुड़ते हैं, जहां generated declarations effectively एक project और इस पर depend करने वाले दूसरे project के बीच public interface boundary की तरह काम करती हैं।
उदाहरण: Declaration Maps and Composite Projects
// tsconfig.json
// { "compilerOptions": { "composite": true, "declaration": true, "declarationMap": true } }
console.log("Declarations act as the public interface boundary between projects");
Useful Library Configuration
एक well-configured library आमतौर पर declaration output, declaration maps, और regular source maps को साथ combine करती है, consumers को ऐसा code navigate और debug करने में एक smooth experience देते हुए जो उन्होंने नहीं लिखा।
उदाहरण: Useful Library Configuration
// tsconfig.json
// { "compilerOptions": { "declaration": true, "declarationMap": true, "sourceMap": true } }
console.log("Combining these three gives consumers a smooth debugging experience");
declaration: trueके बिनाdeclarationMapon करना, इसलिए map करने के लिए कोई.d.tsfiles exist नहीं करती।- Original
.tssources publish न करना, इसलिए map से "go to definition" के पास खोलने के लिए कुछ नहीं है। sourceMap(.jsके लिए) कोdeclarationMap(.d.tsके लिए) के साथ confuse करना।
tsconfig.jsoncontrol करता है कि compiler कैसे behave करता है, और strict mode options stronger checking enable करते हैं।- Module resolution और path aliases तय करते हैं कि imports कैसे ढूंढे जाते हैं और import paths कैसे छोटे किए जा सकते हैं।
- Project references, composite projects, और declaration maps बड़े codebases को organize और build करने में मदद करते हैं।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: