Skip to content

Fix/config types#37

Merged
jwbrandon merged 5 commits into
mainfrom
fix/config-types
Jul 15, 2026
Merged

Fix/config types#37
jwbrandon merged 5 commits into
mainfrom
fix/config-types

Conversation

@jwbrandon

Copy link
Copy Markdown
Contributor

The d.ts enumerated a closed set of config keys, so TypeScript rejected values the runtime passes through verbatim: custom keys in the config prop (e.g. _customAdServerData), and whitelisted top-level props the types never declared (advertising, floating, related, ...). It also drifted from the player (autostart only allowed 'viewable').

JWPlayerConfig is now Record<string, unknown> so it can't fall out of sync with the player's config surface. Input positions (config, advertising, setup) also accept plain object, since interface-typed values lack the implicit index signature Record assignability requires. Declared props keep their strict types.

The d.ts enumerated a closed set of config keys, so TypeScript rejected
values the runtime passes through verbatim: custom keys in the config
prop (e.g. _customAdServerData), and whitelisted top-level props the
types never declared (advertising, floating, related, ...). It also
drifted from the player (autostart only allowed 'viewable').

JWPlayerConfig is now Record<string, unknown> so it can't fall out of
sync with the player's config surface. Input positions (config,
advertising, setup) also accept plain object, since interface-typed
values lack the implicit index signature Record assignability requires.
Declared props keep their strict types.
Widening JWPlayerConfig gave JWPlayerProps an open index signature, so
any top-level prop typechecked — including custom keys and typos the
runtime whitelist silently drops, recreating the silent-vanishing
confusion the config widening was meant to fix.

Props now extend an enumerated mirror of the config-props.js whitelist
(values still unknown, so no player-shape drift) and a unit test keeps
the two lists in sync. React consumes the key prop before the component
sees it, so key is omitted and only works via config.
The config-props.js whitelist meant every new player option needed a
package release before it worked as a top-level prop, and anything not
yet listed was silently dropped — the confusion behind the custom ad
data thread. generateConfig now forwards every prop except the
component's own API (library, config, id, children, mount callbacks,
and on*/once* event handlers), so the player decides which keys are
meaningful and the wrapper can't drift out of sync.

The props type reopens accordingly (extends JWPlayerConfig), and the
whitelist mirror plus its sync test are gone.
@jwbrandon
jwbrandon merged commit 7f2ce70 into main Jul 15, 2026
3 checks passed
@jwbrandon
jwbrandon deleted the fix/config-types branch July 16, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant