-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Convert core to typescript #6340
Conversation
Good start |
My one request is you do-no-harm with this PR. Keep the changes as straightforward as possible and no refactoring. There’s always time to improve later. |
Well, there is one small deprecation: I removed |
OK, it should build, but I don't know how to deal with |
@Zyie could use your help on this one |
@ivanpopelyshev I believe this should do the trick. Add this to the the
|
OK, its building but now I have to fight typescript-eslint and few of those rules are just stupid.
|
b54339e
to
60f8cc5
Compare
Codecov Report
@@ Coverage Diff @@
## dev #6340 +/- ##
=====================================
Coverage 74.7% 74.7%
=====================================
Files 105 105
Lines 6053 6053
=====================================
Hits 4522 4522
Misses 1531 1531 Continue to review full report at Codecov.
|
OK, i have a few things: I've tried to preserve everything even if I saw places where we could do better with TS. only in few cases I actually changed code a bit.
|
I think you can add an
This then makes it only one line
I agree think we should disable the @typescript-eslint/camelcase rule |
@EvidentlyCube could you review this? |
@bigtimebuddy I'll review it tomorrow! |
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.
Wow this is huge, well done @ivanpopelyshev, very impressive.
One thing I've noticed is that this PR has a very different style to the other typescript conversion pr's.
- Previously all public variables declared as public
- static variables were defined at the top of the class not the bottom
- variables were organised by public, protected, private
Not sure how much you guys care about the consistency but i thought i would mention 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.
Wow this is huge, well done @ivanpopelyshev, very impressive.
One thing I've noticed is that this PR has a very different style to the other typescript conversion pr's.
- Previously all public variables declared as public
- static variables were defined at the top of the class not the bottom
- variables were organised by public, protected, private
Not sure how much you guys care about the consistency but i thought i would mention it
@@ -57,7 +59,7 @@ export const INSTALLED = []; | |||
* texture should be updated from the video. Leave at 0 to update at every render | |||
* @return {PIXI.resources.Resource} The created resource. | |||
*/ | |||
export function autoDetectResource(source, options) | |||
export function autoDetectResource(source: any, options: any): Resource |
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 options here are not any
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.
We only can do something like {[key: string: any}
, because we don't know the resources that user adds there.
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 do. The options are in the documentation.
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.
We can add those fields to satisfy autocomplete but we need `{[key:string]:any} just because its possible to use in custom resources.
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.
We should define strict types and then add a generic type for extensibility. Just using the generic type isn’t that great
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.
I dont care about this place and it can be patched later when we find a case it doesnt work. Its still experimental API :)
You may change it and and other related places, and commit to this branch.
constructor(source, options) | ||
items: Array<BaseTexture>; | ||
|
||
constructor(source: Array<string|Resource>, options?: any) |
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 options here are not any
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.
they are being passed to autoDetectResource, we only can do something like {[key: string: any}
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.
You need stricter types here for options. My suggestion is to make CubeResourceOptions and then combine all the options into the autoDetectResource: CubeResourceOptions|CanvasResourceOptions|VideoResourseOptions
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.
^^^ its up to you. However I remind you that "|" might have side effects. I remember our struggle with Point|ObservablePoint
;)
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.
Yeah that’s fine in this case because these Resource-specific options are non-functional and don’t have method signatures like Point v ObservablePoint.
OK then i'll fix it and add Extra information. Both I and @GoodBoyDigital have custom scene trees for pixijs. Its better if Part of that is typings-related - that's why I made |
OK, I'm applying your idea regarding public/protected/private . However I leave the fields that have mixed usage without any modifiers. I also remove We still have those modifiers in jsdoc, so we can apply them if TS will allow us to have custom modifiers. This requires one more pass over all the code. |
Regarding statics - I left them where they were originally and our team expects them there. If we move stuff like |
Thank you! I have predisposition for large and brain-melting tasks, but I couldn't have a chance to show that without people who "prepare the field" for me. |
OK, access modifiers are ready. |
Btw, @Zyie, I had to rename all |
I think we can merge this thing and treat Right now the only serious thing here is |
I like IRenderContext |
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.
Summary:
- There are a bunch of conversations marked as resolved but they don't seem to involve the code actually being changed
- There is a lot of inconsistency in when access modifiers are applied. I personally prefer to always have them explicit, but for me also any approach is fine provided it's standarized across the whole codebase :). I suggest adding eslint rule to cover that.
- Ditto for
Array<X>
vsX[]
- One more thing I noted, there are a bunch of
{[key: string]: T}} in the code, how about introducting a generic type
type Dictionary = {[key: string]: T}`? - 95 files is a lot, if I sound dry in my comments I didn't intend to!
And a suggestion for the future - when enormous modules like this one are converted to TS it might be a good idea to split it into smaller steps, maybe 20 files each. I have no hope of being able to go through 95 files and remain concentrated :).
protected readonly _tempDisplayObjectParent: DisplayObject; | ||
protected _backgroundColor: number; | ||
protected _backgroundColorString: string; | ||
_backgroundColorRgba: number[]; |
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.
In a different file you declare private
explicitly, shouldn't that be followed here?
Also, it'd probably be a good idea to enforce explicit access modifiers in eslint if that's the way to go.
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.
That particular field is used in RenderTextureSystem. I've decided not to add modifiers that can affect code readability.
{ | ||
// do as you please! | ||
|
||
filterManager.applyFilter(this, input, output, clearMode, currentState); | ||
filterManager.applyFilter(this, input, output, clearMode); |
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.
Why was this code changed?
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.
because that parameter is absent in filterManager.
@EvidentlyCube I forgot to push it :) |
I feel like I'm rushing things, but from other point of view - we cant merge other PR's related to core while this one exists. Glory to our reviewers! |
While not perfect, I think this is good enough to merge. Further fixes can be added to address some of the outstanding things. Are you good @ivanpopelyshev or are you waiting for any other responses? |
There are two possible improvements and one potential problem we can address in PR's.
Summary: YES, we can merge it. |
Actually, we cant merge it. There are failing examples, i didnt test everything :( |
What’s broken? Could you keep me posted. |
Graphics, both batched and main versions. Probably something with Geometry.. https://www.pixiplayground.com/#/edit/jPgE3ZEUhhVb7GJx9DuJb |
OK, I've checked all examples. The one that doesnt work - ParticleContainer - fixed in #6371 |
Its done. Lets review it. Discussion and a few details about conversion is in the post below.