Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'headers' does not exist in type 'Partial<APIParameters>' #370

Open
obochurkin opened this issue May 30, 2022 · 0 comments
Open

'headers' does not exist in type 'Partial<APIParameters>' #370

obochurkin opened this issue May 30, 2022 · 0 comments

Comments

@obochurkin
Copy link

obochurkin commented May 30, 2022

The issue is with the api.d.ts file itself. It is not allowed to pass headers as there is a RequestInit interface not reachable.
Here is a code example:

const createPagerDutyIncident = (pd: PartialCall, incidentData: IncidentDataType) => {
    return pd.post('/incidents', {
        headers: {
            From: '**@**.**'
        },
        data: incidentData
    });
}

and here is the TS error:

Argument of type '{ headers: { From: string; }; data: IncidentDataType; }' is not assignable to parameter of type 'Partial<APIParameters>'.
  Object literal may only specify known properties, and 'headers' does not exist in type 'Partial<APIParameters>'.ts(2345)

RequestInit interface should be inside npm package.

[UPD] this issue occurs if you not using lib dom in tsconfig file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant