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

[nightly][regression] Some emitted imports are syntactically invalid #58159

Closed
MichaelMitchell-at opened this issue Apr 12, 2024 · 5 comments Β· Fixed by #58165
Closed

[nightly][regression] Some emitted imports are syntactically invalid #58159

MichaelMitchell-at opened this issue Apr 12, 2024 · 5 comments Β· Fixed by #58165
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@MichaelMitchell-at
Copy link

πŸ”Ž Search Terms

import, declaration, empty

πŸ•— Version & Regression Information

⏯ Playground Link

No response

πŸ’» Code

n/a

πŸ™ Actual behavior

A type referenced in a declaration file is sometimes emitted as import().SomeType and sometimes as import(<actual_import_path>).SomeType

πŸ™‚ Expected behavior

The type is always emitted as import(<actual_import_path>).SomeType

Additional information about the issue

It's not easy for me to provide a self-contained reproduction, as it involves the composition of a lot of our private code, but I figure since it's already known which PR introduced the regression, it should hopefully be easier for someone on the TS team to spot how an import could possibly be empty. I can patch speculative fixes or add some debug logs if requested.

@MichaelMitchell-at
Copy link
Author

Ok I have a repro. It actually demonstrates an even more egregious behavior
https://github.com/MichaelMitchell-at/repro_for_typescript_issue_58159

export declare const d: {
    e: {
        f: (foo: import({e};
        ).Foo) => boolean;
    };
};

This is even less syntactically valid!

@MichaelMitchell-at MichaelMitchell-at changed the title [nightly][regression] Some emitted imports in declaration file are empty [nightly][regression] Some emitted imports are syntactically invalid Apr 12, 2024
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Apr 12, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.5.0 milestone Apr 12, 2024
@typescript-bot typescript-bot added Fix Available A PR has been opened for this issue labels Apr 12, 2024
@weswigham
Copy link
Member

Thanks for the repro - looks like we could have triggered this bug before #58085, but that change made it much easier to trigger, since we reuse type nodes so much more. #58165 is up with the fix.

@jakebailey
Copy link
Member

It's not easy for me to provide a self-contained reproduction, as it involves the composition of a lot of our private code, but I figure since it's already known which PR introduced the regression, it should hopefully be easier for someone on the TS team to spot how an import could possibly be empty. I can patch speculative fixes or add some debug logs if requested.

FWIW https://www.npmjs.com/package/every-ts may be useful in the future if you're already able to use nightly TS (and can bisect instead).

@MichaelMitchell-at
Copy link
Author

MichaelMitchell-at commented Apr 12, 2024

@jakebailey that's how I found the offending commit :). BTW could I put in a quick feature request for a command to rebuild TS in the current branch? Bisecting took extra work because there was an unrelated bad commit that I had to revert on every commit I was testing, so my flow was like:

every-ts bisect good
git revert ...
# copy the current revision with the revert
git checkout HEAD^  # have to switch otherwise every-ts won't rebuild TypeScript
every-ts switch <copied revision with revert>

What I'd want is something like

every-ts bisect good
git revert ...
every-ts rebuild # or alternatively something like `every-ts switch ... --rebuild`

@jakebailey
Copy link
Member

Oh, oops, I didn't even see that you bisected it; I skipped straight to the end.

BTW could I put in a quick feature request for a command to rebuild TS in the current branch? Bisecting took extra work because there was an unrelated bad commit that I had to revert or every commit I was testing, so my flow was like:

At the moment, I'm not intending for anyone to be modifying the TS repo that every-ts checks out internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants