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

Modification Cornucopia #168

Open
NickHeiner opened this issue May 9, 2022 · 9 comments
Open

Modification Cornucopia #168

NickHeiner opened this issue May 9, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@NickHeiner
Copy link

NickHeiner commented May 9, 2022

Hi. I recently used ts-migrate, in conjunction with my own codemod runner, to migrate large portions of my codebase to TS. It was fun!

Along the way, I made a series of modifications to make ts-migrate work for my repo. Some of them are likely specific to my idiosyncrasies, but some may be generally applicable. I'll list them here, and you can tell me which, if any, you're interested in. I'll then carve individual PRs for the pieces you want.

Change List

Here's the full set of changes, but it's a bit noisy because some of it is things I'd never recommend merging / it's not cleaned up for you. So I'll also link to individual commits in the list below, but it's not always a 1:1 mapping 🤪 .

Anyway, lmk if you're interested in any of this. 😄

Task Tracking

Completed Changes

  • TS update to 4.7 – looks like someone got there before me. 😄
@Rudeg
Copy link
Contributor

Rudeg commented May 20, 2022

Hi @NickHeiner ,

Sorry for the delay.

I'm glad that ts-migrate helped you with migration!
Some of those changes would definitely be nice to merge into the ts-migrate.

Those seem like good candidates to be added:

It would probably be better to add a generic ability to skip plugin/plugging instead of custom options for each plugin.

Let me know what you think!

@NickHeiner
Copy link
Author

Cool – I'll probably have time to do some of these PRs in a month or so. Or anyone else is welcome to make an attempt in the meantime. 😄

Also, I recently ran into issues that I think are attributable to a stale tsbuildinfo after updating the compilerOptions in tsconfig. This may account for some instances where ts-migrate inserted ts-expect-errors unnecessarily, or failed to insert some that were needed. I don't have a bulletproof repro yet, but it may be safer for ts-migrate to delete tsbuildinfo before building the TS project, to avoid any such risks.

@devinrhode2
Copy link

idk if it's just me... but I'd much rather try my luck with @NickHeiner's fork instead of the current master

I took @NickHeiner's fork and carefully rebased it onto latest upstream/master (airbnb/master)

git remote add devinrhode2 git@github.com:devinrhode2/ts-migrate.git
git checkout --track devinrhode2/nth/tvui-modifications-rebased-by-devin

I'm not sure of the BEST way to use it locally... I guess I need to learn a little bit of Lerna.. maybe use yalc

@devinrhode2
Copy link

@NickHeiner or anyone, if you have any idea how to use a fork of ts-migrate locally, that would be great :)

It's easy to clone the fork, install deps, run various npm scripts... but I'm not sure how to then use that inside of my company's project... presumably I need to basically npm install ../path/to/project but the tricky part is that ts-migrate uses Lerna, so.. I'm not sure just doing npm install ../path would work

@NickHeiner
Copy link
Author

You want to use link for the use-case of pointing one repo to a dep that's another local repo.

I recommend doing:

# in the ts-migrate repo
yarn
yarn build
yarn link

# In the repo you want to use ts-migrate from
yarn link ts-migrate

If your repo is using npm, then maybe npm link will work. But I'm not sure how it works when one project is using npm and the other is using yarn. Maybe you can npm link in both repos.

@devinrhode2

This comment was marked as off-topic.

@NickHeiner
Copy link
Author

NickHeiner commented Jun 21, 2022 via email

@devinrhode2
Copy link

devinrhode2 commented Jun 21, 2022

@NickHeiner all those setup steps ran without warnings or errors, but when I finally ran yarn run ts-migrate locally, it was as if ts-migrate was not actually installed.

I did have success using verdaccio instead:

npm install --global verdaccio@6-next
verdaccio

Publish forked package locally:

git clone https://github.com/devinrhode2/ts-migrate.git ts-migrate-devin
cd ts-migrate-devin
git checkout nth/tvui-modifications-rebased-by-devin
yarn install
yarn run bootstrap
yarn run build
npm adduser --registry http://localhost:4873
YARN_REGISTRY=http://localhost:4873 yarn lerna publish

finally:

YARN_REGISTRY=http://localhost:4873 yarn add ts-migrate --dev

@NickHeiner
Copy link
Author

NickHeiner commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants