Menu

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

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

DEV Community·Orinda Felix Ochieng·6 months ago
#veBP8Zx7
#kickjs#typescript#types#roles#module
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.…

Continue reading — create a free account

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