Skip to content
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

Merged
merged 14 commits into from
Mar 8, 2019
Merged

Shift plexus to TypeScript (from flowtypes) #331

merged 14 commits into from
Mar 8, 2019

Conversation

tiffon
Copy link
Member

@tiffon tiffon commented Feb 16, 2019

Partially addresses #306.

Outstanding items for this PR (before feedback):

  • Linting TypeScript in plexus
  • Document the build related changes
  • Misc cleanup
  • Resurrect the demo

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 <joef@uber.com>
@ghost ghost assigned tiffon Feb 16, 2019
@ghost ghost added the review label Feb 16, 2019
Signed-off-by: Joe Farro <joef@uber.com>
@codecov
Copy link

codecov bot commented Feb 16, 2019

Codecov Report

Merging #331 into master will increase coverage by 0.12%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...ts/TracePage/TraceTimelineViewer/SpanTreeOffset.js 100% <ø> (ø) ⬆️
...ckages/jaeger-ui/src/components/common/CopyIcon.js 100% <ø> (ø) ⬆️
...jaeger-ui/src/components/App/TraceIDSearchInput.js 0% <ø> (ø) ⬆️
...kages/jaeger-ui/src/components/common/TraceName.js 5.55% <ø> (ø) ⬆️
.../jaeger-ui/src/components/DependencyGraph/index.js 100% <ø> (ø) ⬆️
...aceTimelineViewer/SpanDetail/AccordianKeyValues.js 100% <ø> (ø) ⬆️
...components/DependencyGraph/DependencyForceGraph.js 84.21% <ø> (ø) ⬆️
...omponents/TraceDiff/TraceDiffHeader/TraceHeader.js 100% <ø> (ø) ⬆️
...Page/TraceTimelineViewer/SpanDetail/DetailState.js 94.44% <ø> (ø) ⬆️
packages/jaeger-ui/src/utils/color-generator.js 100% <ø> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update caf91a7...d346860. Read the comment docs.

Copy link
Collaborator

@everett980 everett980 left a 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 Enums used to define values before, but that seems to be working well here. I also haven't used Enums 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.

packages/jaeger-ui/.env Outdated Show resolved Hide resolved
packages/jaeger-ui/config-overrides.js Outdated Show resolved Hide resolved
packages/jaeger-ui/src/utils/DraggableManager/README.md Outdated Show resolved Hide resolved
packages/plexus/.neutrinorc.js Show resolved Hide resolved
packages/plexus/src/DirectedGraph/DirectedGraph.tsx Outdated Show resolved Hide resolved
@@ -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';
Copy link
Collaborator

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.

Copy link
Member Author

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';
Copy link
Collaborator

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

Copy link
Member Author

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,
Copy link
Collaborator

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.

Copy link
Member Author

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.

@tiffon
Copy link
Member Author

tiffon commented Feb 22, 2019

Update

Contrary to the docs on void, when in strict mode, only undefined can be assigned to values of type void.

I've marked out the incorrect comments, below.


@everett980 Thanks for reviewing! Will check out your comments.

key: Type | void;
or
key?: Type;
or
key?: Type | void;

In the above, key: Type | void means the value will either be an instance of Type or one of the values null or undefined. It's the equivalent of key: Type | undefined key: ?Type in flow.

key?: Type means the presence of key is optional.

key?: Type | void is a combo of the two: the presence of key is optional and if present it can be either a Type instance or null or undefined.

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.

Agreed. Turns out I missed a few!

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.

I think we should use ; because that's the style used by the TS team.

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 <joef@uber.com>
Signed-off-by: Joe Farro <joef@uber.com>
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 <joef@uber.com>
Signed-off-by: Joe Farro <joef@uber.com>
Signed-off-by: Joe Farro <joef@uber.com>
colno?: number,
error?: any,
};
/// <reference path="custom.d.ts" />
Copy link
Collaborator

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?

Copy link
Member Author

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:

https://github.com/jaegertracing/jaeger-ui/pull/331/files#diff-c21202b241d0cd40822db520c8b00770R103

tiffon and others added 3 commits March 7, 2019 11:00
- 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 <joef@uber.com>
Signed-off-by: Joe Farro <joef@uber.com>
Copy link
Collaborator

@everett980 everett980 left a 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.

BUILD.md Outdated Show resolved Hide resolved
BUILD.md Outdated Show resolved Hide resolved
BUILD.md Outdated Show resolved Hide resolved
BUILD.md Show resolved Hide resolved
BUILD.md Outdated Show resolved Hide resolved
BUILD.md Outdated Show resolved Hide resolved
packages/plexus/BUILD.md Outdated Show resolved Hide resolved
packages/plexus/demo/src/index.tsx Outdated Show resolved Hide resolved
packages/plexus/demo/src/index.tsx Outdated Show resolved Hide resolved
Signed-off-by: Joe Farro <joef@uber.com>
Signed-off-by: Joe Farro <joef@uber.com>
@tiffon tiffon merged commit 2a179bf into master Mar 8, 2019
@ghost ghost removed the review label Mar 8, 2019
@yurishkuro yurishkuro deleted the plexus-to-ts branch January 29, 2020 15:07
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 5, 2021
* 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 <joef@uber.com>

* Typo from renaming

Signed-off-by: Joe Farro <joef@uber.com>

* 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 <joef@uber.com>

* Fix a few issues from merging master

Signed-off-by: Joe Farro <joef@uber.com>

* 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 <joef@uber.com>

* Fix lint error from merging master

Signed-off-by: Joe Farro <joef@uber.com>

* TypeScript type cleanup

Signed-off-by: Joe Farro <joef@uber.com>

* 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 <joef@uber.com>

* Update changelog

Signed-off-by: Joe Farro <joef@uber.com>

* Misc cleanup and add GitHub tickets to build docs

Signed-off-by: Joe Farro <joef@uber.com>

* Add license to package.json for publishing

Signed-off-by: Joe Farro <joef@uber.com>

Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants