isEnum returns false when Enum property has a default value
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
Version: 21.0.1
When a Class enum property has a default value of an enum member, `isEnum()` returns false as it sees the type from the enum value itself.
**To Reproduce**
```ts
import {Project} from "ts-morph";
const project = new Project();
project.createSourceFile("test.ts", `
export enum TestEnum {
A = 1,
}
export class TestClass {
p = TestEnum.A
}
`)
project.getSourceFiles().forEach(src => {
src.getClasses().forEach(cls => {
cls.getProperties().forEach(prop => {
console.log({
prop: prop.getName(),
type: prop.getType().getText(cls),
isEnum: prop.getType().isEnum(),
apparentType: prop.getType().getApparentType().getText(cls),
})
})
})
})
```
**Expected behavior**
would expect `property.getType().isEnum()` to return true
Contributor guide
Assessment
This issue has not been assessed yet.