Typescript: Type inference failure (regression?)

Created on 13 Mar 2019  Â·  6Comments  Â·  Source: microsoft/TypeScript

Maybe a change of type inference strategies but it weakened type inference.

TypeScript Version: 3.4.0-dev.20190309


Search Terms:

Code

https://github.com/falsandtru/securemark/blob/v0.108.5/src/parser/inline/media.ts#L24

Adding a type annotation string[] to the first parameter resolves the errors. Thus there are at least two candidates of the type here. And the errors are thrown since the compiler didn't try to infer the type using the all candidates but the compiler should try with the all candidates.

Expected behavior:

pass

Actual behavior:

Argument of type '([text, INSECURE_URL, ...params]: ((HTMLElement | Text)[] | Text[])[], rest: string) => [any[], string] | undefined' is not assignable to parameter of type '(rs: string[], rest: string) => Result<any, [TextParser, ParamParser]>'.
  Types of parameters '__0' and 'rs' are incompatible.
    Type 'string[]' is not assignable to type '((HTMLElement | Text)[] | Text[])[]'.
      Type 'string' is not assignable to type '(HTMLElement | Text)[] | Text[]'.ts(2345)

Playground Link:

Related Issues:

Unactionable

Most helpful comment

🎵 Please provide an isolated repro 🎵

All 6 comments

🎵 Please provide an isolated repro 🎵

Investigating the provided repro is often easier than isolating such as #29407.

This model doesn't scale - if every bug is just a link to a repo, we can't have a hope of figuring out if a bug is a duplicate of something else we're already investigating, and the engineering team will spend all its time reducing user repos only to usually discover that there was a bug in the code the whole time.

If you're not willing to attempt to reduce a repro, I'll go ahead and close this as unactionable. Thanks!

Looks like your personal opinion. Hey baby, do you know? Nobody knows what you think without saying it :baby_bottle: If you accept only isolated repro, that opinion should be explained at least in the issue template. Thanks :baby: :rofl:

If you accept only isolated repro, that opinion should be explained at least in the issue template.

??????

⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇
// A *self-contained* demonstration of the problem follows...
⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

@RyanCavanaugh Unfortunately, it doesn't explain you reject other repro. In fact, you've accepted many unisolated repro under that text. If you want to change other people using that text, you have to change it to assert your request. But it may be too difficult for babies to understand it :baby: :baby_bottle: :rofl:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

born2net picture born2net  Â·  150Comments

rbuckton picture rbuckton  Â·  139Comments

RyanCavanaugh picture RyanCavanaugh  Â·  205Comments

kimamula picture kimamula  Â·  147Comments

disshishkov picture disshishkov  Â·  224Comments