just icon indicating copy to clipboard operation
just copied to clipboard

cached() option on task() gives TS error

Open Thisen opened this issue 6 years ago • 7 comments

When using task("no-op", () => {}).cached() with TypeScript, cached gives a TS error:

Property 'cached' does not exist on type 'void | TaskFunction'.
  Property 'cached' does not exist on type 'void'. ts(2339)

This makes sense, since task() has a union type TaskFunction | void.

I propose removing the void return type option.

Thisen avatar Jul 19 '19 11:07 Thisen

https://github.com/microsoft/just/blob/599d32ecf782d825e069cf4dd682f2f7a9596bb7/packages/just-task/src/interfaces.ts#L13-L16

its should be existing as per the line. Any way I guess caching is still under development. Right ? @kenotron

anikethsaha avatar Jul 19 '19 16:07 anikethsaha

I am in favor of removing the "void" signature now.

kenotron avatar Jul 30 '19 21:07 kenotron

I can fix it @kenotron, if you'd like.

Thisen avatar Jul 31 '19 13:07 Thisen

@Thisen - oh that'd be appreciated!

kenotron avatar Jul 31 '19 17:07 kenotron

I looked a bit into it, seems like removing void, just surfaces another problem.

When I tried to write a test, to see if I could call cached() on the task function, I get a TS error: Cannot invoke an object which is possibly 'undefined'.ts(2722).

Not sure why I get this error, I can't find a possible undefined in the Undertaker typings either.

Do you know @kenotron?

Thisen avatar Aug 02 '19 07:08 Thisen

Cannot invoke an object which is possibly 'undefined'.ts(2722).

weird 😕 is it coming when placing the void, if so then it might be declaration bug, else I am not sure.

anikethsaha avatar Aug 02 '19 08:08 anikethsaha

Issues seem to have gone stale.

github-actions[bot] avatar Mar 08 '20 00:03 github-actions[bot]