← Back to TypeScript Course | Chapter 17: TypeScript Configuration | Lesson 6 of 7

Composite Projects की जानकारी

एक composite project composite: true के साथ configure किया जाता है ताकि TypeScript इसे एक project reference graph के हिस्से के रूप में उपयोग कर सके। Composite projects में stricter configuration requirements होती हैं और build information produce करती हैं जो TypeScript को dependencies manage करने में मदद करती है।
Syntax
typescript
{
  "compilerOptions": {
    "composite": true,
    "declaration": true
  }
}

composite Enable करना

composite को किसी project के compilerOptions में true सेट करें जब वह project किसी दूसरे project द्वारा reference किए जाने के लिए meant हो — यह वह flag है जो उस specific tsconfig.json के लिए project-reference behavior unlock करता है।

उदाहरण: Enabling composite

typescript
// tsconfig.json
// { "compilerOptions": { "composite": true } }
console.log("composite: true unlocks project-reference behavior for this config");

Composite और Declaration Files

Composite projects को आमतौर पर declaration output on चाहिए ताकि dependent projects original source files तक access चाहे बिना इनके public types देख और इनके against type-check कर सकें।

उदाहरण: Composite and Declaration Files

typescript
// tsconfig.json
// { "compilerOptions": { "composite": true, "declaration": true } }
console.log("Composite projects need declaration output for dependents to use");

Composite और rootDir

एक composite project के पास एक normal project से stricter source-file requirements होती हैं, तो एक clear rootDir define करना इसके output structure को किसी भी project के लिए जो इसे reference करता है उसके लिए predictable रखता है।

उदाहरण: Composite and rootDir

typescript
// tsconfig.json
// { "compilerOptions": { "composite": true, "rootDir": "src" } }
console.log("A clear rootDir keeps composite project output structure predictable");

References वाले Composite

Composite projects एक project-reference graph के building blocks हैं — हर एक एक self-contained unit है जिसे दूसरे projects अपने ही tsconfig.json में references array के through point कर सकते हैं।

उदाहरण: Composite with References

typescript
// consumer/tsconfig.json
// { "references": [{ "path": "../composite-lib" }] }
console.log("Composite projects are the buildable units other projects reference");

Incremental Builds

Composite projects TypeScript की incremental build information के साथ naturally काम करते हैं, tsc -b को उन projects को rebuild करना skip करने देते हुए जिनका source पिछले build के बाद नहीं बदला, जो बड़े monorepos में काफी speed up करता है।

उदाहरण: Incremental Builds

typescript
// tsc -b   (skips projects whose source hasn't changed)
console.log("Composite projects enable fast incremental builds in monorepos");
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. declaration के बिना composite on करना, या include से files छोड़ना, जो files list न होने के बारे में errors का कारण बनता है।
  2. rootDir गलत सेट करना ताकि इसके बाहर की files compile error का कारण बनें।
  3. No references वाले एक standalone project में composite उपयोगी होने की उम्मीद करना।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.