Skip to content

Instantly share code, notes, and snippets.

@wevertoum
Created July 13, 2023 14:26
Show Gist options
  • Save wevertoum/38393efec05a87cd3bd01bc5545ef0f0 to your computer and use it in GitHub Desktop.
Save wevertoum/38393efec05a87cd3bd01bc5545ef0f0 to your computer and use it in GitHub Desktop.
exemplo de tipos dinâmicos e funcionais em typescript
type ExampleProps = {
commonProp: string;
} & (
| {
tipoFile: "image";
resolution: "small" | "medium" | "large";
}
| {
tipoFile: "file";
format: ".pdf" | ".doc" | ".docx" | ".xls" | ".xlsx" | ".ppt" | ".pptx";
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment