Closed mrousavy closed 3 months ago
Same goes for method.getSignature().getReturnType().getText()
getDriver(car: Car): Person | undefined
👇
"Person"
Ah, sorry I didn't have strictNullChecks
enabled in my Project
:
const project = new Project({
compilerOptions: {
strict: true,
strictNullChecks: true,
},
})
(or just load the tsconfig.json)
Description
I have the following TS type:
When getting the method
someFunc
as aMethodSignature
, I can get it's return type usinggetReturnType()
:..but instead of being
number | undefined
, this actually is justnumber
!Version: 23.0.0
Expected behavior
I expect the
returnType
to either benumber
andisNullable()
to be true (ideal case), or an union ofnumber | undefined
.But instead, it is just
number
. No optional/undefined.