Repository navigation
Elaborate into arrow return expressions and array types - #27040
Conversation
| return false; | ||
| } | ||
| // Or functions with annotated parameter types | ||
| if (some(node.parameters, ts.hasType)) { |
There was a problem hiding this comment.
Why not though?
There was a problem hiding this comment.
Because we're only validating the return types and the error we may issue on mismatched parameter types is usually better if available.
Daniel Rosenwasser (DanielRosenwasser)
left a comment
There was a problem hiding this comment.
Mostly looks good to me - I'd love to brainstorm on ways to get rid of the not-so-great index signature related span, but I don't think that's a blocker.
I'd suggest you get Ryan Cavanaugh (@RyanCavanaugh) or Brian Terlson (@bterlson) to weigh in as well.
| } | ||
|
|
||
| function checkArrayLiteral(node: ArrayLiteralExpression, checkMode: CheckMode | undefined): Type { | ||
| function checkArrayLiteral(node: ArrayLiteralExpression, checkMode: CheckMode | undefined, forceTuple?: boolean): Type { |
There was a problem hiding this comment.
This is only called in two places, so make it non-optional.
| ~~~~~~~~~ | ||
| !!! error TS2322: Type 'foo' is not assignable to type '{ id: number; }'. | ||
| !!! error TS2322: Property 'id' is missing in type 'foo'. | ||
| !!! related TS6501 /.ts/lib.es5.d.ts:1284:5: The expected type comes from this index signature. No newline at end of file |
There was a problem hiding this comment.
Unfortunately I think that these aren't very helpful. Is there a way to retain the topmost type and point to that?
| !!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. | ||
| !!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
| ~ | ||
| !!! error TS2322: Type 'number' is not assignable to type 'string'. |
There was a problem hiding this comment.
This one is a little bit hard to judge. It's not super clear where this number is coming from and what it's being compared to.
There was a problem hiding this comment.
The overall signature has the same problem, since it's all inferred, IMO.
| !!! error TS2345: Type '[string, number]' is not assignable to type '[string, boolean]'. | ||
| !!! error TS2345: Type 'number' is not assignable to type 'boolean'. | ||
| ~~~~~~~~~~ | ||
| !!! error TS2322: Type '(string | boolean)[]' is not assignable to type '[string, boolean]'. |
There was a problem hiding this comment.
I think this is a regression?
When either seems viable.
Fixes the easier parts of #27030