mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
[mobx-task] Fixed property decorator definition (#34851)
* [mobx-task] Fixed property decorator definition * Revert "[mobx-task] Fixed property decorator definition" This reverts commit 20bd533e * test for decorators & last change * [mobx-task] Fixed property decorator definition
This commit is contained in:
committed by
Pranav Senthilnathan
parent
3034a2763c
commit
a3b8548fb3
Vendored
+2
-1
@@ -45,7 +45,8 @@ export interface TaskStatusAware<Result = any, Args extends any[] = any[]> exten
|
||||
export interface TaskCreator<K extends keyof TaskOptions<any>> extends MethodDecorator, PropertyDecorator {
|
||||
<R, A extends any[]>(func: TaskFunc<R, A>, options?: Pick<TaskOptions<WithoutPromise<R>>, K>): TaskStatusAware<WithoutPromise<R>, A>;
|
||||
|
||||
(options: Pick<TaskOptions<WithoutPromise<any>>, K>): PropertyDecorator | MethodDecorator;
|
||||
(options: Pick<TaskOptions<WithoutPromise<any>>, K>): PropertyDecorator;
|
||||
(options: Pick<TaskOptions<WithoutPromise<any>>, K>): MethodDecorator;
|
||||
}
|
||||
|
||||
export interface TaskFactory extends TaskCreator<keyof TaskOptions<any>> {
|
||||
|
||||
@@ -23,6 +23,13 @@ task1.match({
|
||||
rejected: error => error.message,
|
||||
});
|
||||
|
||||
// $ExpectType string | number
|
||||
task1.match({
|
||||
resolved: res => 1,
|
||||
pending: (txt, num) => txt,
|
||||
rejected: error => error.message,
|
||||
});
|
||||
|
||||
// wrap
|
||||
const task2 = task(func);
|
||||
const task2ToString = task2.wrap(inner => {
|
||||
@@ -36,3 +43,13 @@ task2ToString.result; // $ExpectType string | undefined
|
||||
const task3 = task(func, { result: 1, state: 'resolved' });
|
||||
task3.setState({ result: 2, state: 'pending' });
|
||||
task3.setState({ result: '2', state: 'pending' }); // $ExpectError
|
||||
|
||||
class TestClass {
|
||||
@task fieldWithArrowFn = () => {};
|
||||
@task({ swallow: true }) fieldWithArrowFn2 = () => {};
|
||||
fieldWithArrowFn3 = task(() => {}, { swallow: true });
|
||||
|
||||
@task method() {}
|
||||
|
||||
@task({ swallow: true }) method2() {}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"experimentalDecorators": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user