From 0a2b568244bfc0d2a816ea1fd043f34aa819c508 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 17 Oct 2023 15:33:38 +0300 Subject: [PATCH 1/6] Provide TaskParameters types --- package.json | 3 ++- types/TaskParameters.d.ts | 25 +++++++++++++++++++++++++ types/index.d.ts | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 types/TaskParameters.d.ts create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index 2152a9dfc..b74580947 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "./tasks/bundlers/utils/*": null, "./package.json": "./package.json", "./internal/taskRepository": "./lib/tasks/taskRepository.js", - "./internal/jsdoc/template/publish": "./lib/processors/jsdoc/lib/ui5/template/publish.cjs" + "./internal/jsdoc/template/publish": "./lib/processors/jsdoc/lib/ui5/template/publish.cjs", + "./types": "./types/index.d.ts" }, "engines": { "node": "^16.18.0 || >=18.12.0", diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts new file mode 100644 index 000000000..2eef6249c --- /dev/null +++ b/types/TaskParameters.d.ts @@ -0,0 +1,25 @@ +declare module "@ui5/builder/task/TaskParameters" { + import { TaskUtil } from "@ui5/project/build/helpers/TaskUtil"; + + // Mock some of the types, so it would be easier to follow + type ui5_fs_DuplexCollection = object + + // This one should be (eventually) provided globally or as a part of @ui5/server/Specification + type availableSpecVersions = "2.0" | "2.2" | "3.0" | "3.2"; + + interface TaskParametersBase { + workspace: ui5_fs_DuplexCollection, + options: { + omitSourceMapResources?: boolean, + useInputSourceMaps?: boolean, + } + } + + interface TaskParameters_2_2 extends TaskParametersBase { + taskUtil: TaskUtil + } + + type TaskParameters = specVersion extends "2.2" | "3.0" | "3.2" + ? TaskParameters_2_2 + : TaskParametersBase +} diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 000000000..479090ca4 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,3 @@ +// Reference multiple definitions, so they could act like a bundle + +/// \ No newline at end of file From 038561e75e7992477f995504e441dc42363f06ad Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 17 Oct 2023 15:40:37 +0300 Subject: [PATCH 2/6] Align types --- types/TaskParameters.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts index 2eef6249c..f6006b2ef 100644 --- a/types/TaskParameters.d.ts +++ b/types/TaskParameters.d.ts @@ -4,7 +4,7 @@ declare module "@ui5/builder/task/TaskParameters" { // Mock some of the types, so it would be easier to follow type ui5_fs_DuplexCollection = object - // This one should be (eventually) provided globally or as a part of @ui5/server/Specification + // This one should be (eventually) provided globally or as a part of @ui5/project/Specification type availableSpecVersions = "2.0" | "2.2" | "3.0" | "3.2"; interface TaskParametersBase { From 07b2cb6f8572a4fc3df4eba6378c13b5bcd2851a Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 18 Oct 2023 13:52:52 +0300 Subject: [PATCH 3/6] Include explicitly type defs from the other "@ui5/*" projects --- types/TaskParameters.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts index f6006b2ef..bdbbf29dc 100644 --- a/types/TaskParameters.d.ts +++ b/types/TaskParameters.d.ts @@ -1,3 +1,4 @@ +import "@ui5/project/types"; declare module "@ui5/builder/task/TaskParameters" { import { TaskUtil } from "@ui5/project/build/helpers/TaskUtil"; From 55bc18195970f8529e1d60b4c2b461d9044e0b78 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 18 Oct 2023 14:12:23 +0300 Subject: [PATCH 4/6] Scope imports --- types/TaskParameters.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts index bdbbf29dc..f69264d25 100644 --- a/types/TaskParameters.d.ts +++ b/types/TaskParameters.d.ts @@ -1,5 +1,5 @@ -import "@ui5/project/types"; declare module "@ui5/builder/task/TaskParameters" { + import "@ui5/project/types"; import { TaskUtil } from "@ui5/project/build/helpers/TaskUtil"; // Mock some of the types, so it would be easier to follow From 5d208e940412d763b0b1552566706cd9fff10773 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 20 Oct 2023 15:16:50 +0300 Subject: [PATCH 5/6] Remove ambient modules and use package.json export's conditional syntax instead --- package.json | 5 ++++- types/TaskParameters.d.ts | 43 +++++++++++++++++++-------------------- types/index.d.ts | 3 --- 3 files changed, 25 insertions(+), 26 deletions(-) delete mode 100644 types/index.d.ts diff --git a/package.json b/package.json index b74580947..236ece137 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,10 @@ "exports": { "./processors/*": "./lib/processors/*.js", "./processors/jsdoc/lib/*": null, - "./tasks/*": "./lib/tasks/*.js", + "./tasks/*": { + "default": "./lib/tasks/*.js", + "types": "./types/*.d.ts" + }, "./tasks/taskRepository": null, "./tasks/bundlers/utils/*": null, "./package.json": "./package.json", diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts index f69264d25..cc9c96113 100644 --- a/types/TaskParameters.d.ts +++ b/types/TaskParameters.d.ts @@ -1,26 +1,25 @@ -declare module "@ui5/builder/task/TaskParameters" { - import "@ui5/project/types"; - import { TaskUtil } from "@ui5/project/build/helpers/TaskUtil"; - - // Mock some of the types, so it would be easier to follow - type ui5_fs_DuplexCollection = object - - // This one should be (eventually) provided globally or as a part of @ui5/project/Specification - type availableSpecVersions = "2.0" | "2.2" | "3.0" | "3.2"; - - interface TaskParametersBase { - workspace: ui5_fs_DuplexCollection, - options: { - omitSourceMapResources?: boolean, - useInputSourceMaps?: boolean, - } - } +// declare module "@ui5/builder/task/TaskParameters" { +import type { TaskUtil } from "@ui5/project/build/helpers/TaskUtil"; + +// Mock some of the types, so it would be easier to follow +declare type ui5_fs_DuplexCollection = object + +// This one should be (eventually) provided globally or as a part of @ui5/project/Specification +declare type availableSpecVersions = "2.0" | "2.2" | "3.0" | "3.2"; - interface TaskParameters_2_2 extends TaskParametersBase { - taskUtil: TaskUtil +declare interface TaskParametersBase { + workspace: ui5_fs_DuplexCollection, + options: { + omitSourceMapResources?: boolean, + useInputSourceMaps?: boolean, } +} - type TaskParameters = specVersion extends "2.2" | "3.0" | "3.2" - ? TaskParameters_2_2 - : TaskParametersBase +declare interface TaskParameters_2_2 extends TaskParametersBase { + taskUtil: TaskUtil } + +export declare type TaskParameters = specVersion extends "2.2" | "3.0" | "3.2" + ? TaskParameters_2_2 + : TaskParametersBase +// } diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index 479090ca4..000000000 --- a/types/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -// Reference multiple definitions, so they could act like a bundle - -/// \ No newline at end of file From d07d852175358402f898801360696975969d66e9 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 20 Oct 2023 15:18:16 +0300 Subject: [PATCH 6/6] Add .tsconfig file --- tsconfig.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tsconfig.json diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..bfce1eb8a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "esnext", + "noEmit": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "allowSyntheticDefaultImports": true, + "module": "NodeNext", + "moduleResolution": "NodeNext", + }, +}