Menu

Type-Safe Augmentation Patterns in KickJS — ContextMeta, AuthUser, PolicyRegistry
📰
0

Type-Safe Augmentation Patterns in KickJS — ContextMeta, AuthUser, PolicyRegistry

DEV Community·Orinda Felix Ochieng·about 1 month ago
#veBP8Zx7
Reading 0:00
15s threshold

Decorator decorations are unsound until you augment. @Roles('owner', 'admin') looks like it is type-checked — it is not, until you tell TypeScript what AuthUser['roles'] actually is. ctx.get('tenant') looks like it returns a tenant — it does not, until you tell ContextMeta that 'tenant' is a key. @Can('delete', 'invoice') looks like a permission check — but until PolicyRegistry knows about 'invoice' , both arguments are just string . KickJS v5 ships these three interfaces deliberately empty so each adopter can fill them in, and the framework's helper types pivot on whether you have. This article walks the three augmentation surfaces, the catalogue-only defineAugmentation() helper, and the file-organisation rules — generically, with minimal examples.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More