advanced

Module augmentation

Расширение third-party declarations и reviewable global/module patches.

Module augmentation расширяет declarations другого module. Полезно, когда frameworks expose extension points — request properties, theme tokens, plugin hooks. Изменение global для type checking, поэтому patches должны быть small, documented и близко к integration.

Incorrect augmentation может пройти type checking, хотя runtime objects still lack property. Ambient declarations могут leak в unrelated code.

На интервью: объясняйте на конкретном примере и называйте, что проверяют в production code.

Типовые ошибки: путать похожие API и забывать edge cases в live coding.

Компромисс часто между ясностью и безопасностью или expressiveness и maintainability. Чеклист:

  • Только real extension points.
  • Declarations рядом с integration.
  • Подтвердите runtime shape.