Closed AlexBeauchemin closed 3 years ago
@oculus42 Sorry for the delay, but yes you were right we should be able to differentiate a uuid from a short uuid based on the type.
So I added another type for the short uuid SUUID
So no we can either use either string or UUID
as the type for a UUID
and string or SUUID
for a short uuid, which shouldn't break backward compatibility and would allow users to have stricter implementation in typescript instead of relying on the string
type and allowing a
to be considered as a UUID for example
ie:
import { generate, SUID } from 'short-uuid';
const newId = generate();
function create(id: SUID) { ... }
create(newId) // ok
create('abc') // error
Sorry for the delay, and thanks for the update. Merged!
Adding a
UUID
type so we can expect a uuid instead of a string using typescriptThis implementation extends string to keep backward compatibility, so this will continue working