1.0.0 • Published 5 years ago
@mkmod-ts/ts-get-exported-type v1.0.0
@mkmod-ts/ts-get-exported-type
Uses typescript to get exported types from a .ts file:
const getExportedType = require("@mkmod-ts/ts-get-exported-type")
const code = `
export declare type Person = {
	name: string;
	age?: number;
}
`
console.log(
	getExportedType(code, "Person")
)Result is in the following format:
[{
	name: "name of member",
	type: "type of member",
	optional: true|false,
	text: "<name>:<type>;"
}, ...]or null if type was not found.
1.0.0
5 years ago