diff --git a/package.json b/package.json index bc959649e..e7c57558b 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,14 @@ "./validation/ValidationError": "./lib/validation/ValidationError.js", "./graph/ProjectGraph": "./lib/graph/ProjectGraph.js", "./graph/projectGraphBuilder": "./lib/graph/projectGraphBuilder.js", - "./graph": "./lib/graph/graph.js", - "./package.json": "./package.json" + "./graph": { + "default": "./lib/graph/graph.js", + "types": "./types/index.d.ts" + }, + "./package.json": "./package.json", + "./build/helpers/*": { + "types": "./types/*.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/TaskUtil.d.ts b/types/TaskUtil.d.ts new file mode 100644 index 000000000..3f7017bc5 --- /dev/null +++ b/types/TaskUtil.d.ts @@ -0,0 +1,41 @@ +// 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"; + +// Mock some of the types, so it would be easier to follow +declare type ui5_fs_resourceFactory = object +declare type ui5_fs_Resource = object +declare type ProjectInterface = object + +declare type StandardBuildTags = { + OmitFromBuildResult: string + IsBundle: string + IsDebugVariant: string + HasDebugVariant: string +} + +declare class TaskUtil_v2_2 { + STANDARD_TAGS: StandardBuildTags + resourceFactory: ui5_fs_resourceFactory + getDependencies(projectName?: string): string[] + getProject(projectNameOrResource?: ProjectInterface | undefined) + isRootProject(): boolean + registerCleanupTask(callback: CallableFunction): never +} + +declare class TaskUtil_v3_0 extends TaskUtil_v2_2 { + clearTag(resource: ui5_fs_Resource, tag: string): never + getTag(resource: ui5_fs_Resource, tag: string): string | boolean | number | undefined + setTag(resource: ui5_fs_Resource, tag: string, value: string | boolean | number): never +} + +declare class TaskUtil_v3_2 extends TaskUtil_v3_0 { + someFutureMethod(); +} + +export declare type TaskUtil = specVersion extends "2.2" + ? TaskUtil_v2_2 + : specVersion extends "3.0" + ? TaskUtil_v3_0 + : specVersion extends "3.2" + ? TaskUtil_v3_2 + : never; \ No newline at end of file diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 000000000..92160abac --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,3 @@ +export declare interface ProjectGraph { } + +export declare function graphFromPackageDependencies(settings: Record): ProjectGraph;