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

Suggest autofixes for declaration diagnostics #30

Merged

Conversation

MichaelMitchell-at
Copy link
Contributor

@MichaelMitchell-at MichaelMitchell-at commented Apr 30, 2024

This is to allow autofixes for errors like microsoft/TypeScript#58260.

Test plan:

  • Build and install the TS branch above
  • Have a TS project with isolatedDeclarations enabled and containing exports whose types cannot be inferred trivially.
  • Run ts-fix -t <path_to_tsconfig> -e9013 -f add-annotation --write --ignoreGitStatus and verify that type annotations are automatically added where necessary.

Fixes #32

@@ -112,16 +112,16 @@ export const checkOptions = async (opt: Options): Promise<[string[], string[]]>

// Check git status if the write flag was provided and the output folder is the same as the project folder
// Do not allow overwriting files with previous changes on them unless --ignoreGitStatus flag was provided
if (opt.write && path.dirname(opt.tsconfig) === opt.outputFolder) {
if (!opt.ignoreGitStatus && opt.write && path.dirname(opt.tsconfig) === opt.outputFolder) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't make sense to run any of the code in this block if ignoreGitStatus is true.

It will also just crash on MacOS due to #26. Not bothering to fix that as there's already an (over-year old) PR for that at #23.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I noticed this one when I tried ts-fix last.

@MichaelMitchell-at
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Airtable"

Copy link
Contributor Author

@MichaelMitchell-at MichaelMitchell-at left a comment

Choose a reason for hiding this comment

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

I would suggest running a code formatter over this repo. Too invasive of a change to include in this PR, but very tempting.

src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

LGTM though most of the diff is unrelated stuff 😄

@MichaelMitchell-at
Copy link
Contributor Author

LGTM though most of the diff is unrelated stuff 😄

Gotta sneak these in somehow 😉 (since typo fix PRs tend to look like spam)

@jakebailey
Copy link
Member

CI doesn't like this PR, it's probably not your fault, though. I'll look later.

@aminpaks
Copy link

aminpaks commented May 5, 2024

@MichaelMitchell-at, I tried this branch but still can't get fixes working, what am I missing?

@MichaelMitchell-at
Copy link
Contributor Author

@MichaelMitchell-at, I tried this branch but still can't get fixes working, what am I missing?

Have you tried running it across the individual sub-projects? I wouldn't expect ts-fix to follow references.

@aminpaks
Copy link

aminpaks commented May 6, 2024

Have you tried running it across the individual sub-projects? I wouldn't expect ts-fix to follow references.

Yep, that works! It might be only me but I find this confusing, and there is no warning anywhere either!

Thanks anyway!

@jakebailey jakebailey closed this May 6, 2024
@jakebailey jakebailey reopened this May 6, 2024
@jakebailey
Copy link
Member

Actually the CI problems are real; the tests are not actually typechecked so that's being missed.

@jakebailey jakebailey merged commit 50e122e into microsoft:main May 6, 2024
2 checks passed
@MichaelMitchell-at MichaelMitchell-at deleted the include_declaration_diagnostics branch May 17, 2024 21:42
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.

Question: Isolated Declarations
3 participants