From 7f9e0b901f2ddd104deb10c4e1b8b5f2dc0fe769 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Mon, 28 Oct 2019 18:11:50 +0200 Subject: [PATCH] mobx-task: Provides its own types (#39465) --- notNeededPackages.json | 6 ++++ types/mobx-task/index.d.ts | 58 ------------------------------ types/mobx-task/mobx-task-tests.ts | 55 ---------------------------- types/mobx-task/tsconfig.json | 24 ------------- types/mobx-task/tslint.json | 1 - 5 files changed, 6 insertions(+), 138 deletions(-) delete mode 100644 types/mobx-task/index.d.ts delete mode 100644 types/mobx-task/mobx-task-tests.ts delete mode 100644 types/mobx-task/tsconfig.json delete mode 100644 types/mobx-task/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 7b791ed359..fdc9bba319 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -2160,6 +2160,12 @@ "sourceRepoURL": "https://github.com/will-stone/mobx-cookie", "asOfVersion": "1.1.1" }, + { + "libraryName": "mobx-task", + "typingsPackageName": "mobx-task", + "sourceRepoURL": "https://github.com/jeffijoe/mobx-task#readme", + "asOfVersion": "2.0.0" + }, { "libraryName": "mockingoose", "typingsPackageName": "mockingoose", diff --git a/types/mobx-task/index.d.ts b/types/mobx-task/index.d.ts deleted file mode 100644 index 85df15ec54..0000000000 --- a/types/mobx-task/index.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Type definitions for mobx-task 1.0 -// Project: https://github.com/jeffijoe/mobx-task#readme -// Definitions by: Julian Wielga -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 - -export type Omit = Pick>; -export type WithoutPromise = T extends Promise ? U : T; - -export type TaskState = 'pending' | 'resolved' | 'rejected'; -export type TaskError = Error; -export type TaskFunc = (...args: A) => R; - -export interface TaskOptions { - state?: TaskState; - error?: TaskError; - result?: Result; - swallow?: boolean; -} - -export interface TaskMatchProps { - pending: (...args: Args) => T1; - rejected: (error: TaskError) => T2; - resolved: (result: Result) => T3; -} - -export interface TaskStatusAware extends TaskFunc, Args> { - readonly state: TaskState; - readonly pending: boolean; - readonly resolved: boolean; - readonly rejected: boolean; - readonly args: Args; - readonly result?: Result; - readonly error?: TaskError; - - match(props: TaskMatchProps): PendingType | RejectedType | ResolvedType; - - wrap(func: (inner: TaskStatusAware) => (...args: A) => Promise): TaskStatusAware; - - setState(props: TaskOptions): void; - - reset(): void; -} - -export interface TaskCreator> extends MethodDecorator, PropertyDecorator { - (func: TaskFunc, options?: Pick>, K>): TaskStatusAware, A>; - - (options: Pick>, K>): PropertyDecorator; - (options: Pick>, K>): MethodDecorator; -} - -export interface TaskFactory extends TaskCreator> { - resolved: TaskCreator, 'state'>>; - rejected: TaskCreator, 'state'>>; -} - -export type Task = TaskStatusAware; -export const task: TaskFactory; diff --git a/types/mobx-task/mobx-task-tests.ts b/types/mobx-task/mobx-task-tests.ts deleted file mode 100644 index 92e0d3a7d1..0000000000 --- a/types/mobx-task/mobx-task-tests.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { task } from 'mobx-task'; - -const func = () => 42; -const funcAsync = (txt: string, num: number) => Promise.resolve(`${txt}${num}`); - -const task1 = task(funcAsync); - -task1('test', 123); // $ExpectType Promise -task1.result; // $ExpectType string | undefined -task1.state; // $ExpectType TaskState - -// $ExpectType number -task1.match({ - resolved: res => 1, - pending: (txt, num) => num, - rejected: error => -1, -}); - -// $ExpectType string -task1.match({ - resolved: res => res, - pending: (txt, num) => txt, - 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 => { - return () => { - return inner().then(r => JSON.stringify(r)); - }; -}); -task2ToString.result; // $ExpectType string | undefined - -// options -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() {} -} diff --git a/types/mobx-task/tsconfig.json b/types/mobx-task/tsconfig.json deleted file mode 100644 index dc8124044e..0000000000 --- a/types/mobx-task/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "experimentalDecorators": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "mobx-task-tests.ts" - ] -} diff --git a/types/mobx-task/tslint.json b/types/mobx-task/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/mobx-task/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" }