I have this function:
function getProduct(id: string){
//return some product
}
where id is actually GUID. Typescript doesn't have guid type. Is it possible create type GUID
manually?
function getProduct(id: GUID){
//return some product
}
so if instead 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
will be some 'notGuidbutJustString'
then I will see typescript compilation error.
Update: as David Sherret said: there is no way to ensure a string value based on regex or some other function at compile time but it is possible do all the checks in one place at run time.
type Guid = string;
– Hazardous