This adds a new PersistedSpraypaintRecord type which extends any
record type, definining the id as string instead of the initial
string | undefined. This will allow any record retrieved from
finders to be correctly typed with a defined id. This should avoid the
need for a bunch of boilerplate type guards when dealing with records
which are always coming from from finders. You can also use this to
manually cast a record after you save it:
function createPerson(attrs): PersistedSpraypaintRecord<Person>
let person = new Person(attrs)
let success = await person.save()
if (success) {
person = person as PersistedSpraypaintRecord<Person>
} else {
// handle error
}
return person
}
This adds a new
PersistedSpraypaintRecord
type which extends any record type, definining the id asstring
instead of the initialstring | undefined
. This will allow any record retrieved from finders to be correctly typed with a defined id. This should avoid the need for a bunch of boilerplate type guards when dealing with records which are always coming from from finders. You can also use this to manually cast a record after you save it: