ConstructorTypeNode is missing support for type parameters
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
Version: 19.0.0
In tinkering around with a custom structures set, I was trying to extract type parameters from a `ConstructorTypeNode`. I expected, like `FunctionTypeNode`, there would be a `.getTypeParameters()` method... but there isn't.
**To Reproduce**
```ts
import {
ConstructorTypeNode
} from "ts-morph";
const keySet = new Set;
let proto: object | null = ConstructorTypeNode.prototype;
while (proto && (proto !== Object.prototype)) {
const ownKeys = Reflect.ownKeys(proto);
for (const key of ownKeys) {
if ((typeof key === "string") && key.startsWith("get"))
keySet.add(key);
}
proto = Reflect.getPrototypeOf(proto);
}
const keys = Array.from(keySet);
keys.sort();
for (const key of keys) {
console.log(key);
}
// getParameters shows up, but not getTypeParameters
```
[ts-ast-viewer link](https://ts-ast-viewer.com/#code/JYOwLgpgTgZghgYwgAgHIFcC2AjaBlMKUAcwBUBPABxQG8AoZR5OgXzrCpQFFkBeZEBADuyADwEiIMp2QQAHpBAATAM7IVhEgBo0WXFArVZCiMrUg90PsgCMAPgZMAFCoBcyCSUMQdIAJR8dro4+JpS3gDcdEA)
**Expected behavior**
I expected to be able to call:
```ts
const typeParameterNodes: readonly TypeParameterDeclaration[] = (typeNode as ConstructorTypeNode).getTypeParameters();
```
Contributor guide
Research direction
Start by comparing ConstructorTypeNode with FunctionTypeNode, focusing on the existing getTypeParameters() API and the type-node entry points mentioned in the reproduction. Use the supplied TypeScript example or ts-ast-viewer link to confirm the current behavior; done means constructor type nodes expose the expected type parameter declarations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100