Skip to content

getSheetId fails with an error when called without an argument. #654

Closed

Description

@jansiegel

Description

hf.getSheetId throws the Cannot read property 'toLowerCase' of undefined, when called without an argument.
It also fails with sheetDisplayName.toLowerCase is not a function if called with a number as an argument.

Steps to reproduce

  1. Call hf.getSheetId()...
  2. ... or hf.getSheetId(333)

Your environment

  • HyperFormula version: latest develop

Activity

  1. added
    Bug
    on Apr 26, 2021
  2. izulin commented on Apr 26, 2021

    @izulin
    Contributor

    It is explicitly stated as a function taking string as an argument in the docs.

  3. wojciechczerniak commented on Apr 26, 2021

    @wojciechczerniak
    Contributor

    In TS, but JS allows undefined args. We may do better here and return undefined assuming that such sheet name does not exist. One if (typeof sheetName === 'string') WDYT?

  4. jansiegel commented on Apr 27, 2021

    @jansiegel
    ContributorAuthor

    When I look closer at the other functions similar to this I can see there's basically no type validation anywhere, so it's an issue with many of the methods.
    Is this intentional?

  5. izulin commented on Apr 27, 2021

    @izulin
    Contributor

    When I look closer and the other functions similar to this I can see there's basically no type validation anywhere, so it's an issue with many of the methods.
    Is this intentional?

    Yes, in the sense that the code was written with TS-mindset in mind, not with JS-mindset.

  6. izulin commented on Apr 27, 2021

    @izulin
    Contributor

    In TS, but JS allows undefined args. We may do better here and return undefined assuming that such sheet name does not exist. One if (typeof sheetName === 'string') WDYT?

    To be consistent it would require to add basic typechecking to all the API functions. We can do it, but it's a little bit more of an effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions