-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[helpers TS conversion] classes #16511
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56990 |
Thanks! For compatibility, we need to keep |
var _typeof = require("./typeof.js")["default"]; | ||
var assertThisInitialized = require("./assertThisInitialized.js"); | ||
|
||
function _possibleConstructorReturn<T, U>(t: T, e: U): U | T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to migrate to export default
? Let's give it a shot and see if the make test
passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I also convert require()
to use esm import?
@SukkaW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files in this directory should be automatically generated and we should not edit it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah you're right
there is another file called possibleConstructorReturn.js in packages/babel-helpers/src/helpers/possibleConstructorReturn.js
which has the same name as this one
should I also convert it to typescript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should convert packages/babel-helpers/src/helpers/possibleConstructorReturn.js
and remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed and pushed
make the function accept undefined as a param type Co-authored-by: Sukka <isukkaw@gmail.com>
I must have changed it out of habit unconsciously reverted! @liuxingbaoyu |
Did you forget to push your changes? :) |
pushed |
import toPropertyKey from "toPropertyKey"; | ||
function _defineProperties(target, props) { | ||
// @ts-expect-error Migrate in another PR | ||
import toPropertyKey from "toPropertyKey.ts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import toPropertyKey from "toPropertyKey.ts"; | |
import toPropertyKey from "./toPropertyKey.ts"; |
(and it's already written in TS :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
export default function _possibleConstructorReturn< | ||
T extends object | undefined, | ||
>(self: T, call: T | ((...args: any[]) => T) | undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are here, let's rename call
to value
. Calling it call
makes absolutely no sense 😅
It's the value passed to return
in a derived class constructor:
class A extends B {
constructor() {
return 1;
}
}
"call" is 1
in this case.
(and probably it's type should just be any
or unknown
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!!
that makes much sense now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Migrate all classes helper functions (createClass, possibleConstructorReturn, classCallCheck, assertThisInitialized) to TypeScript