method.getSignature().getReturnType().getText() returns union type instead of type alias in 10.x
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
I am using ts-morph to auto-generate documentation for a project of mine and just upgraded from ts-morph from 9.1.0 to 10.0.1.
**Describe the bug**
Version: 10.0.1
Prior to the upgrade, [this method](https://github.com/zwave-js/node-zwave-js/blob/28879caf2b6e90da846d7a1adfdf37403209c0c6/packages/zwave-js/src/lib/commandclass/BinarySwitchCC.ts#L68) had an inferred return type of
```ts
Promise<{ currentValue: Maybe; targetValue: boolean | undefined; duration: Duration | undefined; } | undefined>
```
whereas after the update, the return type gets printed as
```ts
Promise<{ currentValue: boolean | ("unknown" & { __brand: boolean; }); targetValue: boolean | undefined; duration: Duration | undefined; } | undefined>
```
where `currentValue` gets printed with the union type behind `Maybe`.
I have verified with `git bisect` that the culprit is indeed not the update to TypeScript 4.2, but the ts-morph update. I didn't find anything regarding this change in the changelog, so I'm assuming it is not intended.
**To Reproduce**
```
git clone https://github.com/zwave-js/node-zwave-js
git checkout 6ffcf0f0104cbfb1c1af793b2a8fc291eb171c9d
yarn install && yarn run docs:generate
# you should see no changes here
git checkout 3373caa84e16c78999101fefbc82f4dd4b49f774
yarn install && yarn run docs:generate
# docs/api/CCs/BinarySwitch.md changes as described above
```
**Expected behavior**
No changes to `docs/api/CCs/BinarySwitch.md` like before the update.
Contributor guide
Assessment
This issue has not been assessed yet.