Typescript error when `postData` is missing

Open
#325 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript

Research direction

Start with the TypeScript declaration referenced in the error, httpsnippet.d.ts, and compare its HarRequest definition with the example that constructs HTTPSnippet without postData. Verify the corrected typing by compiling the shown example and confirming that the missing-postData error is gone.

Written by the indexing model from the issue text.

Description

From the example:

const snippet = new HTTPSnippet({
        method: 'GET',
        url: 'http://mockbin.com/request',
      });

      const options = { indent: '\t' };
      const output = snippet.convert('shell', 'curl', options);
      console.log(output);

I get a typescript error

Argument of type '{ method: string; url: string; }' is not assignable to parameter of type 'HarRequest | HarEntry'.
  Type '{ method: string; url: string; }' is not assignable to type 'HarRequest'.
    Property 'postData' is missing in type '{ method: string; url: string; }' but required in type '{ postData: any; }'.ts(2345)
httpsnippet.d.ts(19, 5): 'postData' is declared here.
Dominant language
TypeScript
Stars
1.2k
Forks
242
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Kong/httpsnippet

All issues in Kong/httpsnippet

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.