I need to declare uuid type in TypeScript/Angular.
I already had working solution, but my computer broke and I don’t remember what exactly I did.
I need two things:
- declare a type
- convert from string to that type
Maybe some changes at tsconfig.json are requried.
Here is the code:
`import {v4 as uuidv4} from ‘uuid’;
import { parse as parseUuid } from ‘uuid’;
export interface Feature {
id: uuidv4,
name: string
}
export const feature1: Feature = {
id: parseUuid(‘bd004be1-7b64-4c03-8f1a-2f1414d7e7f4’),
name: ‘Feature 1’
}`
Janusz Kowal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.