Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shaka namespace types to generated externs #6762

Open
joeyparrish opened this issue Jun 5, 2024 · 0 comments
Open

Add shaka namespace types to generated externs #6762

joeyparrish opened this issue Jun 5, 2024 · 0 comments
Labels
priority: P3 Useful but not urgent type: enhancement New feature or request
Milestone

Comments

@joeyparrish
Copy link
Member

There are cases where we want to refer to the type of the shaka namespace in a type-safe way. For example, in test/test/util/loader.js, we load the Shaka library dynamically for tests without inserting it into the global namespace. To refer to that with strong types, we need a namespace type.

Today, we have code like in

/**
* A stand-in type for the "shaka" namespace. Used when loading the compiled
* library or when referencing it in ManifestGenerator or TestScheme.
*
* The new compiler has a "typeof" annotation for classes, but it warns of an
* incomplete type when used on the entire library namespace. So instead, we
* use this type, which maps out parts of the compiled namespace used in
* top-level integration tests.
*
* @typedef {{
* Player: typeof shaka.Player,
* media: {
* SegmentReference: typeof shaka.media.SegmentReference,
* InitSegmentReference: typeof shaka.media.InitSegmentReference,
* SegmentIndex: typeof shaka.media.SegmentIndex,
* PresentationTimeline: typeof shaka.media.PresentationTimeline
* },
* net: {
* NetworkingEngine: typeof shaka.net.NetworkingEngine
* },
* offline: {
* Storage: typeof shaka.offline.Storage
* },
* ui: {
* Overlay: typeof shaka.ui.Overlay,
* Controls: typeof shaka.ui.Controls,
* Element: typeof shaka.ui.Element
* },
* util: {
* StringUtils: typeof shaka.util.StringUtils
* }
* }}
*/
let shakaNamespaceType;
that creates a one-off typedef of the parts we're using in those tests. Ideally, we would generate this into our generated externs, and it would be complete.

This has also come up in context of the Cast Application Framework, which depends on Shaka Player and has unit tests that mock the Shaka API. For those tests, we would like to use the same complete, generated typedef for the namespace.

@joeyparrish joeyparrish added type: enhancement New feature or request priority: P3 Useful but not urgent labels Jun 5, 2024
@shaka-bot shaka-bot added this to the Backlog milestone Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: P3 Useful but not urgent type: enhancement New feature or request
2 participants