Skip to content

FR: upgrade Boolean to be a type assertion function  #213

@jasikpark

Description

@jasikpark

Implement #138 w/in ts-reset

When using code like

const isReady = Boolean(downloadURL);

return isReady ?
          <LinkButton fullWidth href={downloadURL} download={fileName}>
            Download
          </LinkButton>
        : null;

downloadURL is considered falsey still in the ternary. With this change to global types:

interface BooleanConstructor {
  // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
  new (value?: unknown): Boolean;
  <T>(value?: T): value is TSReset.NonFalsy<T>;
  // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
  readonly prototype: Boolean;
}

It typechecks fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions