1.0.0 • Published 3 years ago

@mkmod-ts/ts-get-exported-type v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@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.