From 973f28fd0720ea03f7c3d9fa96588fdeff680c6e Mon Sep 17 00:00:00 2001 From: Christopher Manouvrier Date: Thu, 16 Jan 2020 07:36:31 +1100 Subject: [PATCH] fix(hls-parser): Updates Playlist constructor paramaters (#41574) --- types/hls-parser/hls-parser-tests.ts | 7 +++- types/hls-parser/index.d.ts | 56 +++++++++++++++------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/types/hls-parser/hls-parser-tests.ts b/types/hls-parser/hls-parser-tests.ts index 6b6fadf601..303bb97fc1 100644 --- a/types/hls-parser/hls-parser-tests.ts +++ b/types/hls-parser/hls-parser-tests.ts @@ -8,7 +8,7 @@ if (playlist.isMasterPlaylist) { // Media playlist } -const { MediaPlaylist, Segment } = HLS.types; +const { MediaPlaylist, MasterPlaylist, Segment } = HLS.types; new MediaPlaylist({ targetDuration: 9, @@ -22,3 +22,8 @@ new MediaPlaylist({ }), ], }); + +new MasterPlaylist({ + version: 3, + variants: [], +}); diff --git a/types/hls-parser/index.d.ts b/types/hls-parser/index.d.ts index 32006da288..e280173f4f 100644 --- a/types/hls-parser/index.d.ts +++ b/types/hls-parser/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for hls-parser 0.5 // Project: https://github.com/kuu/hls-parser#readme // Definitions by: Christian Rackerseder +// Christopher Manouvrier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.4 @@ -20,6 +21,14 @@ export class Data { } export namespace types { + interface BasePlaylistConstructorProperties { + uri?: string; + version?: number; + independentSegments?: boolean; + start?: { offset: number; precise: boolean }; + source?: string; + } + class Playlist extends Data { isMasterPlaylist: boolean; @@ -33,14 +42,7 @@ export namespace types { source?: string; - constructor(properties: { - isMasterPlaylist: boolean; - uri?: string; - version?: number; - independentSegments: boolean; - start?: { offset: number; precise: boolean }; - source?: string; - }); + constructor(properties: BasePlaylistConstructorProperties & { isMasterPlaylist: boolean }); } class MasterPlaylist extends Playlist { @@ -52,13 +54,15 @@ export namespace types { sessionKeyList: readonly Key[]; - constructor(properties: { - variants?: readonly Variant[]; - currentVariant?: number; - sessionDataList?: readonly SessionData[]; - sessionKeyList?: readonly Key[]; - source?: string; - }); + constructor( + properties: BasePlaylistConstructorProperties & { + variants?: readonly Variant[]; + currentVariant?: number; + sessionDataList?: readonly SessionData[]; + sessionKeyList?: readonly Key[]; + source?: string; + }, + ); } class MediaPlaylist extends Playlist { @@ -76,16 +80,18 @@ export namespace types { segments: readonly Segment[]; - constructor(properties: { - targetDuration: number; - mediaSequenceBase?: number; - discontinuitySequenceBase?: number; - endlist?: boolean; - playlistType?: 'EVENT' | 'VOD'; - isIFrame?: boolean; - segments?: readonly Segment[]; - source?: string; - }); + constructor( + properties: BasePlaylistConstructorProperties & { + targetDuration: number; + mediaSequenceBase?: number; + discontinuitySequenceBase?: number; + endlist?: boolean; + playlistType?: 'EVENT' | 'VOD'; + isIFrame?: boolean; + segments?: readonly Segment[]; + source?: string; + }, + ); } class Variant {