@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
14 lines (13 loc) • 546 B
JavaScript
import { TypeFormatFlags, ts } from "ts-morph";
export function apparentType(node) {
// See:
// https://github.com/dsherret/ts-morph/issues/453#issuecomment-427405736
// https://github.com/dsherret/ts-morph/issues/453#issuecomment-667578386
return node
.getType()
.getApparentType()
.getText(node, ts.TypeFormatFlags.NoTruncation | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope)
.replace(/^Number$/, "number")
.replace(/^Boolean$/, "boolean")
.replace(/^String$/, "string");
}