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

Move to TypeScript #9

Merged
merged 24 commits into from
Oct 6, 2020
Merged

Move to TypeScript #9

merged 24 commits into from
Oct 6, 2020

Conversation

andy-hook
Copy link

@andy-hook andy-hook commented Sep 28, 2020

I wanted to start setting up typescript for some of our packages and this one was a simple, easy first go.

I thought it was a good idea to standardise around TSDX inline with @bpierre's work on use-wallet aragon/use-wallet#51

I moved us away from class components but otherwise the logic is the same but typed.

@andy-hook andy-hook requested review from bpierre and Evalir September 28, 2020 18:50
.eslintrc.js Outdated
Comment on lines 3 to 4
'react-app',
'prettier/@typescript-eslint',
Copy link
Author

Choose a reason for hiding this comment

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

These are the ejected defaults via yarn lint --write-file so I could use the hooks plugin. Do we want to be explicit here with our own standards?

Copy link

Choose a reason for hiding this comment

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

Good question, I've never looked, but do you know if there a good way to diff between different eslint configs?

Since we're currently in a reset phase, this may also be a good time to standardize an eslint config for JS and TS.

Copy link
Author

@andy-hook andy-hook Sep 29, 2020

Choose a reason for hiding this comment

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

I was thinking about this and I really like the idea of standardising around a single opinionated tool. The more of this configuration we can offload the more we can focus on the building, so for the TS projects I was thinking we could just straight up use the provided values and leave it there, see how we get on?

These customisations I made were actually unnecessary, the tool ships with all the setting we would want, my editor just couldn't see the configuration.

I followed their suggested fix jaredpalmer/tsdx#379 (comment) and exported unedited default settings in 9dd0d73

Copy link

Choose a reason for hiding this comment

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

Interesting, so VSC can't automatically resolve TSDX's default config without ejecting them?

I've been procrastinating on setting up "standard" linting configs in https://github.com/aragon/github for forever, but now is a good chance. I'll get a structure going—I was mainly thinking of packaging something like eslint-config-aragon-ts-react (and etc. for other environments).

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a package for our config would be lovely! And yeah, for some reason VSCode sometimes has a hard time reading configs with TSDX 😅

@andy-hook andy-hook changed the title Move to TypeScript [WIP] Move to TypeScript Sep 28, 2020
@andy-hook andy-hook changed the title [WIP] Move to TypeScript Move to TypeScript Sep 28, 2020
Copy link

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Left a couple of notes but looking good for me; let's also have @Evalir have a look once he's back :).

.eslintrc.js Outdated Show resolved Hide resolved
.eslintrc.js Outdated
Comment on lines 3 to 4
'react-app',
'prettier/@typescript-eslint',
Copy link

Choose a reason for hiding this comment

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

Good question, I've never looked, but do you know if there a good way to diff between different eslint configs?

Since we're currently in a reset phase, this may also be a good time to standardize an eslint config for JS and TS.

.eslintrc.js Show resolved Hide resolved
examples/simple-viewport/index.tsx Outdated Show resolved Hide resolved
src/viewport.tsx Show resolved Hide resolved
src/viewport.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

Looking good 😍 ! tested locally with a few projects and all seems fine.

Copy link
Contributor

@bpierre bpierre left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀 🚀 🚀

package.json Outdated Show resolved Hide resolved
"dist"
],
"engines": {
"node": ">=10"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can safely remove support for Node 10 everywhere:

Suggested change
"node": ">=10"
"node": ">=12"

Copy link
Author

Choose a reason for hiding this comment

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

Hmmm it seems the codesandbox containers only run v10 and fail unless we explicitly install a node version in the examples. I'm thinking unless we have a strong need to drop the support it'll be simpler to leave it for now: https://codesandbox.io/docs/faq#can-i-change-the-node-version-used-in-a-container-sandbox

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, let’s leave it then 👍

package.json Outdated Show resolved Hide resolved
.eslintrc.js Outdated
},
settings: {
react: {
pragma: 'React',
version: '16.6',
version: '999.999.999',
Copy link
Contributor

Choose a reason for hiding this comment

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

What would you think about doing this?

Suggested change
version: '999.999.999',
version: require('./package.json').peerDependencies.react,

Copy link
Author

@andy-hook andy-hook Oct 6, 2020

Choose a reason for hiding this comment

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

It's a good idea! but I think keeping the config free of side effects would be simpler and more portable. For consistency I've reverted to being explicit with the version and pragma.

.eslintrc.js Outdated Show resolved Hide resolved
@andy-hook andy-hook merged commit 619d069 into master Oct 6, 2020
@andy-hook andy-hook deleted the typescript branch October 6, 2020 11:44
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