Skip to content

[Bug] Typescript error in organization.fetch() "An argument for 'force' was not provided." #232

Open
@louh

Description

@louh

Current Behavior

When fetching projects from an organization with await organization.fetch('projects'); (see for example this line in documentation) Typescript will throw an error like this:

Expected 2 arguments, but got 1.ts(2554)
transifexApi.d.ts(20, 35): An argument for 'force' was not provided.
(method) JsonApiResource.fetch(relationshipName: string, force: boolean): Promise<JsonApiResource | Collection>

Expected Behavior

As force is an optional parameter that defaults to false, the end developer should not be required to provide a value simply to satisfy the typechecker.

Steps to Reproduce

In a TypeScript module working with @transifex/api package, add this line and you should see the error while typechecking.

const projects = await organization.fetch('projects');

Possible Solution

Update this line in transifexApi.d.ts so that force is optional: https://github.com/transifex/transifex-javascript/blob/master/packages/api/src/transifexApi.d.ts#L20

old:

fetch(relationshipName: string, force: boolean): Promise<JsonApiResource | Collection>;

new:

fetch(relationshipName: string, force?: boolean): Promise<JsonApiResource | Collection>;

Possible Implementation

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions