`ExportedDeclarations` type union is missing type `BindingElement`
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
Version: 21.0.1
The `ExportedDeclarations` type union is missing the type `BindingElement` which can be returned when an `export` declaration uses object or array destructuring, for example:
```ts
// Export with object destructuring.
export const {
foo,
bar: baz,
...qux
} = {
foo: "hello",
bar: 42,
quxA: 1, quxB: 2, quxC: 3
} as const;
// Export with array destructuring.
export const [aaa, bbb, ...[ccc, ddd]] = [1, 2, 3, 4] as const;
```
**To Reproduce**
```ts
import { Project } from "ts-morph";
const project = new Project({ useInMemoryFileSystem: true });
const sourceFile = project.createSourceFile(
"test.ts",
`
// Export with object destructuring.
export const {
foo,
bar: baz,
...qux
} = {
foo: "hello",
bar: 42,
quxA: 1, quxB: 2, quxC: 3
} as const;
// Export with array destructuring.
export const [aaa, bbb, ...[ccc, ddd]] = [1, 2, 3, 4] as const;
`,
);
for (const [exportName, declarations] of sourceFile.getExportedDeclarations()) {
for (const declaration of declarations) {
console.log({
exportName,
kind: declaration.getKindName(), // All declarations are of kind `BindingElement`
type: declaration.getType().getText(),
});
}
}
```
Output:
```
{
exportName: "foo",
kind: "BindingElement",
type: "\"hello\"",
}
{
exportName: "baz",
kind: "BindingElement",
type: "42",
}
{
exportName: "qux",
kind: "BindingElement",
type: "{ quxA: 1; quxB: 2; quxC: 3; }",
}
{
exportName: "aaa",
kind: "BindingElement",
type: "1",
}
{
exportName: "bbb",
kind: "BindingElement",
type: "2",
}
{
exportName: "ccc",
kind: "BindingElement",
type: "3",
}
{
exportName: "ddd",
kind: "BindingElement",
type: "4",
}
```
**Expected behavior**
`ExportedDeclarations` type union should include type `BindingElement`.
Thank you for your time!
Contributor guide
Assessment
This issue has not been assessed yet.