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

Align typings on DataSet returns #208

Closed
kmannislands opened this issue Sep 14, 2022 · 1 comment · Fixed by #209
Closed

Align typings on DataSet returns #208

kmannislands opened this issue Sep 14, 2022 · 1 comment · Fixed by #209
Labels

Comments

@kmannislands
Copy link
Contributor

Most methods on DataSet are typed incorrectly. For example, int16 declares that it will always return a number:

  export interface DataSet {
    /**
     * Finds the element for tag and returns an unsigned int 16 if it exists and has data. Use this function for VR type US.
     */
    uint16: (tag: string, index?: number) => number;
 
   // ...
}

However, the actual logic can also return undefined:

export default class DataSet {

  int16 (tag, index) {
    var element = this.elements[tag];

    index = (index !== undefined) ? index : 0;
    if (element && element.length !== 0) {
      return getByteArrayParser(element, this.byteArrayParser).readInt16(this.byteArray, element.dataOffset + (index * 2));
    }

    return undefined; // <- This part
  }

  // ...
}

I'd suggest updating the typing to reflect the implementation to avoid breaking changes (ie: returning 0 in this case)

@ohif-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 1.8.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants