Skip to content

Commit

Permalink
API Generator: Add support for TypeScript paths (#1374)
Browse files Browse the repository at this point in the history
Add support for TypeScript paths (e.g., `@src/`) by using the project's
TSConfig.

---------

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
  • Loading branch information
nsams and johnnyomair authored Nov 20, 2023
1 parent 7c6eb68 commit b8e040c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-yaks-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-api": patch
---

API Generator: Add support for TypeScript paths (e.g., `@src/`) by using the project's TSConfig
8 changes: 3 additions & 5 deletions packages/api/cms-api/src/generator/utils/ts-morph-helper.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { EntityMetadata } from "@mikro-orm/core";
import * as path from "path";
import { ClassDeclaration, ModuleKind, Project } from "ts-morph";
import { ClassDeclaration, Project } from "ts-morph";

/* eslint-disable @typescript-eslint/no-explicit-any */

const project = new Project({
compilerOptions: {
strictNullChecks: true,
module: ModuleKind.Node16,
},
tsConfigFilePath: "tsconfig.json",
skipAddingFilesFromTsConfig: true,
});
function morphTsSource(metadata: EntityMetadata<any>) {
let tsSource = project.getSourceFile(metadata.path);
Expand Down

0 comments on commit b8e040c

Please sign in to comment.