24 lines
534 B
TypeScript
24 lines
534 B
TypeScript
import { Project, ResolutionHosts, ts } from "ts_morph/mod.ts";
|
|
|
|
export function generate(path: string) {
|
|
const project = new Project({
|
|
resolutionHost: ResolutionHosts.deno,
|
|
});
|
|
|
|
const file = project.addSourceFileAtPath(path);
|
|
|
|
const classes = file.getClasses();
|
|
|
|
const props = classes[0].getConstructors();
|
|
|
|
const ps = props[0].getParameters()[0];
|
|
|
|
console.log(classes[0].getProperties()[0].hasQuestionToken());
|
|
|
|
console.log(ps.isParameterProperty());
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
generate("../myapp/todo.ts");
|
|
}
|