-
Notifications
You must be signed in to change notification settings - Fork 568
Open
Description
Description
Puck exposes many types in a way that is simple to use from a user’s perspective. However, this relies on a lot of advanced type definitions and TypeScript features, which can easily break if not handled carefully.
Currently, whenever there is a type change, we need to manually verify that the types behave as expected from the user’s point of view. This process involves many variations and edge cases that can be easily overlooked.
Because of this, it would be valuable to have some kind of compilation testing to verify that types behave as expected in all scenarios (e.g., required fields are enforced, unions work correctly, types widen or narrow when they should, etc.).
For example, we should be able to test the following:
import { Config } from "@measured/puck";
// Given:
type Components = { List: { items: { text: string }[] } };
// When:
const config: Config<{
components: Components;
}> = {
components: {
List: {
fields: {
items: {
type: "array",
arrayFields: {} // Then: Should throw an error since "text" isn't defined
}
}
}
}
};
Considerations
- There might be existing libraries that can help with this.