Skip to content

Commit

Permalink
yarn prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihanChen-MSFT committed Sep 26, 2022
1 parent c4b4f32 commit 701166a
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 151 deletions.
2 changes: 1 addition & 1 deletion Libraries/vendor/core/ErrorUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @format
*/

type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;
type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;

export interface ErrorUtils {
setGlobalHandler: (callback: ErrorHandlerCallback) => void;
Expand Down
290 changes: 145 additions & 145 deletions Libraries/vendor/emitter/EventEmitter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,158 +7,158 @@
* @format
*/

/**
/**
* EventSubscription represents a subscription to a particular event. It can
* remove its own subscription.
*/
interface EventSubscription {
eventType: string;
key: number;
subscriber: EventSubscriptionVendor;

/**
* @param subscriber the subscriber that controls
* this subscription.
*/
new (subscriber: EventSubscriptionVendor): EventSubscription;

/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void;
}
eventType: string;
key: number;
subscriber: EventSubscriptionVendor;

/**
* @param subscriber the subscriber that controls
* this subscription.
*/
new (subscriber: EventSubscriptionVendor): EventSubscription;

/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void;
}

/**
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
*/
declare class EventSubscriptionVendor {
constructor();

/**
* Adds a subscription keyed by an event type.
*
*/
addSubscription(
eventType: string,
subscription: EventSubscription,
): EventSubscription;

/**
* Removes a bulk set of the subscriptions.
*
* @param eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void;

/**
* Removes a specific subscription. Instead of calling this function, call
* `subscription.remove()` directly.
*
*/
removeSubscription(subscription: any): void;

/**
* Returns the array of subscriptions that are currently registered for the
* given event type.
*
* Note: This array can be potentially sparse as subscriptions are deleted
* from it when they are removed.
*
*/
getSubscriptionsForType(eventType: string): EventSubscription[];
}

/**
* EmitterSubscription represents a subscription with listener and context data.
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter;
listener: () => any;
context: any;

/**
* @param emitter - The event emitter that registered this
* subscription
* @param subscriber - The subscriber that controls
* this subscription
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
new (
emitter: EventEmitter,
subscriber: EventSubscriptionVendor,
listener: () => any,
context: any,
): EmitterSubscription;

/**
* Removes this subscription from the emitter that registered it.
* Note: we're overriding the `remove()` method of EventSubscription here
* but deliberately not calling `super.remove()` as the responsibility
* for removing the subscription lies with the EventEmitter.
*/
remove(): void;
}

export declare class EventEmitter {
/**
*
* @param subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
constructor(subscriber?: EventSubscriptionVendor | null);

/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*
* @param eventType - Name of the event to listen to
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
addListener(
eventType: string,
listener: (...args: any[]) => any,
context?: any,
): EmitterSubscription;

/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*
* @param eventType - Optional name of the event whose registered
* listeners to remove
*/
removeAllListeners(eventType?: string): void;

/**
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
* Returns the number of listeners that are currently registered for the given
* event.
*
* @param eventType - Name of the event to query
*/
declare class EventSubscriptionVendor {
constructor();

/**
* Adds a subscription keyed by an event type.
*
*/
addSubscription(
eventType: string,
subscription: EventSubscription,
): EventSubscription;

/**
* Removes a bulk set of the subscriptions.
*
* @param eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void;

/**
* Removes a specific subscription. Instead of calling this function, call
* `subscription.remove()` directly.
*
*/
removeSubscription(subscription: any): void;

/**
* Returns the array of subscriptions that are currently registered for the
* given event type.
*
* Note: This array can be potentially sparse as subscriptions are deleted
* from it when they are removed.
*
*/
getSubscriptionsForType(eventType: string): EventSubscription[];
}
listenerCount(eventType: string): number;

/**
* EmitterSubscription represents a subscription with listener and context data.
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*
* @param eventType - Name of the event to emit
* @param Arbitrary arguments to be passed to each registered listener
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter;
listener: () => any;
context: any;

/**
* @param emitter - The event emitter that registered this
* subscription
* @param subscriber - The subscriber that controls
* this subscription
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
new (
emitter: EventEmitter,
subscriber: EventSubscriptionVendor,
listener: () => any,
context: any,
): EmitterSubscription;

/**
* Removes this subscription from the emitter that registered it.
* Note: we're overriding the `remove()` method of EventSubscription here
* but deliberately not calling `super.remove()` as the responsibility
* for removing the subscription lies with the EventEmitter.
*/
remove(): void;
}

export declare class EventEmitter {
/**
*
* @param subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
constructor(subscriber?: EventSubscriptionVendor | null);

/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*
* @param eventType - Name of the event to listen to
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
addListener(
eventType: string,
listener: (...args: any[]) => any,
context?: any,
): EmitterSubscription;

/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*
* @param eventType - Optional name of the event whose registered
* listeners to remove
*/
removeAllListeners(eventType?: string): void;

/**
* Returns the number of listeners that are currently registered for the given
* event.
*
* @param eventType - Name of the event to query
*/
listenerCount(eventType: string): number;

/**
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*
* @param eventType - Name of the event to emit
* @param Arbitrary arguments to be passed to each registered listener
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
emit(eventType: string, ...params: any[]): void;
}
emit(eventType: string, ...params: any[]): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const flowSnaps = require('../../../../src/parsers/flow/components/__tests__/__s
const flowExtraCases = [];
const tsFixtures = require('../../typescript/components/__test_fixtures__/fixtures.js');
const tsSnaps = require('../../../../src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap');
const tsExtraCases = ['ARRAY2_PROP_TYPES_NO_EVENTS', 'ARRAY2_STATE_TYPES', 'PROPS_AND_EVENTS_WITH_INTERFACES'];
const tsExtraCases = [
'ARRAY2_PROP_TYPES_NO_EVENTS',
'ARRAY2_STATE_TYPES',
'PROPS_AND_EVENTS_WITH_INTERFACES',
];
const ignoredCases = ['ARRAY_PROP_TYPES_NO_EVENTS', 'ARRAY_STATE_TYPES'];

compareSnaps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,7 @@ function flattenProperties(
} else if (property.type === 'TSTypeLiteral') {
return flattenProperties(property.members, types);
} else if (property.type === 'TSInterfaceDeclaration') {
return flattenProperties(
getProperties(property.id.name, types),
types,
);
return flattenProperties(getProperties(property.id.name, types), types);
} else {
throw new Error(
`${property.type} is not a supported object literal type.`,
Expand Down

0 comments on commit 701166a

Please sign in to comment.