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

Improve the typing of ClientSettings

Open ghost91- opened this issue 3 years ago • 1 comments
trafficstars

In which branch or foundry version does the problem occur? main

Describe the wrong type The types for register are currently not correct. The connection between the type property and the returned and the stored type are not correct. Also, some of the types that are currently handled (such as bigint and symbol) straight up don't work and cause errors.

Expected behavior This should probably be simplified, so that we only allow the basic types boolean, number, string, Array<T>, ReadonlyArray<T>, T extends Record<string, unknown>, as these have clear correspondences to the type property (Boolean, Number, String, Array, Object). In theory, custom class constructors also work here, but not sure if that is even intended or if we should support it (it becomes weird because in set, you actually need to provide the value that's stringifiable, and that's the thing you get in onChange, not the instantiated class...).

Additional context https://discord.com/channels/170995199584108546/811676497965613117/943281494741352498

ghost91- avatar Feb 15 '22 23:02 ghost91-