question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'default' of type 'Response | undefined' is not assignable to string index type 'Response'

See original GitHub issue

using package open-api in a project with "strict": true in tsconfig.json causes the error:

Property 'default' of type 'Response | undefined' is not assignable to string index type 'Response'

It would seem that explicitly accepting undefined in ResponsesObject fixes it:

  export interface ResponsesObject {
    [index: string]: Response | undefined;
    default?: Response;
  }

This happens since version 9.0.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:13
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Morl99commented, Jun 29, 2021

@jsdevel I don’t mean to be pushy, but if there is any chance that you could take a look at the linked PR, it would be really helpful. For the moment, we are blocked to update to 9.0.2 because of this.

Thank you for your hard work!

2reactions
Kosta-Githubcommented, May 25, 2021

default is definitely optional, therefore default?: Response is required.

IMHO, [index: string]: Response | undefined is reasonably, since you will not get a Response object back for a random string, e.g., resp['bla'] or resp.hello … therefore, you should be “forced” to check for undefined

Read more comments on GitHub >

github_iconTop Results From Across the Web

undefined' is not assignable to type 'string' - Stack Overflow
When I make any property of an interface optional ...
Read more >
Type 'undefined' is not assignable to type in TypeScript
The "Type 'undefined' is not assignable to type" error occurs when a possibly undefined value is assigned to something that expects a different...
Read more >
type 'undefined' is not assignable to type 'string'.ts(2345)
Solution 1: Remove the explicit type definition. Since getPerson already returns a Person with a name, we can use the inferred type. function...
Read more >
Documentation - Narrowing - TypeScript
return " ". repeat ( padding ) + input ;. Argument of type 'string | number' is not assignable to parameter of type...
Read more >
Typescript `never` type - Explain Programming
Argument of type 'string[]' is not assignable to parameter of type 'ConcatArray<never>'. Types of property 'slice' are incompatible. Type '(start?: number | ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found