Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
54 changes: 39 additions & 15 deletions common/config/rush/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions packages/utilities/api/utilities.api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function assign(target: any, ...args: any[]): any;

// WARNING: dispose has incomplete type information
// WARNING: clearImmediate has incomplete type information
// WARNING: clearInterval has incomplete type information
Expand Down Expand Up @@ -50,10 +52,11 @@ class BaseComponent<P extends IBaseProps, S> extends React.Component<P, S> {

// WARNING: contextTypes has incomplete type information
// WARNING: childContextTypes has incomplete type information
// WARNING: __constructor has incomplete type information
// WARNING: componentWillReceiveProps has incomplete type information
// WARNING: render has incomplete type information
class Customizer extends BaseComponent<ICustomizerProps, ICustomizerState> {
// (undocumented)
constructor(props: any, context: any);
public static addChangeListener(onChanged: IChangeListener): void;
// (undocumented)
public getChildContext(): any;
Expand Down Expand Up @@ -150,6 +153,8 @@ export function hasOverflow(element: HTMLElement): boolean;

export function hasVerticalOverflow(element: HTMLElement): boolean;

export function hoistMethods(destination: any, source: any, exclusions: string[] = REACT_LIFECYCLE_EXCLUSIONS): string[];

// (undocumented)
interface IBaseProps {
// (undocumented)
Expand Down Expand Up @@ -374,10 +379,8 @@ export function warnMutuallyExclusive < P >(componentName: string,
// WARNING: getWindow has incomplete type information
// WARNING: getDocument has incomplete type information
// WARNING: doesElementContainFocus has incomplete type information
// WARNING: hoistMethods has incomplete type information
// WARNING: setLanguage has incomplete type information
// WARNING: shallowCompare has incomplete type information
// WARNING: assign has incomplete type information
// WARNING: filteredAssign has incomplete type information
// WARNING: Unsupported export: baseElementEvents
// WARNING: Unsupported export: baseElementProperties
Expand Down
1 change: 1 addition & 0 deletions packages/utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@types/chai": "^3.4.35",
"@types/enzyme": "^2.7.5",
"@types/es6-promise": "^0.0.32",
"@types/es6-weak-map": "1.2.0",
"@types/mocha": "^2.2.39",
"@types/prop-types": "^15.5.1",
"@types/react": "^15.0.25",
Expand Down
20 changes: 10 additions & 10 deletions packages/utilities/src/Async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ declare function setTimeout(cb: Function, delay: number): number;
declare function setInterval(cb: Function, delay: number): number;

export class Async {
private _timeoutIds = null;
private _immediateIds = null;
private _intervalIds = null;
private _timeoutIds: any = null;
private _immediateIds: any = null;
private _intervalIds: any = null;
private _animationFrameIds: { [id: number]: boolean } = null;
private _isDisposed = false;
private _parent: any;
Expand All @@ -38,7 +38,7 @@ export class Async {
if (this._timeoutIds) {
for (id in this._timeoutIds) {
if (this._timeoutIds.hasOwnProperty(id)) {
this.clearTimeout(id);
this.clearTimeout(parseInt(id, 10));
}
}

Expand All @@ -49,7 +49,7 @@ export class Async {
if (this._immediateIds) {
for (id in this._immediateIds) {
if (this._immediateIds.hasOwnProperty(id)) {
this.clearImmediate(id);
this.clearImmediate(parseInt(id, 10));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there is a bug here, but I don't have enough context. Id is a string since it's a key in _timeoutIds, but it's being used as a number...

Copy link
Member

@dzearing dzearing Jun 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's a bug, unless it's browser specific. I just tried it by caching the stringified value of the response of setTimeout and then calling clearTimeout with it and it worked. Are you seeing an actual bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not seeing an actual bug. It just stood out to me.

}
}

Expand All @@ -60,7 +60,7 @@ export class Async {
if (this._intervalIds) {
for (id in this._intervalIds) {
if (this._intervalIds.hasOwnProperty(id)) {
this.clearInterval(id);
this.clearInterval(parseInt(id, 10));
}
}
this._intervalIds = null;
Expand All @@ -70,7 +70,7 @@ export class Async {
if (this._animationFrameIds) {
for (id in this._animationFrameIds) {
if (this._animationFrameIds.hasOwnProperty(id)) {
this.cancelAnimationFrame(id);
this.cancelAnimationFrame(parseInt(id, 10));
}
}

Expand Down Expand Up @@ -254,7 +254,7 @@ export class Async {
let leading = true;
let trailing = true;
let lastExecuteTime = 0;
let lastResult;
let lastResult: any;
let lastArgs: any[];
let timeoutId: number = null;

Expand Down Expand Up @@ -320,10 +320,10 @@ export class Async {
let waitMS = wait || 0;
let leading = false;
let trailing = true;
let maxWait = null;
let maxWait: any = null;
let lastCallTime = 0;
let lastExecuteTime = (new Date).getTime();
let lastResult;
let lastResult: any;
let lastArgs: any[];
let timeoutId: number = null;

Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/src/BaseComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ describe('BaseComponent', () => {
});
});

function _buildTestFor(methodName) {
function _buildTestFor(methodName: string) {
it(`calls the error logger on ${methodName} exception`, () => {
let lastErrorMessage = null;

BaseComponent.onError = (errorMessage, ex) => lastErrorMessage = errorMessage;

let c = new TestComponent();

c[methodName]();
(c as any)[methodName]();

assert(lastErrorMessage !== null, 'Error callback not called');
});
Expand Down
8 changes: 4 additions & 4 deletions packages/utilities/src/BaseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class BaseComponent<P extends IBaseProps, S> extends React.Component<P, S
}
if (!this.__resolves[refName]) {
this.__resolves[refName] = (ref) => {
return this[refName] = ref;
return (this as any)[refName] = ref;
};
}

Expand Down Expand Up @@ -202,11 +202,11 @@ function _makeAllSafe(obj: BaseComponent<any, any>, prototype: Object, methodNam
}

function _makeSafe(obj: BaseComponent<any, any>, prototype: Object, methodName: string) {
let classMethod = obj[methodName];
let prototypeMethod = prototype[methodName];
let classMethod = (obj as any)[methodName];
let prototypeMethod = (prototype as any)[methodName];

if (classMethod || prototypeMethod) {
obj[methodName] = function () {
(obj as any)[methodName] = function () {
let retVal;

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/src/Customizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Customizer extends BaseComponent<ICustomizerProps, ICustomizerState
}
}

constructor(props, context) {
constructor(props: any, context: any) {
super(props);

this.state = this._getInjectedProps(props, context);
Expand All @@ -87,7 +87,7 @@ export class Customizer extends BaseComponent<ICustomizerProps, ICustomizerState
return this.state;
}

public componentWillReceiveProps(newProps, newContext) {
public componentWillReceiveProps(newProps: any, newContext: any) {
this.setState(this._getInjectedProps(newProps, newContext));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/DelayedRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DelayedRender extends React.Component<IDelayedRenderProps, IDelayed
delay: 0
};

private _timeoutId;
private _timeoutId: number | undefined;

constructor(props: IDelayedRenderProps) {
super(props);
Expand Down
8 changes: 4 additions & 4 deletions packages/utilities/src/EventGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IDeclaredEventsByName {
*/
export class EventGroup {
private static _uniqueId = 0;
private _parent;
private _parent: any;
private _eventRecords: IEventRecord[];
private _id = EventGroup._uniqueId++;
private _isDisposed: boolean;
Expand All @@ -56,10 +56,10 @@ export class EventGroup {
let ev = document.createEvent('HTMLEvents');

ev.initEvent(eventName, bubbleEvent, true);
ev['args'] = eventArgs;
(ev as any)['args'] = eventArgs;
retVal = target.dispatchEvent(ev);
} else if (document['createEventObject']) { // IE8
let evObj = document['createEventObject'](eventArgs);
} else if ((document as any)['createEventObject']) { // IE8
let evObj = (document as any)['createEventObject'](eventArgs);
// cannot set cancelBubble on evObj, fireEvent will overwrite it
target.fireEvent('on' + eventName, evObj);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/autobind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function autobind<T extends Function>(target: any, key: string, descripto
return fnBound;
},

set(newValue) {
set(newValue: any) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function css(...args: ICssInput[]) {
classes.push(arg.toString());
} else {
for (let key in arg as any) {
if (arg[key]) {
if ((arg as any)[key]) {
classes.push(key);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/customizable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Foo extends React.Component<{ field: string; }, {}> {
public name: any;

public render() {
return <div>{ this.props[this.props.field] }</div>;
return <div>{ (this.props as any)[this.props.field] }</div>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/customizable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function customizable<P>(fields: string[]) {
let defaultProps = {};

for (let propName of fields) {
defaultProps[propName] = (this.context.injectedProps) ?
(defaultProps as any)[propName] = (this.context.injectedProps) ?
this.context.injectedProps[propName] :
Customizer.getDefault(propName);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ let _isSSR = false;
/**
* Helper to set ssr mode to simulate no window object returned from getWindow helper.
*/
export function setSSR(isEnabled) {
export function setSSR(isEnabled: boolean) {
_isSSR = isEnabled;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/utilities/src/focus.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ let { expect } = chai;

import { isElementVisible, isElementTabbable } from './focus';

let _hiddenElement;
let _visibleElement;
let _element;
let _hiddenElement: HTMLElement | undefined;
let _visibleElement: HTMLElement | undefined;
let _element: HTMLElement | undefined;

function renderIntoDocument(element: React.ReactElement<any>): HTMLElement {
const component = ReactTestUtils.renderIntoDocument(element);
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/hoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const REACT_LIFECYCLE_EXCLUSIONS = [
* @param exclusions - (Optional) What methods to exclude from being hoisted.
* @returns An array of names of methods that were hoisted.
*/
export function hoistMethods(destination, source, exclusions: string[] = REACT_LIFECYCLE_EXCLUSIONS): string[] {
export function hoistMethods(destination: any, source: any, exclusions: string[] = REACT_LIFECYCLE_EXCLUSIONS): string[] {
let hoisted: string[] = [];
for (let methodName in source) {
if (
Expand Down
6 changes: 3 additions & 3 deletions packages/utilities/src/memoize.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { memoize, memoizeFunction, setMemoizeWeakMap } from './memoize';
import * as weakMapPolyfill from 'es6-weak-map/polyfill';
import weakMapPolyfill = require('es6-weak-map');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzearing, is this ok? I was having a hard time getting the /polyfill path to work because it doesn't have a d.ts file. I remember you mentioning that this was a fix for UT environments? Based on this, it seems like the behavior is different for the /polyfill path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a fix to be ok with WeakMap missing in the memoize functions. i think this is ok as long as tests pass.


let { expect } = chai;

describe('memoizeFunction', () => {
before(()=> {
before(() => {
setMemoizeWeakMap(weakMapPolyfill);
});

Expand Down Expand Up @@ -95,7 +95,7 @@ describe('memoizeFunction', () => {
});

describe('memoize', () => {
before(()=> {
before(() => {
setMemoizeWeakMap(weakMapPolyfill);
});

Expand Down
Loading