-
Notifications
You must be signed in to change notification settings - Fork 336
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
Turn remaining files into TypeScript source #758
Turn remaining files into TypeScript source #758
Conversation
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.
There are quite a few formatting changes here. These were mostly inserted by my IDE because of the Prettier configuration (as master isn't actually following the prettier config).
It would maybe be an idea to add a CI step to check the formatting.
export function getBlogPostsByYear({ limit } = {}) { | ||
export function getBlogPostsByYear(limit?: number) { | ||
let count = 0; | ||
return cachedPaths().reduce((years, post) => { | ||
if (limit != null && count >= limit) { | ||
if (limit !== undefined && count >= limit) { |
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 believe it's just as easy to make this limit a regular value, and not an object. It makes it a little nicer to type it as well.
@@ -6,7 +6,7 @@ | |||
"scripts": { | |||
"dev": "next dev", | |||
"build": "next build && npm run build:rss && next export", | |||
"build:rss": "node ./scripts/generate-rss-feed.js", | |||
"build:rss": "tsc --outDir dist --noEmit false && sed -i 's/markdown\"/markdown.js\"/g' dist/lib/api.js && node scripts/generate-rss-feed.js", |
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.
This is a small workaround for Webpack not supporting ".js" imports in TypeScript source (TypeScript itself does, but Webpack is the issue here).
Since node with type: module
requires full file extensions, I need to rewrite an import in the compiled javascript code.
An alternative would be using something like https://www.npmjs.com/package/tsx or https://www.npmjs.com/package/ts-node to execute TypeScript directly, but I didn't want to add any new dependencies
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 the npm install
and npm run dev
commands in the readme still work?
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, nothing has changed there. npm run build:rss
also works as expected
I merged the other PR with automatic formatting. Please resolve the merge conflicts. |
1f6f899
to
3b0e58e
Compare
Thanks! I have resolved the conflicts now |
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.
Looks sensible to me. I clicked around and it seems like it still works.
Hi! This is a small patch for turning the remainder of the source files into TypeScript.
While I was working on this patch, I noticed we're compiling TypeScript with
strict: false
which means we lose most of the safety TypeScript gives us. I would be willing to do the necessary changes to enable strict mode in a different patch 😃As with other parts of the codebase, there are a lot of untyped/loosely typed things which I've just left as-is for now. I've left some TODO comments in the relevant places. I would like some feedback before I commit to any larger changes!
Let me know if there are any questions or concerns. Thanks!