@@ -36,30 +36,35 @@ const createTaskInnerApi = (taskState: TaskObject) => {
3636 return api ;
3737} ;
3838
39- type TaskFunction = ( taskHelpers : ReturnType < typeof createTaskInnerApi > ) => Promise < unknown > ;
39+ // Until full ESM
40+ // eslint-disable-next-line @typescript-eslint/no-namespace
41+ namespace task {
42+ export type TaskInnerApi = ReturnType < typeof createTaskInnerApi > ;
43+ export type TaskFunction = ( taskHelpers : TaskInnerApi ) => Promise < unknown > ;
44+ }
4045
41- type TaskAPI < T extends TaskFunction > = {
46+ type TaskApi < T extends task . TaskFunction > = {
4247 run : ( ) => Promise < Awaited < ReturnType < T > > > ;
4348 clear : ( ) => void ;
4449} ;
4550type TaskResults <
46- T extends TaskFunction ,
47- Tasks extends TaskAPI < T > [ ]
51+ T extends task . TaskFunction ,
52+ Tasks extends TaskApi < T > [ ]
4853> = {
4954 [ key in keyof Tasks ] : (
50- Tasks [ key ] extends TaskAPI < T >
55+ Tasks [ key ] extends TaskApi < T >
5156 ? Awaited < ReturnType < Tasks [ key ] [ 'run' ] > >
5257 : Tasks [ key ]
5358 ) ;
5459} ;
5560
5661let app : ReturnType < typeof createApp > ;
5762
58- function registerTask < T extends TaskFunction > (
63+ function registerTask < T extends task . TaskFunction > (
5964 taskList : TaskList ,
6065 taskTitle : string ,
6166 taskFunction : T ,
62- ) : TaskAPI < T > {
67+ ) : TaskApi < T > {
6368 if ( ! app ) {
6469 app = createApp ( taskList ) ;
6570 taskList . isRoot = true ;
@@ -105,7 +110,7 @@ function registerTask<T extends TaskFunction>(
105110function createTaskFunction (
106111 taskList : TaskList ,
107112) {
108- async function task < T extends TaskFunction > (
113+ async function task < T extends task . TaskFunction > (
109114 title : string ,
110115 taskFunction : T ,
111116 ) {
@@ -118,7 +123,7 @@ function createTaskFunction(
118123 ) ;
119124 }
120125
121- const createTask = < T extends TaskFunction > (
126+ const createTask = < T extends task . TaskFunction > (
122127 title : string ,
123128 taskFunction : T ,
124129 ) => registerTask (
@@ -128,8 +133,8 @@ function createTaskFunction(
128133 ) ;
129134
130135 task . group = async <
131- T extends TaskFunction ,
132- Tasks extends TaskAPI < T > [ ]
136+ T extends task . TaskFunction ,
137+ Tasks extends TaskApi < T > [ ]
133138 > (
134139 createTasks : ( taskCreator : typeof createTask ) => readonly [ ...Tasks ] ,
135140 options ?: Options ,
0 commit comments