Skip to content

Fetch client generates invalid typescript when params contain dates, but exploded params don't #2616

@jlillywhite

Description

@jlillywhite

When the fetch client is generated, if the params object contains parameters with a date-time format, but the params that are in exploded params do not, then the value of hasDateParams is true, but there are no date params in the explodeParams. This means that the generated code looks like this:

        if (Array.isArray(value) && explodeParameters.includes(key)) {
            value.forEach((v) => {
                normalizedParams.append(key, v === null ? "null" : v instanceof Date ? v.toISOString() : v.toString());
            });
            return;
        }

Which results in a typescript error: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.

Metadata

Metadata

Assignees

Labels

fetchFetch client related issue

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions