Use the object's identifier type

tags: [[TypeScript]], [[Development]]

pid: 211117191049

Select the object's identifier type instead of using for example string when you have a function that should only take a specific identifier. This will make the code easier to refactor and also make it more evident what the function is expecting.
type Task = {
id: string

// This is fine, but might require refactoring if the id ever changes type
function getTask(id: string) {}

// Better alternative
function getTask(id: Task['id']) {}

Linked references