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

types: TextRequest class type is incorrect due to skipLibChecks: true #4210

Closed
ondreian opened this issue Jun 13, 2023 · 0 comments · Fixed by #4211
Closed

types: TextRequest class type is incorrect due to skipLibChecks: true #4210

ondreian opened this issue Jun 13, 2023 · 0 comments · Fixed by #4211
Labels

Comments

@ondreian
Copy link
Contributor

ondreian commented Jun 13, 2023

The type definition here:

dash.js/index.d.ts

Lines 4107 to 4114 in 4b0b16d

export class TextRequest extends FragmentRequest {
constructor(url: string, type: string);
url: string | null;
type: 'InitializationSegment' | 'MediaSegment' | null;
mediaType: MediaType;
responseType: string;
}

generates a type error when skipLibChecks: false is added to a containing project, because this type is incorrect.

Environment
  • typescript: ^5.1.3
  • Dash.js version: v4.7.0
Steps to reproduce
  1. checkout isolated reproduce case here
  2. cd dash-type-4.7.0
  3. run yarn fail convenience script to reproduce the case with tsc
Console output
yarn build
yarn run v1.22.17
$ tsc && rimraf dist && webpack --config build/webpack.prod.js
index.d.ts:4110:9 - error TS2416: Property 'url' in type 'TextRequest' is not assignable to the same property in base type 'FragmentRequest'.
  Type 'string | null' is not assignable to type 'string'.
    Type 'null' is not assignable to type 'string'.

4110         url: string | null;
             ~~~


Found 1 error in index.d.ts:4110

This is because in Typescript, you cannot change the type of an already declared property like this. By default tsc init configures a project as "skipLibCheck": true

Which means that this silently fails as the types are never checked in the dash.js index.d.ts file during compile time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant