mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 12:10:18 +00:00
Merge branch 'master' of https://github.com/DefinitelyTyped/DefinitelyTyped
This commit is contained in:
30
types/co/co-tests.ts
Normal file
30
types/co/co-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import co = require('co');
|
||||
|
||||
function* gen(num: number, str: string, arr: number[], obj: object, fun: () => void) {
|
||||
return num;
|
||||
}
|
||||
|
||||
co(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.default(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.co(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.wrap(gen)(42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
// $ExpectError
|
||||
co(gen, 42, 'forty-two', [42], { value: 42 }, () => {}).then((str: string) => {});
|
||||
|
||||
// $ExpectError
|
||||
co.wrap(gen)();
|
||||
|
||||
// $ExpectError
|
||||
co.wrap(gen)('forty-two');
|
||||
18
types/co/index.d.ts
vendored
Normal file
18
types/co/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for co 4.6
|
||||
// Project: https://github.com/tj/co#readme
|
||||
// Definitions by: Doniyor Aliyev <https://github.com/doniyor2109>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
type ExtractType<T> = T extends IterableIterator<infer R> ? R : never;
|
||||
|
||||
interface Co {
|
||||
<F extends (...args: any[]) => Generator>(fn: F, ...args: Parameters<F>): Promise<ExtractType<ReturnType<F>>>;
|
||||
default: Co;
|
||||
co: Co;
|
||||
wrap: <F extends (...args: any[]) => Generator>(fn: F) => (...args: Parameters<F>) => Promise<ExtractType<ReturnType<F>>>;
|
||||
}
|
||||
|
||||
declare const co: Co;
|
||||
|
||||
export = co;
|
||||
23
types/co/tsconfig.json
Normal file
23
types/co/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"co-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/co/tslint.json
Normal file
1
types/co/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
31
types/jest/index.d.ts
vendored
31
types/jest/index.d.ts
vendored
@@ -978,20 +978,29 @@ declare namespace jest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the result of a single call to a mock function.
|
||||
* Represents the result of a single call to a mock function with a return value.
|
||||
*/
|
||||
interface MockResult {
|
||||
/**
|
||||
* True if the function threw.
|
||||
* False if the function returned.
|
||||
*/
|
||||
isThrow: boolean;
|
||||
/**
|
||||
* The value that was either thrown or returned by the function.
|
||||
*/
|
||||
interface MockResultReturn<T> {
|
||||
type: 'return';
|
||||
value: T;
|
||||
}
|
||||
/**
|
||||
* Represents the result of a single incomplete call to a mock function.
|
||||
*/
|
||||
interface MockResultIncomplete {
|
||||
type: 'incomplete';
|
||||
value: undefined;
|
||||
}
|
||||
/**
|
||||
* Represents the result of a single call to a mock function with a thrown error.
|
||||
*/
|
||||
interface MockResultThrow {
|
||||
type: 'throw';
|
||||
value: any;
|
||||
}
|
||||
|
||||
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
||||
|
||||
interface MockContext<T, Y extends any[]> {
|
||||
calls: Y[];
|
||||
instances: T[];
|
||||
@@ -999,7 +1008,7 @@ declare namespace jest {
|
||||
/**
|
||||
* List of results of calls to the mock function.
|
||||
*/
|
||||
results: MockResult[];
|
||||
results: Array<MockResult<T>>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ interface TestApi {
|
||||
test(x: number): string;
|
||||
}
|
||||
// $ExpectType Mock<string, [number]>
|
||||
const mock12 = jest.fn<ReturnType<TestApi["test"]>, ArgsType<TestApi["test"]>>();
|
||||
const mock12 = jest.fn<ReturnType<TestApi["test"]>, jest.ArgsType<TestApi["test"]>>();
|
||||
|
||||
// $ExpectType number
|
||||
mock1('test');
|
||||
@@ -485,6 +485,19 @@ mocked.test4.mockRejectedValue(new Error());
|
||||
// $ExpectError
|
||||
mocked.test4.mockRejectedValueOnce(new Error());
|
||||
|
||||
const mockResult = jest.fn(() => 1).mock.results[0];
|
||||
switch (mockResult.type) {
|
||||
case 'return':
|
||||
mockResult.value; // $ExpectType number
|
||||
break;
|
||||
case 'incomplete':
|
||||
mockResult.value; // $ExpectType undefined
|
||||
break;
|
||||
case 'throw':
|
||||
mockResult.value; // $ExpectType any
|
||||
break;
|
||||
}
|
||||
|
||||
/* Snapshot serialization */
|
||||
|
||||
const snapshotSerializerPlugin: jest.SnapshotSerializerPlugin = {
|
||||
|
||||
2
types/react-dom/index.d.ts
vendored
2
types/react-dom/index.d.ts
vendored
@@ -17,7 +17,7 @@ import {
|
||||
DOMAttributes, DOMElement, ReactNode, ReactPortal
|
||||
} from 'react';
|
||||
|
||||
export function findDOMNode(instance: ReactInstance): Element | null | Text;
|
||||
export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
|
||||
export function unmountComponentAtNode(container: Element): boolean;
|
||||
|
||||
export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;
|
||||
|
||||
@@ -30,6 +30,8 @@ describe('ReactDOM', () => {
|
||||
const rootElement = document.createElement('div');
|
||||
ReactDOM.render(React.createElement('div'), rootElement);
|
||||
ReactDOM.findDOMNode(rootElement);
|
||||
ReactDOM.findDOMNode(null);
|
||||
ReactDOM.findDOMNode(undefined);
|
||||
});
|
||||
|
||||
it('createPortal', () => {
|
||||
|
||||
2
types/react-dom/v15/index.d.ts
vendored
2
types/react-dom/v15/index.d.ts
vendored
@@ -15,7 +15,7 @@ import {
|
||||
DOMAttributes, DOMElement
|
||||
} from 'react';
|
||||
|
||||
export function findDOMNode<E extends Element>(instance: ReactInstance): E;
|
||||
export function findDOMNode<E extends Element>(instance: ReactInstance | null | undefined): E;
|
||||
export function findDOMNode(instance: ReactInstance): Element;
|
||||
|
||||
export function render<P extends DOMAttributes<T>, T extends Element>(
|
||||
|
||||
@@ -25,6 +25,8 @@ describe('ReactDOM', () => {
|
||||
const rootElement = document.createElement('div');
|
||||
ReactDOM.render(React.createElement('div'), rootElement);
|
||||
ReactDOM.findDOMNode(rootElement);
|
||||
ReactDOM.findDOMNode(null);
|
||||
ReactDOM.findDOMNode(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
3
types/react-native/index.d.ts
vendored
3
types/react-native/index.d.ts
vendored
@@ -7662,6 +7662,9 @@ export interface PanResponderStatic {
|
||||
export interface Rationale {
|
||||
title: string;
|
||||
message: string;
|
||||
buttonPositive: string;
|
||||
buttonNegative?: string;
|
||||
buttonNeutral?: string;
|
||||
}
|
||||
|
||||
export type Permission =
|
||||
|
||||
1
types/three/index.d.ts
vendored
1
types/three/index.d.ts
vendored
@@ -17,7 +17,6 @@
|
||||
// Daniel Hritzkiv <https://github.com/dhritzkiv>,
|
||||
// Apurva Ojas <https://github.com/apurvaojas>,
|
||||
// Tiger Oakes <https://github.com/NotWoods>,
|
||||
// Seth Kingsley <https://github.com/sethk>,
|
||||
// Ethan Kay <https://github.com/elk941>,
|
||||
// Methuselah96 <https://github.com/Methuselah96>
|
||||
// Dilip Ramirez <https://github.com/Dukuo>
|
||||
|
||||
Reference in New Issue
Block a user