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

client: Port to TypeScript #1457

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

client: Port to TypeScript #1457

wants to merge 18 commits into from

Conversation

jtojnar
Copy link
Member

@jtojnar jtojnar commented Jul 29, 2023

No description provided.

@netlify
Copy link

netlify bot commented Jul 29, 2023

Deploy Preview for selfoss canceled.

Name Link
🔨 Latest commit e2c447d
🔍 Latest deploy log https://app.netlify.com/sites/selfoss/deploys/64d010f1df4c5400072a93c2

Copy link

netlify bot commented May 30, 2024

Deploy Preview for selfoss canceled.

Name Link
🔨 Latest commit 25c78e1
🔍 Latest deploy log https://app.netlify.com/sites/selfoss/deploys/668f85f9e7162f0008095e00

@jtojnar jtojnar force-pushed the ts branch 2 times, most recently from 78d2233 to 9a83804 Compare June 6, 2024 08:27
I do not like the formatting very much but at least it is consistent and supports TypeScript.
https://typescript-eslint.io/troubleshooting/formatting/

Also replaces `lint:js` npm script in the `client/` directory with `check:js:lint`
and adds `check:js` which runs that in addition to newly introduced `check:js:prettify`.
This matches how the stylesheet scripts are structured.

We are using `eslint-config-prettier` instead of `eslint-plugin-prettier`,
the latter would run prettier as part of eslint but we are already running it separately.

TODO: Remove stylistic rules from config.
We are exporting other symbols as well and mixing default export
with regular ones is considered bad practice apparently.
React 19 removes propTypes, which were deprecated since 2017:
https://19.react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-deprecated-react-apis

The recommended replacement is using TypeScript.

Given that the code base is a mess but dynamic nature of JavaScript
gives us little hope of cleaning it without introducing a ton of regressions
I have decided to bite the bullet.

In this commit, I mostly used https://www.npmjs.com/package/js-to-ts-converter

Additionally, I had to perform the following manually changes:

- Update references in package.json, index.html and selfoss-base.
- Switch to typescript-eslint.
- Declare `selfoss` inside `window`.
They have been deprecated since 2017.
Also fix a bug in ajax code not spreading the rest field.
Using static for now to minimize required changes
so that tsc can find it.
Another long standing bug discovered by TypeScript.
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.

1 participant