Skip to content

HttpClient in 20.1 throws TS2769 when using documented 'timeout' option #62581

@michael-small

Description

@michael-small

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

Yes

Description

(Credit to @IgorSedov who found this and wrote 95% of this but had to get going)

In Angular 20.1, a new timeout option was introduced for HttpClient requests, as documented in the official guide and 20.1 release notes. However, using this option currently results in a TypeScript error:

ERROR TS2769: No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'timeout' does not exist in type '{ headers?: HttpHeaders | Record<string, string | string[]> | undefined; context?: HttpContext | undefined; observe?: "body" | undefined; params?: HttpParams | ... 1 more ... | undefined; ... 9 more ...; transferCache?: boolean | ... 1 more ... | undefined; }'. [plugin angular-compiler]

TypeScript type definitions have not been updated to reflect it.

Code Example (from the documentation):

http.get('/api/config', {
  timeout: 3000,
}).subscribe({
  next: config => {
    console.log('Config fetched successfully:', config);
  },
  error: err => {
    // If the request times out, an error will have been emitted.
  }
});

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-tyswe3aa?file=src%2Fmain.ts

Please provide the exception or error you saw

ERROR TS2769: No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'timeout' does not exist in type '{ headers?: HttpHeaders | Record<string, string | string[]> | undefined; context?: HttpContext | undefined; observe?: "body" | undefined; params?: HttpParams | ... 1 more ... | undefined; ... 9 more ...; transferCache?: boolean | ... 1 more ... | undefined; }'. [plugin angular-compiler]

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.1.0
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64

Angular: 20.1.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2001.0
@angular-devkit/core         20.1.0
@angular-devkit/schematics   20.1.0
@schematics/angular          20.1.0
rxjs                         7.8.2
typescript                   5.8.2
zone.js                      0.15.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonIssues related to APIs in the @angular/common packagestate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions