Skip to content

Commit

Permalink
Update to TypeScript 3.x #1071
Browse files Browse the repository at this point in the history
  • Loading branch information
Nev Wylie committed Jun 9, 2020
1 parent ecd509e commit 266ad6e
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 37 deletions.
2 changes: 1 addition & 1 deletion AISKU/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"source-map-loader": "^0.2.3",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "2.5.3"
"typescript": "^3.9.3"
},
"dependencies": {
"@microsoft/dynamicproto-js": "^0.5.2",
Expand Down
2 changes: 1 addition & 1 deletion AISKULight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0",
"source-map-loader": "^0.2.3",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"rollup": "^0.66.0",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
Expand Down
2 changes: 1 addition & 1 deletion channels/applicationinsights-channel-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"rollup": "^0.66.0"
Expand Down
6 changes: 3 additions & 3 deletions channels/applicationinsights-channel-js/src/Sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
/**
* error handler
*/
public _onError(payload: string[], message: string, event?: ErrorEvent) {
public _onError(payload: string[], message: string, event?: ErrorEvent|any) {
this.diagLog().throwInternal(
LoggingSeverity.WARNING,
_InternalMessageId.OnError,
Expand Down Expand Up @@ -572,7 +572,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
}

xhr.onreadystatechange = () => this._xhrReadyStateChange(xhr, payload, payload.length);
xhr.onerror = (event: ErrorEvent) => this._onError(payload, this._formatErrorMessageXhr(xhr), event);
xhr.onerror = (event) => this._onError(payload, this._formatErrorMessageXhr(xhr), event);

// compose an array of payloads
const batch = this._buffer.batchPayloads(payload);
Expand Down Expand Up @@ -701,7 +701,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
let _window = getWindow();
const xdr = new XDomainRequest();
xdr.onload = () => this._xdrOnLoad(xdr, payload);
xdr.onerror = (event: ErrorEvent) => this._onError(payload, this._formatErrorMessageXdr(xdr), event);
xdr.onerror = (event) => this._onError(payload, this._formatErrorMessageXdr(xdr), event);

// XDomainRequest requires the same protocol as the hosting page.
// If the protocol doesn't match, we can't send the telemetry :(.
Expand Down
14 changes: 7 additions & 7 deletions common/config/rush/npm-shrinkwrap.json

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

2 changes: 1 addition & 1 deletion extensions/applicationinsights-analytics-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@microsoft/applicationinsights-rollup-es3" : "1.1.1",
"@microsoft/applicationinsights-properties-js": "2.5.5",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"globby": "^11.0.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ export class ApplicationInsights extends BaseTelemetryPlugin implements IAppInsi
const handled = originalOnError && (originalOnError(message, url, lineNumber, columnNumber, error) as any);
if (handled !== true) { // handled could be typeof function
instance._onerror({
message,
message: CoreUtils.isString(message) ? message as string : (message ? message.toString() : null),
url,
lineNumber,
columnNumber,
Expand Down
2 changes: 1 addition & 1 deletion extensions/applicationinsights-angular-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "~3.4.3",
"typescript": "^3.9.3",
"rxjs": "~6.4.0",
"types": "^0.1.1",
"zone.js": "~0.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
"typescript": "^3.9.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,9 @@ export class AjaxFrozenTests extends TestClass {

// Restore the real fetch
window.fetch = this._fetch;
window["XMLHttpRequest"] = this._xmlHttpRequest;
if (this._xmlHttpRequest) {
getGlobal()["XMLHttpRequest"] = this._xmlHttpRequest;
}
}

public registerTests() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@microsoft/applicationinsights-rollup-es3" : "1.1.1",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"grunt": "1.0.1",
"grunt-contrib-qunit": "2.0.0",
"grunt-contrib-uglify": "3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion extensions/applicationinsights-properties-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@microsoft/applicationinsights-rollup-es3" : "1.1.1",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"grunt": "1.0.1",
"grunt-contrib-qunit": "2.0.0",
"grunt-contrib-uglify": "3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion extensions/applicationinsights-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "tslint -p tsconfig.json"
},
"devDependencies": {
"typescript": "^3.6.4",
"typescript": "^3.9.3",
"grunt": "1.0.1",
"grunt-contrib-qunit": "2.0.0",
"grunt-contrib-uglify": "3.1.0",
Expand Down
6 changes: 3 additions & 3 deletions legacy/JavaScript/JavaScriptSDK/Sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ module Microsoft.ApplicationInsights {
}

xhr.onreadystatechange = () => this._xhrReadyStateChange(xhr, payload, payload.length);
xhr.onerror = (event: ErrorEvent) => this._onError(payload, this._formatErrorMessageXhr(xhr), event);
xhr.onerror = (event) => this._onError(payload, this._formatErrorMessageXhr(xhr), event);

// compose an array of payloads
var batch = this._buffer.batchPayloads(payload);
Expand All @@ -436,7 +436,7 @@ module Microsoft.ApplicationInsights {
private _xdrSender(payload: string[], isAsync: boolean) {
var xdr = new XDomainRequest();
xdr.onload = () => this._xdrOnLoad(xdr, payload);
xdr.onerror = (event: ErrorEvent) => this._onError(payload, this._formatErrorMessageXdr(xdr), event);
xdr.onerror = (event) => this._onError(payload, this._formatErrorMessageXdr(xdr), event);

// XDomainRequest requires the same protocol as the hosting page.
// If the protocol doesn't match, we can't send the telemetry :(.
Expand Down Expand Up @@ -589,7 +589,7 @@ module Microsoft.ApplicationInsights {
/**
* error handler
*/
public _onError(payload: string[], message: string, event?: ErrorEvent) {
public _onError(payload: string[], message: string, event?: ErrorEvent|any) {
_InternalLogging.throwInternal(
LoggingSeverity.WARNING,
_InternalMessageId.OnError,
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tslint": "^5.19.0",
"tslint-microsoft-contrib": "^5.2.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"whatwg-fetch": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion shared/AppInsightsCommon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"rollup": "^0.66.0"
Expand Down
4 changes: 2 additions & 2 deletions shared/AppInsightsCommon/src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ export class Util {
* Checks if error has no meaningful data inside. Ususally such errors are received by window.onerror when error
* happens in a script from other domain (cross origin, CORS).
*/
public static isCrossOriginError(message: string, url: string, lineNumber: number, columnNumber: number, error: Error): boolean {
return (message === "Script error." || message === "Script error") && !error;
public static isCrossOriginError(message: string|Event, url: string, lineNumber: number, columnNumber: number, error: Error): boolean {
return !error && _isString(message) && (message === "Script error." || message === "Script error");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion shared/AppInsightsCore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"tslint-microsoft-contrib": "^5.2.1",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"rollup": "^0.66.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tools/rollup-es3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"tslint-microsoft-contrib": "^5.2.1",
"typescript": "2.5.3",
"typescript": "^3.9.3",
"magic-string": "^0.25.5"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tools/shims/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"tslint-microsoft-contrib": "^5.2.1",
"typescript": "2.5.3"
"typescript": "^3.9.3"
},
"dependencies": {
}
Expand Down
22 changes: 19 additions & 3 deletions tools/shims/src/applicationinsights-shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare var globalThis: Window;
declare var global: Window;
declare var __extends:(d: any, b: any) => any;
declare var __assign:(t: any) => any;
declare var __spreadArrays:(args: any[][]) => any[];

/**
* Returns the current global scope object, for a normal web page this will be the current
Expand Down Expand Up @@ -107,16 +108,31 @@ export function __extendsFn(d: any, b: any) {
d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new (__ as any)());
}

export function __spreadArraysFn(args: any[][]): any[] {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments[i].length;
}

for (var r = Array(s), k = 0, i = 0; i < il; i++) {
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
r[k] = a[j];
}
}

return r;
};

let globalObj:any = getGlobal() || {};

// tslint:disable: only-arrow-functions
(function (root: any, assignFn, extendsFn) {
(function (root: any, assignFn, extendsFn, spreadArraysFn) {
// Assign the globally scoped versions of the functions -- used when consuming individual ts files
root.__assign = root.__assign || (Object as any).assign || assignFn;
root.__extends = root.__extends || extendsFn;
})(globalObj, __assignFn, __extendsFn);
root.__spreadArrays = root.__spreadArrays || spreadArraysFn;
})(globalObj, __assignFn, __extendsFn, __spreadArraysFn);

// Assign local variables that will be used for embedded scenarios
__assign = globalObj.__assign;
__extends = globalObj.__extends;

__spreadArrays = globalObj.__spreadArrays;

0 comments on commit 266ad6e

Please sign in to comment.