-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby): Use Typescript internally! #19923
Conversation
1fc295e
to
a361d9b
Compare
FYI: #13436 |
a361d9b
to
668d1bc
Compare
668d1bc
to
3fd90e4
Compare
@moonmeister Thank you for the prior art! This is still a bit of an exploration ticket, but the core team is happy to explore this more now! |
@blainekasten good to know, I think it would be huge for the project. Thanks for taking this on. |
3fd90e4
to
00a3e21
Compare
2df0dee
to
9aaa866
Compare
d22e36f
to
ee4bf92
Compare
report.panic(`There was a problem starting the development server`, err) | ||
} | ||
}) | ||
const listener = server.listen(program.port, program.host) |
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.
typescript taught me that this callback function is not called with an error. But good news, we check for the port above and change the port to a new number. So this code was old and unused, but ts taught me to delete it!
ee4bf92
to
9d49c47
Compare
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.
My five cents
fcac80d
to
3ca2f57
Compare
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've added some questions about guidelines and importing modules 👍 Thanks @blainekasten
} = require(`../utils/webpack-error-utils`) | ||
} from "../utils/webpack-error-utils" | ||
|
||
type Cert = { |
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.
Do we want to write down guidelines when to use type or interface? I personally use interface for everything except if I need to use union, intersection, ...
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.
So I've had so many debates about this. There is no longer a practical difference besides syntax with types and interfaces. I'll switch to interfaces because that's more common in the typescript world. One benefit of interfaces is the practice of prefixing with I
makes it obvious when importing whats a type and what's code.
e.g., import { Reporter, IReporter } from 'reporter';
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've had so many debates about this
Haha, I can imagine. Honestly, I don't care, I just think something written about our way of using typescript would be great. If an eslint rule exists I would also use it to keep consistency.
remove flow from eslint Add typings for `got` fix lint drop commit test:check bring back webpack-utils Allow flow to live with typescript fix lint Improve check-ts script and add ts transformation to a second package Fix ts imports Fix gatsby-cli build script address PR comments
3ca2f57
to
d284dc6
Compare
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.
Let's do this. Great work @blainekasten ❤️
Summary
This PR is the result of some exploration work to see what it would take to use TypeScript in gatsby source. This does not enable TypeScript for consumers. The goal of using TypeScript is to have the benefits of a type system to catch errors in our code paths that may not otherwise be easily found. This PR sets up the infrastructure to begin using TS and converts one file,
gatsby/commands/develop
. There is a lot of organizational and process oriented discovery work to still resolve, but they are not blockers for this.What's next
With this PR we enable a slow migration of changing files to TS. The community could definitely get involved here! We'll need to decide some rules on how we want to approach typing our app before we can accept PRs. Things like, sharing types and what types we allow. Our goal is to simplify the types as much as possible, complex types usually mean complex code and a refactor is warranted.