Skip to content

Commit

Permalink
🩹 Fix type error for keywords in metadata
Browse files Browse the repository at this point in the history
The type of the `info` property in the document definition combines the
`InfoProps` and `CustomInfoProps` types. This introduces a type conflict
as the type of the `keywords` property (`string[]`) conflicts with the
type of the values in `CustomInfoProps` (`string`). As a result, an
assignment of the `keywords` property results in a type error.

To fix this problem, we enforce the `XX` prefix for custom keys in the
`info` property, following the recommendation. This could be considered
a breaking change, however, it will only affect custom info attributes
without the recommended `XX` prefix and the resulting type error can
easily be suppressed.
  • Loading branch information
ralfstx committed Dec 17, 2024
1 parent 07fe0c3 commit 688c0d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export type CustomInfoAttrs = CustomInfoProps;
* `XX` to avoid name collisions.
*/
export type CustomInfoProps = {
[name: string]: string;
[name: `XX${string}`]: string;
};

/**
Expand Down

0 comments on commit 688c0d2

Please sign in to comment.