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

Migrate lexical-react to TypeScript (7/n) #2211

Merged
merged 13 commits into from
May 20, 2022
Merged

Conversation

thegreatercurve
Copy link
Contributor

@thegreatercurve thegreatercurve commented May 18, 2022

Continues work on #1242. This PR includes:

  • Migrated 1 package::
    • lexical-react

Migration steps

I ran the below script to update the directories automatically, and then fixed each compiler linter error manually:

#!/usr/bin/env bash
DIRECTORIES=(
    "lexical-react" 
)

for directory in ${DIRECTORIES[@]}; do
    # Preserve commit history
    for i in $(find ./packages/$directory -iname "*.js" -not -path "*dist*");
        do git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).ts";
    done
    for i in $(find ./packages/$directory -iname "*.jsx" -not -path "*dist*");
        do git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).tsx";
    done

    for i in $(find ./packages/$directory -iname "*.ts" -not -path "*dist*" -not -path "flow");
        do sed -i "" "s/boolean %checks/node is ManuallyFindAndReplace/g" $i && sed -i "" "s/: LexicalNode>/ = LexicalNode>/g" $i;
    done
    for i in $(find ./packages/$directory -iname "*.tsx" -not -path "*dist*" -not -path "flow");
        do sed -i "" "s/boolean %checks/node is ManuallyFindAndReplace/g" $i && sed -i "" "s/: LexicalNode>/ = LexicalNode>/g" $i;
    done
    
    npx @khanacademy/flow-to-ts --write "./packages/$directory/**/{!*.d.ts,*.ts}";
    npx @khanacademy/flow-to-ts --write "./packages/$directory/**/*.tsx";
done

npm run prettier:fix;

Bundle sizes

Bundle sizes are consistent with main. Below are some sample packages:

package main TS branch
LexicalCharacterLimitPlugin.prod.js 3.4K 3.4K
LexicalAutoLinkPlugin.prod.js 2.5K 2.5K
LexicalTablePlugin.prod.js 1.6k 1.6K

@vercel
Copy link

vercel bot commented May 18, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview May 20, 2022 at 8:18AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview May 20, 2022 at 8:18AM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 18, 2022
@thegreatercurve thegreatercurve marked this pull request as ready for review May 18, 2022 19:00
@thegreatercurve
Copy link
Contributor Author

@acywatson I'll rebase the serialization PR on top of this and fix any merge conflict. I just want to try and get the TS stuff before the end of the week.

@acywatson
Copy link
Contributor

@acywatson I'll rebase the serialization PR on top of this and fix any merge conflict. I just want to try and get the TS stuff before the end of the week.

That's fine, but let me worry about the rebase, if you don't mind. :)

@thegreatercurve thegreatercurve changed the title Migrate lexical-react to TypeScript (6/n) Migrate lexical-react to TypeScript (7/n) May 18, 2022
Copy link
Contributor

@tylerjbainbridge tylerjbainbridge left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@thegreatercurve thegreatercurve merged commit 8c4e9dd into main May 20, 2022
@thegreatercurve thegreatercurve deleted the lexical-react-ts branch May 20, 2022 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants