-
Notifications
You must be signed in to change notification settings - Fork 484
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
Shift plexus to TypeScript (from flowtypes) #331
Conversation
Main outstanding items are to add linting to plexus TS files and more comments in the plexus build related files. Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #331 +/- ##
==========================================
+ Coverage 83.12% 83.25% +0.12%
==========================================
Files 145 145
Lines 3224 3224
Branches 658 660 +2
==========================================
+ Hits 2680 2684 +4
+ Misses 436 432 -4
Partials 108 108
Continue to review full report at Codecov.
|
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.
This is a fantastic start. Some minor things came up but by and large it looks pretty good.
Three things came up that are a bit more open ended:
First, I haven't seen Enum
s used to define values before, but that seems to be working well here. I also haven't used Enum
s much before at all so maybe that is how they are intended to be used. Mostly curious if they should live in the type.tsx
files if they are also constants? But I'm not sure what approach I would prefer over this.
Secondly, and this is something I'll look into more myself over the weekend, I am not sure when to use these three following type definitions:
key: Type | void;
or
key?: Type;
or
key?: Type | void;
Thirdly, if we want to be super thorough in type names, we may want to regex fix the type names that don't start with a T
.
Then one other point is that we don't need to use ;
instead of ,
in type definitions. I'm not overly attached to ,
over ;
but do have a slight preference. If you do as well we may want to change but if not it's fine either way.
@@ -17,33 +15,41 @@ | |||
/* eslint-disable no-console */ | |||
|
|||
import * as convCoord from './dot/conv-coord'; | |||
import workerFactory from './layout.worker'; | |||
import LayoutWorker from 'worker/LayoutManager/layout.worker'; |
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 this now from an npm package? if so I believe it should be the first import with a new line after.
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.
Well, I needed to create a type definition for the layout.worker that reflected it being used by Coordinator.tsx
as a WebWorker
. In TypeScript, I don't think you can create auxiliary type defs for local files. So, I made an alias in webpack and then added a type def for the alias.
So, it's a local file loaded via an alias resolver.
Seems like it should be kept in the local files section of imports, but moved to the bottom.
const VALIDITY_WARN = 'VALIDITY_WARN'; | ||
const VALIDITY_ERROR = 'VALIDITY_ERROR'; |
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.
not that important but seems like this should've moved up a line, not down
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.
These were actually unused, so I remove them.
meta: currentMeta, | ||
errorMessage: { | ||
colno, | ||
error, |
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.
previously errorMessage.error
was guaranteed to have the exactly the keys code, message, name, stack
even if some may be not be present on event.data.error
or if more are present on event.data.error
Not sure if this matters, but it may change the shape of this object.
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 current code is more aligned with the spec. Not sure why I had the previous code, might have been from experimentation.
UpdateContrary to the docs on I've marked out the incorrect comments, below. @everett980 Thanks for reviewing! Will check out your comments.
In the above,
Agreed. Turns out I missed a few!
I think we should use |
This required an update to `eslint-plugin-import`, which, in turn, emtailed updating a few packages. This resulted in the addition of a few new rules. So, there are also changes to adhere to the new rules. Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
TypeScript linting is not quite correctly intergrated with VS code, but the current eslint and tsc-lint npm scripts have TS linting in pretty good shape. tsc-lint endeavors to build the TS files but does not emit them, thereby filling in the gaps left by eslint TS support. Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
colno?: number, | ||
error?: any, | ||
}; | ||
/// <reference path="custom.d.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.
Does this file serve a purpose if it is just comments?
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.
Hey, thought I responded to this. Yes, it does. Added docs for this, here:
- Main type exports moved from src/types/layout to src/types/index - Change worker alias to be more obvious, e.g. "worker-alias" - Various props made optional on: - DirectedGraph - PureEdges - PureNodes Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
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.
LGTM. Left some minor comments, most of which have to do with creating issues for future work.
Signed-off-by: Joe Farro <[email protected]>
Signed-off-by: Joe Farro <[email protected]>
* Shift plexus to TypeScript (from flowtypes) Main outstanding items are to add linting to plexus TS files and more comments in the plexus build related files. Signed-off-by: Joe Farro <[email protected]> * Typo from renaming Signed-off-by: Joe Farro <[email protected]> * Add linting for plexus TypeScript This required an update to `eslint-plugin-import`, which, in turn, emtailed updating a few packages. This resulted in the addition of a few new rules. So, there are also changes to adhere to the new rules. Signed-off-by: Joe Farro <[email protected]> * Fix a few issues from merging master Signed-off-by: Joe Farro <[email protected]> * Better linting for plexus / TypeScript TypeScript linting is not quite correctly intergrated with VS code, but the current eslint and tsc-lint npm scripts have TS linting in pretty good shape. tsc-lint endeavors to build the TS files but does not emit them, thereby filling in the gaps left by eslint TS support. Signed-off-by: Joe Farro <[email protected]> * Fix lint error from merging master Signed-off-by: Joe Farro <[email protected]> * TypeScript type cleanup Signed-off-by: Joe Farro <[email protected]> * Build docs for root and plexus, revive plexus demo - Main type exports moved from src/types/layout to src/types/index - Change worker alias to be more obvious, e.g. "worker-alias" - Various props made optional on: - DirectedGraph - PureEdges - PureNodes Signed-off-by: Joe Farro <[email protected]> * Update changelog Signed-off-by: Joe Farro <[email protected]> * Misc cleanup and add GitHub tickets to build docs Signed-off-by: Joe Farro <[email protected]> * Add license to package.json for publishing Signed-off-by: Joe Farro <[email protected]> Signed-off-by: vvvprabhakar <[email protected]>
Partially addresses #306.
Outstanding items for this PR (before feedback):