Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change EventGroup.declare to string literal #14085

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions change/@uifabric-utilities-2020-09-04-11-48-42-patch-3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Change EventGroup.declare to string literal",
"packageName": "@uifabric/utilities",
"email": "email not provided",
"dependentChangeType": "patch",
"date": "2020-09-04T18:48:42.852Z"
}
2 changes: 1 addition & 1 deletion packages/utilities/etc/utilities.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function enableBodyScroll(): void;
// @public
export class EventGroup {
constructor(parent: any);
declare(event: string | string[]): void;
['declare'](event: string | string[]): void;
// (undocumented)
dispose(): void;
static isDeclared(target: any, eventName: string): boolean;
Expand Down
5 changes: 3 additions & 2 deletions packages/utilities/src/EventGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,10 @@ export class EventGroup {
}

/** Declare an event as being supported by this instance of EventGroup. */
public declare(event: string | string[]): void {
// Use quotes around 'declare' because it can also be a keyword in TS, which may cause problems
// for parsers (see https://github.com/alangpierce/sucrase/issues/545)
public ['declare'](event: string | string[]): void {
let declaredEvents = (this._parent.__declaredEvents = this._parent.__declaredEvents || {});

if (typeof event === 'string') {
declaredEvents[event] = true;
} else {
Expand Down