Change libaries to rely less on implicit {} in test output (#34336)

This commit is contained in:
Wesley Wigham 2019-03-29 15:28:15 -07:00 committed by GitHub
parent 44a802cdba
commit 4d0a8f38cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 26 deletions

View File

@ -104,12 +104,13 @@ AirbnbPropTypes.forbidExtraProps<ForbidShape>({
// $ExpectType Requireable<number>
AirbnbPropTypes.integer();
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.number);
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.number, 'foo');
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar']));
const top = (<T>(x?: T): T => x!)();
type Top = typeof top;
declare function validateRequireableTop(x: React.Requireable<Top>): void;
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number, 'foo'));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar'])));
// $ExpectType Requireable<number>
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number);
@ -156,23 +157,17 @@ AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator<number>
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp();
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp(() => 'Error');
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp(() => new Error('Error'));
validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => new Error('Error')));
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string });
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf(
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }));
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string }));
validateRequireableTop(AirbnbPropTypes.sequenceOf(
{ validator: PropTypes.number, min: 0, max: 10 },
{ validator: PropTypes.string },
{ validator: PropTypes.bool },
);
));
interface ShapeShape {
foo: string;

View File

@ -2,8 +2,12 @@ import Ember from 'ember';
// $
Ember.$; // $ExpectType JQueryStatic
const top = (<T>(x?: T): T => x!)();
type Top = typeof top;
declare function expectTypeNativeArrayTop(x: Ember.NativeArray<Top>): void;
// A
Ember.A(); // $ExpectType NativeArray<{}>
expectTypeNativeArrayTop(Ember.A());
Ember.A([1, 2]); // $ExpectType NativeArray<number>
// addListener
Ember.addListener({ a: 'foo' }, 'a', {}, () => {});

View File

@ -9,7 +9,7 @@ export interface PropertyBaseDefinition {
description?: string | DescriptionDefinition;
}
export class PropertyBase<TDefinition> implements PropertyBaseDefinition {
export class PropertyBase<TDefinition extends {}> implements PropertyBaseDefinition {
description?: string | DescriptionDefinition;
constructor(definition?: PropertyBaseDefinition | {info: PropertyBaseDefinition} | string);
@ -42,7 +42,7 @@ export interface PropertyDefinition extends PropertyBaseDefinition {
disabled?: boolean;
}
export class Property<TDefinition> extends PropertyBase<TDefinition> implements PropertyDefinition {
export class Property<TDefinition extends {}> extends PropertyBase<TDefinition> implements PropertyDefinition {
disabled: boolean;
id: string;
name: string;

View File

@ -7,4 +7,8 @@ acceptError(new TimeoutError());
timeout(); // $ExpectError
timeout(new Promise(() => { })); // $ExpectError
timeout(new Promise(() => { }), 1000); // $ExpectType Promise<{}>
const top = (<T>(x?: T): T => x!)();
type Top = typeof top;
declare function expectPromiseTop(x: Promise<Top>): void;
expectPromiseTop(timeout(new Promise(() => { }), 1000));

View File

@ -8,7 +8,7 @@ class ExampleOfUsingReactBroadcast extends React.Component {
<Broadcast channel="my-channel" value={42}>
<div>
<Subscriber channel="my-channel">
{state => <div>{state}</div>}
{(state: React.ReactNode) => <div>{state}</div>}
</Subscriber>
</div>
</Broadcast>

View File

@ -13,6 +13,10 @@ const spy: JasmineSpy = jasmine.createSpy('test');
when(spy); // $ExpectType CallHandler<JasmineSpy>
when(spy).isCalled; // $ExpectType Proxy<JasmineSpy>
when.captor(); // $ExpectType MatcherProxy<{}>
const top = (<T>(x?: T): T => x!)();
type Top = typeof top;
declare function expectMatcherProxyTop(x: (arg: Top) => boolean): void;
expectMatcherProxyTop(when.captor());
when.captor(jasmine.any(Number)); // $ExpectType MatcherProxy<Any>
when.noConflict(); // $ExpectType void

View File

@ -383,7 +383,9 @@ arrSchema.min(5, "min");
arrSchema.min(5, () => "min");
arrSchema.compact((value, index, array) => value === array[index]);
yup.array(); // $ExpectType ArraySchema<{}>
const arr = yup.array();
const top = (<T>(x?: T): T => x!)();
const validArr: yup.ArraySchema<typeof top> = arr;
yup.array(yup.string()); // $ExpectType ArraySchema<string>
yup.array().of(yup.string()); // $ExpectType ArraySchema<string>