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

Enable Typescript 3.8 and update Sewing-kit to latest #2873

Merged
merged 10 commits into from
Mar 25, 2020
Merged

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Mar 25, 2020

WHY are these changes introduced?

Typescript 3.8 contains new syntax abilities (export type) that enable my machinations for drastically simplifying our build process - moving from a two-step thing where we compile our TS files with typescript, then compile that output with babel, to having babel reading the TS files directly.

It's not as simple as "just update typescript" though, as we have to also update all our linting tooling to new versions that understand this new syntax too, which is why we have to update sewing-kit too.

A sewing-kit update includes updates to our linting rules which are almost entirely autofixable but make this PR look a lot bigger and scarier than what it actually is.

Ben, why are you giving us ~400 file PRs to review on hackdays FFS

Yeah sorry. I figure it's a lot cleaner to do this piece by piece, get this pulled into the v5 branch, and then make do my build wrangling there, rather than hacking together an even bigger monstrosity that I then have to pick apart and submit piece by piece later on anyway.

WHAT is this pull request doing?

  • Updates sewing-kit to the latest version - this is needed because it contains updates to linting configs so that they support the new typescript syntax
  • Adds a resolution for prettier v2 - also needed because it's where support for the new syntax was added. I've updated SK to use prettier v2, but it's not been released just yet. As soon as that gets released we can update to the newest SK and remove this resolution.
  • Performs linting fixes as a result of pulling in an up-to-date version of our linting config. The most notable change here is that it autofixes adding blank lines between the group of imports from packages, and the group of imports that are relative paths. These autofixed lints have been isolated into their own files.
  • Updates typescript to v3.8, which required a few small casts
  • Turns on the "isolatedModules" option in TypeScript which warns us about usage patterns that won't work when we compile directly with babel. This mostly boils down to "you cant reexport a type without using export {SomeType}, you have to do export type {SomeType}.

How to 🎩

It's probably best to code review this on a per-commit basis and you can skip over the "automated update from sk format" commits as that's the same sort of whitespace changes in every file.

Ensure linting, tests and typechecks all pass and storybook looks the same as before.

I've compared the build output of the esnext folder, our index.js, index.es.js and styles.css files with the output from master and they're all functionally identical - just a few changes from babel updates in the index.js and index.es.js files.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2020

🟡 This pull request modifies 30 files and might impact 57 other files. This is an average splash zone for a change, remember to tophat areas that could be affected.

Details:
All files potentially affected (total: 57)
📄 .storybook/main.js (total: 0)

Files potentially affected (total: 0)

📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

📄 babel.config.js (total: 0)

Files potentially affected (total: 0)

📄 config/rollup/namespaced-classname.js (total: 0)

Files potentially affected (total: 0)

📄 config/rollup/plugins/image.js (total: 0)

Files potentially affected (total: 0)

📄 config/rollup/plugins/styles.js (total: 0)

Files potentially affected (total: 0)

🧩 config/typescript/react-transition-group.d.ts (total: 0)

Files potentially affected (total: 0)

📄 package.json (total: 0)

Files potentially affected (total: 0)

🧩 playground/DetailsPage.tsx (total: 0)

Files potentially affected (total: 0)

🧩 playground/Playground.tsx (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/analyze-custom-properties.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/cli.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/tests/analyze-custom-properties.test.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/tests/handle-message.test.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/tests/is-custom-property-declaration.test.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/tests/is-var-function.test.ts (total: 0)

Files potentially affected (total: 0)

🧩 scripts/analyze-custom-properties/tests/visit-all.test.ts (total: 0)

Files potentially affected (total: 0)

📄 scripts/build-consumer.js (total: 0)

Files potentially affected (total: 0)

📄 scripts/build-shrink-ray.js (total: 0)

Files potentially affected (total: 0)

📄 scripts/build.js (total: 0)

Files potentially affected (total: 0)

📄 scripts/color-system-docs.js (total: 0)

Files potentially affected (total: 0)

📄 scripts/new-version-pr-generator.js (total: 0)

Files potentially affected (total: 0)

📄 scripts/readme-update-version.js (total: 0)

Files potentially affected (total: 0)

🧩 scripts/splash/index.tsx (total: 0)

Files potentially affected (total: 0)

📄 scripts/updateQuartiles.js (total: 0)

Files potentially affected (total: 0)

🧩 sewing-kit.config.ts (total: 0)

Files potentially affected (total: 0)

🧩 src/components/AccountConnection/tests/AccountConnection.test.tsx (total: 0)

Files potentially affected (total: 0)

🎨 src/components/ActionList/ActionList.scss (total: 56)

Files potentially affected (total: 56)

🧩 src/components/ActionList/ActionList.tsx (total: 55)

Files potentially affected (total: 55)

🧩 src/components/ActionList/components/Item/Item.tsx (total: 57)

Files potentially affected (total: 57)

@BPScott BPScott changed the title Enable Typescript 3.8 Enable Typescript 3.8 and update Sewing-kit to latest Mar 25, 2020
DataTableProps,
TableData,
TableRow,
SortDirection,
ColumnContentType,
} from './DataTable';

export {DatePicker, DatePickerProps, Range, Months, Year} from './DatePicker';
export {DatePicker, Months} from './DatePicker';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm new to this, and find surprising that Months is in this export statement (rather than the one below, alongside type exports), being an enum. Can you explain why this is the case?

Copy link
Member Author

@BPScott BPScott Mar 25, 2020

Choose a reason for hiding this comment

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

Broadly speaking you've got two sorts of thing: "values" which have some kind of JS output, and "types" which are only used at compile time and get stripped away from the resultant JS.

A enum ends up outputting javascript code so it is a value (same as something like const a =1), which means it gets exported with all our other values (like constants and functions etc).

@kaelig
Copy link
Contributor

kaelig commented Mar 25, 2020

Suggestion: relaxing or disabling selector-max-class at the project level. Thoughts?

@BPScott
Copy link
Member Author

BPScott commented Mar 25, 2020

Suggestion: relaxing or disabling selector-max-class at the project level. Thoughts?

This has some rather funky knock on effects as it intersects with a handful of other rules around selector specificity - you'd want to update them all at the same time.

I don't think it's particularly worth loosening the rules as we mostly fall afoul of this because we're wrapping stuff in .newDesignLanguage and that concept will go away eventually.

Copy link
Contributor

@amrocha amrocha left a comment

Choose a reason for hiding this comment

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

I think I would wait for your sk changes to ship before shipping this, we're not in a rush here and that would remove an intermediary step so it seems like there's no drawbacks

@@ -22,7 +22,8 @@ import {monthName} from './utilities';
import {Month} from './components';
import styles from './DatePicker.scss';

export {Range, Months, Year};
export {Months};
Copy link
Contributor

Choose a reason for hiding this comment

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

What's going on here? Is Months not a type even though it's imported from the same place as Year and Range?

Copy link
Member Author

@BPScott BPScott Mar 25, 2020

Choose a reason for hiding this comment

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

Bingo. Months is an enum, while Range and Year are both types. See https://github.com/Shopify/javascript-utilities/blob/master/src/dates.ts#L11

Follow up questions: is this annoying and would it be better if Months was a union type like type Months = 0 |1|2|3|4|5|6|7|8|9|10|11? Yeah probably, but thar be dragons in the javascript-utilities packages and I want to stop relying on it eventually so just stick your fingers in your ears and ignore it for now :D

@kaelig
Copy link
Contributor

kaelig commented Mar 25, 2020

I think I would wait for your sk changes to ship before shipping this, we're not in a rush here and that would remove an intermediary step so it seems like there's no drawbacks

One drawback I can see is that this is a large PR that touches a lot of files, meaning the risk of encountering merge conflicts increases quite a bit as time goes by. Not a huge issue, but could be leading to more work than shipping this in 2 steps.

@BPScott
Copy link
Member Author

BPScott commented Mar 25, 2020

I think I would wait for your sk changes to ship before shipping this, we're not in a rush here and that would remove an intermediary step so it seems like there's no drawbacks

One drawback I can see is that this is a large PR that touches a lot of files, meaning the risk of encountering merge conflicts increases quite a bit as time goes by. Not a huge issue, but could be leading to more work than shipping this in 2 steps.

Yep, that pretty much. Getting this in now unblocks me doing other stuff, that'll be much easier to shuffle around without all this other noise. The update to the currently-unreleased SK will comparativly empty as there won't be any new linting rules appearing, that'll be less effort than trying to rebase this lot.

Copy link
Contributor

@kaelig kaelig left a comment

Choose a reason for hiding this comment

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

I 🎩'd build-consumer (with the style guide) and yarn storybook, both work great ✨

@BPScott BPScott merged commit 86e72e9 into master Mar 25, 2020
@BPScott BPScott deleted the bump-sk-new branch March 25, 2020 23:22
@alex-page alex-page temporarily deployed to polaris-release April 3, 2020 14:06 Inactive
@alex-page alex-page temporarily deployed to polaris-release April 3, 2020 14:06 Inactive
@alex-page alex-page temporarily deployed to production April 3, 2020 19:37 Inactive
@alex-page alex-page requested a deployment to production April 3, 2020 19:37 Abandoned
@alex-page alex-page temporarily deployed to production April 3, 2020 19:37 Inactive
@alex-page alex-page temporarily deployed to production April 3, 2020 19:43 Inactive
@alex-page alex-page requested a deployment to production April 3, 2020 19:43 Abandoned
@alex-page alex-page temporarily deployed to production April 3, 2020 19:43 Inactive
@alex-page alex-page temporarily deployed to production April 3, 2020 19:56 Inactive
@alex-page alex-page requested a deployment to production April 3, 2020 19:56 Abandoned
@alex-page alex-page temporarily deployed to production April 3, 2020 19:56 Inactive
@alex-page alex-page temporarily deployed to production April 3, 2020 20:01 Inactive
@alex-page alex-page requested a deployment to production April 3, 2020 20:01 Abandoned
@alex-page alex-page temporarily deployed to production April 3, 2020 20:01 Inactive
@alex-page alex-page temporarily deployed to production April 3, 2020 20:10 Inactive
@alex-page alex-page requested a deployment to production April 3, 2020 20:10 Abandoned
@alex-page alex-page temporarily deployed to production April 3, 2020 20:10 Inactive
@BPScott BPScott temporarily deployed to production April 3, 2020 20:51 Inactive
@BPScott BPScott temporarily deployed to production April 3, 2020 20:51 Inactive
@BPScott BPScott temporarily deployed to production-test April 6, 2020 20:44 Inactive
@BPScott BPScott requested a deployment to production-test April 6, 2020 20:44 Abandoned
@BPScott BPScott temporarily deployed to production-test April 6, 2020 20:44 Inactive
@alex-page alex-page temporarily deployed to release-test-version April 16, 2020 20:33 Inactive
@alex-page alex-page temporarily deployed to release-test-version April 16, 2020 20:33 Inactive
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.

4 participants