// Created on savesnippets.com ยท https://savesnippets.com/R2P1tgq1FnUzCR type Brand = T & { readonly __brand: B }; type UserId = Brand; type PostId = Brand; const asUserId = (s: string): UserId => s as UserId; const asPostId = (s: string): PostId => s as PostId; function deleteUser(id: UserId) { /* ... */ } const u = asUserId('abc'); const p = asPostId('xyz'); deleteUser(u); // โœ“ deleteUser(p); // โœ— Type 'PostId' is not assignable to 'UserId' deleteUser('raw'); // โœ— raw strings rejected