foundry-vtt-types
foundry-vtt-types copied to clipboard
Stored Documents, when put through `toObject` or `toJson`, drop the id exists validation
This test suite from tests/types/utils.test-d.ts
should all work, but it doesn't because the guarantee is stripped.
declare const storedUser: StoredDocument<User>;
expectTypeOf(storedUser.id).toEqualTypeOf<string>();
expectTypeOf(storedUser._id).toEqualTypeOf<string>();
expectTypeOf(storedUser._source._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toJSON()._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toJSON()._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toObject()._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toObject()._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toObject(false)._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.toObject(false)._id).toEqualTypeOf<string>();
expectTypeOf(storedUser.clone()).toEqualTypeOf<StoredDocument<User>>();