Skip to content

TS3.7: No overload matches this call #34554

Description

@eamodio

TypeScript Version: 3.7.0-dev.20191017

Search Terms:
No overload matches this call.

Code

class Repo {
    async getLastFetched(): Promise<number> {
        try {
            return await new Date().getTime();
        }
        catch {
            return 0;
        }
    }

    async getStatus(): Promise<{ status: number } | undefined> {
        return await { status: 0 };
    }
}

class Foo {
    private async getSingleRepoConfirmStep(repos: Repo[]) {
        const repo = repos[0];
        const [status, lastFetched] = await Promise.all([repo.getStatus(), repo.getLastFetched()]);

        let fetchedOn = ''
        if (lastFetched !== 0 && status !== undefined) {
            const goo = `${status.status}`;
            fetchedOn = `Last fetched ${new Date(lastFetched)}`;
        }
    }
}

Expected behavior:
lastFetched is of type number

Actual behavior:
lastFetched is of type number | undefined

Playground Link:
https://www.typescriptlang.org/play/index.html?ts=Nightly#code/MYGwhgzhAEBKCmAHA9tA3gKGt6kCeAdsNAObwAuAMpOQGIXAAW8AJgBQCUAXNAAoBOyALYBLCPAA8BAK5CARvH4A+dFhzry-PKvW6c-CtP4FcAdzAjy0AvFPQAImHLxOAOjLkAKiKEuOAbjU9AF8g3WAnJh09XQNyIxMABkCY6FD1ULD8IlIKAGVyJ2kITh4BYTFJNGgIQviIHhl5RTToAB9oaQIWeAAzERsWFUxUuISzCytq2qKG6ES0lJxQzNBIGFpkVBGcRH4RADcneFwIQmIPPIGSEHgEFABhZAJ+-iECpDYDFDn75ABtAC6HGiemAz1q0G+qAAvFCkMgIP9EoClmCIVZ-jN6gAaaDgWr0chMViA6BwsDmSx8QSicSuMAgEBsf7Q9z5OrFTh4tkeaiEhjMdgcYGBMLqW5WXqC1gAeRMcIA5IrxTgRL1oGwCXQZSxoABCGFwhYAMhNNU5MENcK6PX6gxBO1S2HBBEhJC25OgAAMACRobHFVyBiDBb1o53S4lC+Ve738qW66D+mx2RzOLU0IkklgcMMRjJhFZAA

Related Issues:

Activity

  1. AviVahl commented on Oct 18, 2019

    @AviVahl

    Might be fixed by #34501
    ?

  2. AviVahl commented on Oct 18, 2019

    @AviVahl
  3. eamodio commented on Oct 24, 2019

    @eamodio
    Author

    Closing at duplicate of #33752

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions