Skip to content

Invalid declaration with computed property using imported symbol #55494

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

Closed
dragomirtitian opened this issue Aug 24, 2023 · 0 comments Β· Fixed by #55529
Closed

Invalid declaration with computed property using imported symbol #55494

dragomirtitian opened this issue Aug 24, 2023 · 0 comments Β· Fixed by #55529
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@dragomirtitian
Copy link
Contributor

πŸ”Ž Search Terms

computed property declaration destructure binding

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?lib=lib.es2015.d.ts&ts=5.1.6#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYC5Q1kBXaAKBAngwCMDoBnANgrHADMN5odEBbaAVi400AB5oAdGgZlxAByzI0oYTgYqA0tACeoALygAyjr40s8ABQBKANysInbrwEEMOGGOmyMfRctAAb1BtPQBfUHZkLD5QACJJYDVRCTj7BSUVdmIcWExcUAB3DDQACwBhEXE0S2CAbVCAXQIAN0R4UlAwgkQcHWsCDWR3AHMgslBJyeRoNGJkHFA2juh7MLIgA

πŸ’» Code

// @declaration: true
// @lib: es6
// @filename: context.ts
export const Key = Symbol();
// @filename: index.ts
import { Key } from "./context";
export function withContext({ [Key]: value }: any): string {
     return value;
}

πŸ™ Actual behavior

In index.d.ts the import of Key is removed leading to an invalid declaration file

// index.d.ts
export declare function withContext({ [Key]: value }: any): string;

πŸ™‚ Expected behavior

In index.d.ts the import of Key should be kept

// index.d.ts
import { Key } from "./context";
export declare function withContext({ [Key]: value }: any): string;

Additional information about the issue

Seems like filterBindingPatternInitializersAndRenamings in declarations.ts does not call checkEntityNameVisibility to mark the import as used in the declaration.

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.

4 participants