From b8e040ca8c860a8b88e8e9df871c8c69ab46e848 Mon Sep 17 00:00:00 2001 From: Niko Sams Date: Mon, 20 Nov 2023 11:00:12 +0100 Subject: [PATCH] API Generator: Add support for TypeScript paths (#1374) 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> --- .changeset/hungry-yaks-develop.md | 5 +++++ .../api/cms-api/src/generator/utils/ts-morph-helper.ts | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .changeset/hungry-yaks-develop.md diff --git a/.changeset/hungry-yaks-develop.md b/.changeset/hungry-yaks-develop.md new file mode 100644 index 0000000000..002f560863 --- /dev/null +++ b/.changeset/hungry-yaks-develop.md @@ -0,0 +1,5 @@ +--- +"@comet/cms-api": patch +--- + +API Generator: Add support for TypeScript paths (e.g., `@src/`) by using the project's TSConfig diff --git a/packages/api/cms-api/src/generator/utils/ts-morph-helper.ts b/packages/api/cms-api/src/generator/utils/ts-morph-helper.ts index 6e757c5f83..8748f9b592 100644 --- a/packages/api/cms-api/src/generator/utils/ts-morph-helper.ts +++ b/packages/api/cms-api/src/generator/utils/ts-morph-helper.ts @@ -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) { let tsSource = project.getSourceFile(metadata.path);