Fix/config types#37
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.