Repository navigation
[codemod][prereq] Convert Functions from arrow to function - #35749
Merged
clintandrewhall merged 1 commit intoApr 29, 2019
Merged
Conversation
Contributor
|
Pinging @elastic/kibana-canvas |
Contributor
💚 Build Succeeded |
rashidkpc
approved these changes
Apr 29, 2019
Contributor
|
We talked about this ahead of the pull, I didn't run this, but the changes are all formatting so LGTM. |
clintandrewhall
added a commit
to clintandrewhall/kibana
that referenced
this pull request
May 2, 2019
clintandrewhall
added a commit
that referenced
this pull request
May 3, 2019
2 of 5 tasks
patrykkopycinski
pushed a commit
to patrykkopycinski/kibana
that referenced
this pull request
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a codemod to support #35087. Including this change in #35087 makes the differences too extreme to review effectively, (
gitthinks the files are all new because of the spacing indents, etc). By pushing this change to master first, we can better review the changes there.This PR was created by running a RegEx to convert the Function arrow expressions and EOF to match.
Why is this change necessary?
There's a bug in Typescript that will affect how our Function files appear and the features they provide: microsoft/TypeScript#241
It's called "return type widening"... here's a practical example of how a typed file looks at the moment:
Since the
constdoes not have an inline return type, the return type fromFunctionFactoryis "widened" to accept anything so long as the rest of the returned object matches the type.As a result, you don't get an error if you include something that shouldn't be there, or isn't documented in the type.
There are a few options to fix this, but each affects how the file is constructed.
Option One: we include the return type inline.
It's long, repetitive, and ugly.
Option Two: we convert the
constto a pure function.Option Three: we wrap the spec in a strongly-typed function
We use the
Neverizetechnique.So I went with 2
I chatted with @w33ble and @rashidkpc ... this seemed to be the least invasive with the tersest syntax.