diff --git a/package.json b/package.json index 2152a9dfc..236ece137 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,16 @@ "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", "./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/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", + }, +} diff --git a/types/TaskParameters.d.ts b/types/TaskParameters.d.ts new file mode 100644 index 000000000..cc9c96113 --- /dev/null +++ b/types/TaskParameters.d.ts @@ -0,0 +1,25 @@ +// 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"; + +declare interface TaskParametersBase { + workspace: ui5_fs_DuplexCollection, + options: { + omitSourceMapResources?: boolean, + useInputSourceMaps?: boolean, + } +} + +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 +// }