From b99eb7a3a23279b8a578cf8552702a636cbb6086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Gr=C3=A9goire?= Date: Tue, 27 Jun 2023 19:00:58 +0200 Subject: [PATCH 1/3] fix: generate POSIX paths in typesOverrides imports --- lerna.json | 1 - packages/cli/src/types.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index e62a3e12..6a82dfe4 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "useWorkspaces": true, "version": "2.2.1" } diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index 9f06834c..0aec6461 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -159,7 +159,8 @@ export function declareImport( let from = imports[0].from; if (from.startsWith('.')) { - from = path.relative(path.dirname(decsFileName), imports[0].from); + const nonPosixFrom = path.relative(path.dirname(decsFileName), imports[0].from); + from = nonPosixFrom.split(path.sep).join(path.posix.sep); if (!from.startsWith('.')) { from = './' + from; From a6b123267045d8de3ec176155714d05155d0a6e2 Mon Sep 17 00:00:00 2001 From: Adel Salakh Date: Tue, 18 Jul 2023 23:30:12 +0200 Subject: [PATCH 2/3] Update packages/cli/src/types.ts --- packages/cli/src/types.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index 0aec6461..daad9763 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -159,8 +159,11 @@ export function declareImport( let from = imports[0].from; if (from.startsWith('.')) { - const nonPosixFrom = path.relative(path.dirname(decsFileName), imports[0].from); - from = nonPosixFrom.split(path.sep).join(path.posix.sep); + from = path.relative(path.dirname(decsFileName), imports[0].from); + if (os.platform() === "win32") { + // make sure we use posix separators in TS import declarations (see #533) + from = from.split(path.sep).join(path.posix.sep); + } if (!from.startsWith('.')) { from = './' + from; From 4d03f66a9f359763b4102fff463f8b2a89df62c4 Mon Sep 17 00:00:00 2001 From: Adel Salakh Date: Tue, 18 Jul 2023 23:31:04 +0200 Subject: [PATCH 3/3] Update types.ts --- packages/cli/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index daad9763..e7593869 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -8,6 +8,7 @@ import { Type, ImportedType, } from '@pgtyped/query'; +import os from 'os'; import path from 'path'; const String: Type = { name: 'string' };