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

Issue 661 Tech Radar Typescript refactor #1080

Merged
merged 17 commits into from Jun 8, 2020

Conversation

NWCalvank
Copy link
Contributor

Hey, I just made a Pull Request!

If successful, this PR has no effect on the end-user.

Change Summary

  • Refactor Tech Radar from JavaScript to TypeScript
  • Convert Tech Radar to use React Functional Components & Hooks
  • Remove PropTypes from Tech Radar

Notes on the Approach

I have taken a very naive approach to this refactor. In an effort to limit the scope of the change and potential regressions, I have opted to:

  • Rename / restructure / modify only the code required to support the language and style change
  • Avoid introducing any new opinions about how this plugin could be written (leaving code as-is)
  • Infer types, where possible, from existing code and leave less-certain types suitably vague
  • Attempt, wherever possible, to maintain the apparent shapes of existing component interfaces (ex. things that are not required in the PropTypes retain null | undefined definition even when the component itself seemed to assume this was not the case).

I removed the PropTypes from Tech Radar as it appeared to be the only plugin still using PropType validation, which did not cooperate very well with TypeScript. If this is not a desirable change, please advise.

Future Work

  • Style cleanup (renaming, separating, etc), once we've confirmed that this first round of changes has not caused numerous regressions
  • More tests, as mentioned as a stretch for this issue.
  • Narrowing types, where appropriate
  • Converting the Segment class to use TypeScript

✔️ Checklist

  • All tests are passing yarn test
  • Screenshots attached (for UI changes)
  • Relevant documentation updated
  • Prettier run on changed files
  • Tests added for new functionality
  • Regression tests added for bug fixes

Seeing some errors that I don't fully understand around the proptypes
assertions seemingly being treated as null | undefined values.

It looks like I'll need to type Segment, which is not explicitly
in-scope for this issue.
I incorrectly added type safety to the original implementation, causing
the segments to no longer be populated here. This change fixes that
regression while retaining the type safety.

This is all necessary because qidx and ridx are apparently both
nullable.
A global search looks like no other plugins use PropTypes. I'm about to
remove them in the next commit because shapes don't seem to cooperate
with TypeScript, making the PropTypes either so vague that they're
mostly useless or specific enough to fail the build.

With that said, I wanted to get this version committed in case I need to
roll back to here. I wouldn't want to redo this work.
I could see these being split into separate files, but I think this is
enough for now.
@NWCalvank NWCalvank requested a review from a team as a code owner May 31, 2020 02:00
I'm not confident in this change. I'm very unclear about the reasoning
behind the type definitions in api.ts as they don't reflect the shape of
the values that I see when I print `data.entries` in the console.

The value of data.entries reflects a fully-populated Entry[], not a
RadarEntry[].

As such, I'm also not sure about the sample data. I would be more
hesitant to updated it, but the fact that the rest of the components
seem to be expecting that data makes it seem fairly clear that it must
be required to be in the updated shape.
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

Good to merge @bih?

@stefanalund stefanalund merged commit 4213098 into backstage:master Jun 8, 2020
@NWCalvank NWCalvank deleted the issue-661-typescript-refactor branch June 8, 2020 14:35
benjdlambert added a commit that referenced this pull request Jun 8, 2020
…entities

* 'master' of github.com:spotify/backstage: (87 commits)
  Minor tweaks to catalog UI (#1176)
  plugins/tech-radar: fix lint issue in RadarBubble
  Fix backend startup instructions (#1188)
  Changed order of backend install instructions
  Issue 661 Tech Radar Typescript refactor (#1080)
  build(deps-dev): bump eslint-plugin-cypress from 2.10.3 to 2.11.1 (#1184)
  build(deps): bump eslint-plugin-import from 2.20.2 to 2.21.1 (#1183)
  Fix backend not starting (#1185)
  fix page reload when clicking on logo (#1178)
  Add background color for tabs (#1170)
  chore(navigation/tabs): fixing prop type validation (#1173)
  Change example component names (#1165)
  chore(Catalog/Tabs): remove extraneous file from otber branch
  packages/cli: avoid duplicate dependency warning in E2E test
  build(deps): [security] bump websocket-extensions from 0.1.3 to 0.1.4
  feat(Catalog/tabs): added some sample tabs for now
  Added HeaderTabs to ComponentPage
  fix: import from package
  fix: type checking
  fix: tests
  ...
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.

None yet

3 participants