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

Hoisted vars in blocks at module scope generate in invalid d.ts files when referenced using typeof #58557

Closed
lucacasonato opened this issue May 17, 2024 · 1 comment Β· Fixed by #58605
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Recent Regression This is a new regression just found in the last major/minor version of TypeScript.

Comments

@lucacasonato
Copy link

lucacasonato commented May 17, 2024

πŸ”Ž Search Terms

  • hoisting
  • var declaration
  • declaration files
  • typeof
  • module

πŸ•— Version & Regression Information

This changed between versions 5.5.0-beta and 5.5.0-dev.20240517

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.5.0-dev.20240517#code/N4KABBYG4IYE5hmAvGARGg3CAviApgB4AOA9nAC5gA2+VARgFxgUCex+pAZotkA

πŸ’» Code

{
    var a = "";
}
export let b: typeof a;

πŸ™ Actual behavior

export declare let b: typeof a;

πŸ™‚ Expected behavior

d.ts emit of either:

var a: string;
export declare let b: typeof a;

or

export declare let b: string;

Probably it should do the first, then it would be compatible with isolated declarations.

Additional information about the issue

No response

@lucacasonato lucacasonato changed the title Hoisted vars in module level blocks result in invalid d.ts files when referenced using typeof Hoisted vars in module level blocks result in invalid d.ts files when referenced using typeof May 17, 2024
@lucacasonato lucacasonato changed the title Hoisted vars in module level blocks result in invalid d.ts files when referenced using typeof Hoisted vars in module scope blocks result in invalid d.ts files when referenced using typeof May 17, 2024
@lucacasonato lucacasonato changed the title Hoisted vars in module scope blocks result in invalid d.ts files when referenced using typeof Hoisted vars in blocks at module scope generate in invalid d.ts files when referenced using typeof May 17, 2024
@weswigham weswigham added Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: Isolated Declarations Related to the --isolatedDeclarations compiler flag labels May 17, 2024
@lucacasonato
Copy link
Author

@weswigham This is not isolated declarations specific. This is a bug introduced between 5.5.0-beta and 5.5.0-dev.20240517. This reproduction is not related to isolated declaration at all. This code fails to emit correctly / does not raise a diagnostic in the latest dev build, but it does work in 5.5.0-beta.

@weswigham weswigham added Bug A bug in TypeScript Recent Regression This is a new regression just found in the last major/minor version of TypeScript. and removed Domain: Isolated Declarations Related to the --isolatedDeclarations compiler flag labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Recent Regression This is a new regression just found in the last major/minor version of TypeScript.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants