Skip to content

Instantly share code, notes, and snippets.

@ehatricksmith
Created May 31, 2022 05:20
Show Gist options
  • Save ehatricksmith/c65de56e01316aac8fe9afb39494fab1 to your computer and use it in GitHub Desktop.
Save ehatricksmith/c65de56e01316aac8fe9afb39494fab1 to your computer and use it in GitHub Desktop.
/**
* Nominal typing for any TypeScript interface or class.
*
* If T is an enum type, any type which includes this interface
* will only match other types that are tagged with the same
* enum type.
*
* See <https://stackoverflow.com/a/37074697/253686>
*/
export interface Nominal<T> {
"nominal structural brand": T;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment