Skip to content

Instantly share code, notes, and snippets.

@Willmo36
Last active February 6, 2024 20:28
Show Gist options
  • Save Willmo36/132e5fcc84f24fb94ce72dc0ca28e701 to your computer and use it in GitHub Desktop.
Save Willmo36/132e5fcc84f24fb94ce72dc0ca28e701 to your computer and use it in GitHub Desktop.
TypeScript Lambda@edge enforce Capitalized-Header-Keys
type CapKebabCase<S extends string> = S extends `${infer A}-${infer B}` ? `${Capitalize<A>}-${CapKebabCase<B>}` : Capitalize<S>;
declare function test<S extends string>(s: S & CapKebabCase<S>): void
test("hello-there")
test("Hello-there")
test("Hello-There")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment