-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Extract function types from function and arrow expressions. #60234
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,6 @@ declare function b1(): typeof b1; | |
declare function foo(): typeof foo; | ||
declare var foo1: typeof foo; | ||
declare var foo2: typeof foo; | ||
declare var foo3: () => /*elided*/ any; | ||
declare var x: () => /*elided*/ any; | ||
declare var foo3: () => () => /*elided*/ any; | ||
declare var x: () => () => /*elided*/ any; | ||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know why this is changing? It seems a little awkward for this self referential type to be printed one level deep like this rather than the single elided any (which would cause fewer downstream errors) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The base cause is that at the root level syntactic printing is now always given a try. And in this case the parameter list can be copied, it's just the return type that needs to fallback on type printing. I think I can revert this behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into it and I don't think I can easily revert to the old behavior. The type checked printer only knows a type is too recursive to represent when it tries to print it. So when I see the function expression, I try to reuse types from the expression. When doing so, I discover the missing return type and fallback to type checker printing which then discovers the type is recursive. What specifically is the worry in this case ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreso if someone actually calls it and uses the result, that result will not be |
||
declare function foo5(x: number): (x: number) => number; |
Uh oh!
There was an error while loading. Please reload this page.