-
Notifications
You must be signed in to change notification settings - Fork 3
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
chore: Replace Flowtype with Typescript #3
Conversation
Setting up the repo to run with Typescript instead of Flowtype. This required changing the initial code, updating Jest & updating ESLint. Also: - Move eslint configuration into its own `.eslintrc.json` - Removing Babel as its replaced by Typescript (except `babel-eslint` which is needed by `eslint-config-eventbrite`)
|
||
# Target files | ||
lib/ | ||
dist/ |
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.
should we add **/.DS_Store ? Those files always show up for me
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.
Really? I've never seen those. I guess the first person to run into can add it. I don't have any to verify that it's working
config/jest-preprocess-typescript.js
Outdated
|
||
module.exports = { | ||
process(src, path) { | ||
if (path.endsWith(".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.
i might use, path.extname but i think it will be the same
https://nodejs.org/dist/latest-v8.x/docs/api/path.html#path_path_extname_path
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.
Oh I like that! The official Jest-Typescript example did this. 🤦♂️
"format": "prettier-eslint --write", | ||
"lint": "eslint src", | ||
"lint": "eslint --cache --max-warnings 0 --ext .ts,.js src", |
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.
that cache is key! thanks!
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.
thanks for the change!
.npmignore
Outdated
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
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.
*.log should capture all three below, no?
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.
Yeah that sounds about right...
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.
awesome! sounds good
#3 Replaced Flow w/ Typescript and as a result removed Babel because TypeScript both transpiles and type checks. However this makes us miss out on a lot of the plugins that are a part of the Babel community. Babel 7 adds support for Typescript. Use babel 7 to build assets instead of tsc. The tsc command is still used for static type checking. Note that the babel typescript plugin will transpile code regardless of its typecheck correctyness. tsc is also still used to generate the declaration files, since it looks as though the babel-typescript-plugin does not support creating those at this time. However there's a "create declaration only" flag that is convenient for this. I've excluded the .spec files from the babel build, so now they won't appear in lib. I didn't move the ignore declaration into the .babelrc because I can imagine a situation where we might want to use a cool feature in our test suite that babel can transpile for is (even though node 8 gets us there at the moment). However there's never a need to have the transpiled versions in our lib. Lastly, we can now support async await etc with the additions of lib -- es2015 and dom which I think will be especially useful in our tests because most of our exports will likely be functions that return promises. PS: i'm not tied to the tests, i just want to prove that they work! I'm happy to remove them, as we definitely should in the future, thought it might be nice while we're building the foundation though. Fixes #4
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Setting up the repo to run with Typescript instead of Flowtype. This required changing the initial code, updating Jest & updating ESLint.
Also:
.eslintrc.json
babel-eslint
which is needed byeslint-config-eventbrite
)(Filed #4 to upgrade to Babel 7 and use Babel + TypeScript)