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

Enable import autofix? #31

Open
MichaelMitchell-at opened this issue May 2, 2024 · 0 comments
Open

Enable import autofix? #31

MichaelMitchell-at opened this issue May 2, 2024 · 0 comments

Comments

@MichaelMitchell-at
Copy link
Contributor

MichaelMitchell-at commented May 2, 2024

I noticed that the import autofix is disabled here

ts-fix/src/index.ts

Lines 260 to 262 in 2898fac

function isNotAppliedFix(fixAndDiagnostic: FixAndDiagnostic): boolean {
return !fixAndDiagnostic.fix.changes.length
|| fixAndDiagnostic.fix.fixName === 'import'

I can maybe see why it's disabled by default, but it would be nice to at least be able to use it if -f import is explicitly provided on the CLI. One use case is that the autofixer for isolatedDeclarations sometimes adds type annotations using inline imports, e.g.

const foo: import('some/module').Foo = ...;

which is not our, and probably not many others', preferred style.

So what I'll do is use a regular expression to just remove all the import('...'). parts, but then now I need to add top-level imports for a bunch of types. This is where the import autofix comes in clutch. I commented out that line above in ts-fix and ran the autofixer and it pretty much worked flawlessly.

Just wanted to provide a data point, but feel free to close if not likely to be implemented.

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

No branches or pull requests

1 participant