foundry-vtt-types icon indicating copy to clipboard operation
foundry-vtt-types copied to clipboard

Stored Documents, when put through `toObject` or `toJson`, drop the id exists validation

Open JPMeehan opened this issue 8 months ago • 0 comments

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>>();

JPMeehan avatar Jun 26 '24 23:06 JPMeehan