Skip to content

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

Closed

Description

πŸ”Ž 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.

Activity

  1. MichaelMitchell-at commented on Apr 12, 2024

    @MichaelMitchell-at
    ContributorAuthor

    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!

  2. changed the title [-][nightly][regression] Some emitted imports in declaration file are empty[/-] [+][nightly][regression] Some emitted imports are syntactically invalid[/+] on Apr 12, 2024
  3. weswigham commented on Apr 12, 2024

    @weswigham
    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.

  4. jakebailey commented on Apr 12, 2024

    @jakebailey
    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).

  5. MichaelMitchell-at commented on Apr 12, 2024

    @MichaelMitchell-at
    ContributorAuthor

    Jake Bailey (@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`
  6. jakebailey commented on Apr 12, 2024

    @jakebailey
    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.

  7. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions