Skip to content

Evi/typings #458

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/boxes/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ipcoBox extends ContainerBox {
export class grplBox extends ContainerBox {
type = 'grpl' as const;
box_name = 'GroupsListBox';
declare boxes: Array<EntityToGroup>;
boxes: Array<EntityToGroup> = [];
}
export class j2kHBox extends ContainerBox {
type = 'j2kH' as const;
Expand Down
8 changes: 4 additions & 4 deletions src/boxes/sampleentries/sampleentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function decimalToHex(d: number | string, padding?: number | null) {
}

class avcCSampleEntryBase extends VisualSampleEntry {
declare avcC: avcCBox;
declare avcCs: Array<avcCBox>;
avcC: avcCBox | undefined;
Copy link
Contributor Author

@erwanvivien erwanvivien May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about this change, my reasoning is that the avcC is at some point undefined (same for most other boxes)

We seem to be checking if (this.avcC) meaning the type can actually be undefined, so I'd say we should do this update, though I'm missing quite a lot of those in the commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 078e7c5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why no | undefined typings are working?

image
Screenshot 2025-05-28 at 11 09 00

On the first screen Typescript doesn't even pick the undefined in the second screen Typescript allows to use .length on an optional type
I'm clueless 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of dropping the latest commit and current work (unmerged) to merge this PR and resolve issues, then come back to it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why no | undefined typings are working?

This is probably due to strict: false in the tsconfig. Maybe not a bad idea to set it to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, only Found 1118 errors in 154 files. haha

I might have time to work on that, I'll break this PR in more PRs so we can merge few things at least

avcCs: Array<avcCBox> = [];

/** @bundle box-codecs.js */
getCodec() {
Expand Down Expand Up @@ -96,8 +96,8 @@ export class dav1SampleEntry extends VisualSampleEntry {
}

class hvcCSampleEntryBase extends VisualSampleEntry {
declare hvcC: hvcCBox;
declare hvcCs: Array<hvcCBox>;
hvcC: hvcCBox;
hvcCs: Array<hvcCBox> = [];

/** @bundle box-codecs.js */
getCodec(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/boxes/tref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Log } from '#/log';
export class trefBox extends ContainerBox {
type = 'tref' as const;

declare boxes: Array<TrackReferenceTypeBox>;
boxes: Array<TrackReferenceTypeBox> = [];

parse(stream: MultiBufferStream) {
while (stream.getPosition() < this.start + this.size) {
Expand Down