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 LexicalClipboard to TypeScript (5/n) #2151

Merged
merged 2 commits into from
May 15, 2022
Merged

Conversation

thegreatercurve
Copy link
Contributor

@thegreatercurve thegreatercurve commented May 12, 2022

Continues work on #1242. This PR includes:

  • Migrated 1 package solo as it created some type errors with core:
    • lexical-clipboard

Migration steps

I ran the below script to update the directories automatically, and then went through each one fixing the result TypeScript compiler errors, and Lint errors which prevents Vite from building the playground.

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

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 "*__tests__*" -not -path "*dist*" -not -path "flow");
        do sed -i "" "s/boolean %checks/node is FindAndReplace/g" $i;
    done
    for i in $(find ./packages/$directory -iname "*.tsx" -not -path "*__tests__*" -not -path "*dist*" -not -path "flow");
        do sed -i "" "s/boolean %checks/node is FindAndReplace/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

All looks good with the bundle sizes after running npm run build-www. We're still making the most out of Google Closure Compiler:

package main TS branch
LexicalClipboard.prod.js 6.2K 6.2K

@vercel
Copy link

vercel bot commented May 12, 2022

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

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview May 12, 2022 at 10:00AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview May 12, 2022 at 10:00AM (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 12, 2022
@thegreatercurve thegreatercurve changed the title Migrate LexicalClipboard to TS (5/n) Migrate LexicalClipboard to TypeScript (5/n) May 12, 2022
@thegreatercurve thegreatercurve marked this pull request as ready for review May 12, 2022 10:02
Copy link
Collaborator

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

Nice work!

@thegreatercurve thegreatercurve merged commit 46e84d9 into main May 15, 2022
@trueadm trueadm deleted the clipboard-types branch November 21, 2022 21:36
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