Make typings compatible with @types/node.

Fixes name clashes and uses Node-compatible typings where possible.

Changes:
 - setTimout et al now return NodeJS.Timer instead of number
 - No "console" module anymore. Everyone uses it through global.console
 anyway.
 - We have a typed "global" instance with exposed properties now. Any
 "freeform" accesses must go through a `(<any>global).blah` cast.
 - remove tns-core-modules.{base,es6,es2015}.d.ts. Those were needed
 as workarounds for the ES6/DOM/Node type clashes.
This commit is contained in:
Hristo Deshev
2017-02-14 17:40:25 +02:00
parent 3056ce51c2
commit 86481cce4a
25 changed files with 238 additions and 307 deletions

View File

@ -1,7 +1,7 @@
import * as application from "application"; import * as application from "application";
declare var CACurrentMediaTime; declare var CACurrentMediaTime;
global.time = function(): number { (<any>global).time = function(): number {
if (global.android) { if (global.android) {
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
} }
@ -10,4 +10,4 @@ global.time = function(): number {
} }
} }
application.start({ moduleName: "css-perf-test/root" }); application.start({ moduleName: "css-perf-test/root" });

View File

@ -2,6 +2,6 @@
export function navigatedTo(args: ObservableEventData) { export function navigatedTo(args: ObservableEventData) {
setTimeout(() => { setTimeout(() => {
console.log(`Time: ${global.time() - global.startTime} ms`); console.log(`Time: ${(<any>global).time() - (<any>global).startTime} ms`);
}); });
} }

View File

@ -1,7 +1,7 @@
import {Page} from "ui/page"; import {Page} from "ui/page";
export function onTap(args: any) { export function onTap(args: any) {
global.startTime = global.time(); (<any>global).startTime = (<any>global).time();
let page = <Page>args.object.page; let page = <Page>args.object.page;
page.frame.navigate("css-perf-test/main-page"); page.frame.navigate("css-perf-test/main-page");
} }

View File

@ -84,13 +84,9 @@ module.exports = function(grunt) {
}); });
var combinedDtsPath = path.join(outDir, outFile); var combinedDtsPath = path.join(outDir, outFile);
grunt.file.write(combinedDtsPath, dtsLines.join('\n')); grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
} };
var generateModulesDts = function generateModulesDts(outDir, srcDir) { var generateModulesDts = function generateModulesDts(outDir, srcDir) {
var angularConflicts = ['module.d.ts'];
var angularExcludes = angularConflicts.map(function(file) {
return '!' + file;
});
var dtsFiles = grunt.file.expand({cwd: srcDir }, [ var dtsFiles = grunt.file.expand({cwd: srcDir }, [
"**/*.d.ts", "**/*.d.ts",
//Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there! //Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there!
@ -99,24 +95,14 @@ module.exports = function(grunt) {
"!android17.d.ts", "!android17.d.ts",
"!**/*.android.d.ts", "!**/*.android.d.ts",
"!ios/**", "!ios/**",
"!lib.core.d.ts",
"!lib.dom.d.ts",
"!**/*.ios.d.ts", "!**/*.ios.d.ts",
"!tns-core-modules.d.ts", "!tns-core-modules.d.ts",
"!tns-core-modules.es6.d.ts",
"!tns-core-modules.es2016.d.ts",
"!tns-core-modules.base.d.ts",
"!references.d.ts", "!references.d.ts",
"!webworker.es2016.d.ts" ].concat(localCfg.defaultExcludes));
].concat(localCfg.defaultExcludes).concat(angularExcludes));
dtsFiles.sort(); dtsFiles.sort();
writeDtsFile(dtsFiles, outDir, 'tns-core-modules/tns-core-modules.base.d.ts'); writeDtsFile(dtsFiles, outDir, "tns-core-modules/tns-core-modules.d.ts");
var es6Files = angularConflicts.concat(['tns-core-modules.base.d.ts']); };
writeDtsFile(es6Files, outDir, 'tns-core-modules/tns-core-modules.es6.d.ts');
var allFiles = angularConflicts.concat(['tns-core-modules.base.d.ts']);
writeDtsFile(allFiles, outDir, 'tns-core-modules/tns-core-modules.d.ts');
}
// Configure localCfg // Configure localCfg
var outDir = tsconfig.compilerOptions.outDir || "./bin/dist"; var outDir = tsconfig.compilerOptions.outDir || "./bin/dist";
@ -411,9 +397,9 @@ module.exports = function(grunt) {
}); });
grunt.registerTask("generate-tns-core-modules-dev-dts", generateModulesDts.bind(null, ".", localCfg.srcTnsCoreModules)); grunt.registerTask("generate-tns-core-modules-dev-dts", generateModulesDts.bind(null, ".", localCfg.srcTnsCoreModules));
grunt.registerTask("generate-tns-core-modules-dts", generateModulesDts.bind(null, localCfg.outDir, localCfg.outTnsCoreModules)); grunt.registerTask("generate-tns-core-modules-dts", generateModulesDts.bind(null, localCfg.outDir, localCfg.outTnsCoreModules));
//aliasing pack-modules for backwards compatibility //aliasing pack-modules for backwards compatibility
grunt.registerTask("pack-modules", [ grunt.registerTask("pack-modules", [
"compile-modules", "compile-modules",

View File

@ -1,5 +1,4 @@
require("globals"); require("globals");
import * as definition from "application";
import * as observable from "data/observable"; import * as observable from "data/observable";
// TODO: Raise event on("livesync") and attach this handler in the ui/frame module. // TODO: Raise event on("livesync") and attach this handler in the ui/frame module.
import { NavigationEntry, reloadPage } from "ui/frame"; import { NavigationEntry, reloadPage } from "ui/frame";
@ -62,7 +61,7 @@ export function setResources(res: any) {
resources = res; resources = res;
} }
export var onUncaughtError: (error: definition.NativeScriptError) => void = undefined; export var onUncaughtError: (error: NativeScriptError) => void = undefined;
export var onLaunch: (context: any) => any = undefined; export var onLaunch: (context: any) => any = undefined;
@ -118,9 +117,9 @@ export function parseCss(cssText: string, cssFileName?: string): RuleSet[] {
export function __onLiveSync() { export function __onLiveSync() {
// Close the error page if available and remove the reference from global context. // Close the error page if available and remove the reference from global context.
if (global.errorPage) { if ((<any>global).errorPage) {
global.errorPage.closeModal(); (<any>global).errorPage.closeModal();
global.errorPage = undefined; (<any>global).errorPage = undefined;
} }
try { try {
@ -132,13 +131,13 @@ export function __onLiveSync() {
// Reload app.css in case it was changed. // Reload app.css in case it was changed.
loadCss(); loadCss();
global.__onLiveSyncCore(); (<any>global).__onLiveSyncCore();
} catch (ex) { } catch (ex) {
// Show the error as modal page, save reference to the page in global context. // Show the error as modal page, save reference to the page in global context.
ensureBuilder(); ensureBuilder();
global.errorPage = builder.parse(`<Page><ScrollView><Label text="${ex}" textWrap="true" style="color: red;" /></ScrollView></Page>`); (<any>global).errorPage = builder.parse(`<Page><ScrollView><Label text="${ex}" textWrap="true" style="color: red;" /></ScrollView></Page>`);
global.errorPage.showModal(); (<any>global).errorPage.showModal();
} }
} }
@ -146,7 +145,7 @@ export function __onLiveSyncCore() {
// Reload current page. // Reload current page.
reloadPage(); reloadPage();
} }
global.__onLiveSyncCore = __onLiveSyncCore; (<any>global).__onLiveSyncCore = __onLiveSyncCore;
export function _onOrientationChanged(){ export function _onOrientationChanged(){
ensurePlatform(); ensurePlatform();
@ -154,4 +153,4 @@ export function _onOrientationChanged(){
ensureFileNameResolver(); ensureFileNameResolver();
fileNameResolver._invalidateResolverInstance(); fileNameResolver._invalidateResolverInstance();
} }

View File

@ -334,7 +334,7 @@ global.__onLiveSync = function () {
loadCss(); loadCss();
}; };
global.__onUncaughtError = function (error: definition.NativeScriptError) { global.__onUncaughtError = function (error: NativeScriptError) {
const types: typeof typesModule = require("utils/types"); const types: typeof typesModule = require("utils/types");
// TODO: Obsolete this // TODO: Obsolete this

View File

@ -5,16 +5,6 @@ declare module "application" {
import { RuleSet } from "ui/styling/css-selector"; import { RuleSet } from "ui/styling/css-selector";
import { NavigationEntry, View, Observable } from "ui/frame"; import { NavigationEntry, View, Observable } from "ui/frame";
/**
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
*/
export interface NativeScriptError extends Error {
/**
* Represents the native error object.
*/
nativeError: any;
}
/** /**
* String value used when hooking to launch event. * String value used when hooking to launch event.
*/ */

View File

@ -215,7 +215,7 @@ class IOSApplication implements definition.iOSApplication {
var iosApp = new IOSApplication(); var iosApp = new IOSApplication();
typedExports.ios = iosApp; typedExports.ios = iosApp;
global.__onUncaughtError = function (error: definition.NativeScriptError) { global.__onUncaughtError = function (error: NativeScriptError) {
var types: typeof typesModule = require("utils/types"); var types: typeof typesModule = require("utils/types");
// TODO: This should be obsoleted // TODO: This should be obsoleted

View File

@ -1,74 +0,0 @@
/**
* Allows printing messages to the device's console.
*/
declare module "console" {
/**
* Encapsulates methods used to print some information in the console.
* Instance of this class is declared in the global JavaScript context and is accessible by directly calling console.[xxx] methods.
*/
class Console {
/**
* Begins counting a time span for a given name (key).
* @param reportName The key for the operation.
*/
public time(reportName: string): void;
/**
* Ends a previously started time span through the time method.
* @param reportName The key for the operation. Must have an already started time(reportName) operation with the same key.
*/
public timeEnd(reportName: string): void;
/**
* Asserts a boolean condition and prints a message in case the assert fails.
* @param test A value that should not be Falsy.
* @param message The message to be displayed in case the asserted value is Falsy.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/
public assert(test: boolean, message: string, ...formatParams: any[]): void;
/**
* Reports some information.
* @param message The information message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/
public info(message: any, ...formatParams: any[]): void;
/**
* Reports a warning.
* @param message The warning message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/
public warn(message: any, ...formatParams: any[]): void;
/**
* Reports an error.
* @param message The error message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/
public error(message: any, ...formatParams: any[]): void;
/**
* Verbously logs a message.
* @param message The message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/
public log(message: any, ...formatParams: any[]): void;
/**
* Prints the current stack trace in the console.
*/
public trace(): void;
/**
* Prints the state of the specified object to the console.
* @param obj The object instance to be dumped.
*/
public dump(obj: any): void;
/**
* Prints the state of the specified object to the console.
*/
public dir(obj: any): void;
}
}

View File

@ -1,8 +1,13 @@
import * as definition from "console";
import * as trace from "trace"; import * as trace from "trace";
import * as platform from "platform"; import * as platform from "platform";
export class Console implements definition.Console { function __message(message: any, level: string) {
if ((<any>global).__consoleMessage) {
(<any>global).__consoleMessage(message, level);
}
}
export class Console {
private TAG: string = "JS"; private TAG: string = "JS";
private _timers: any; private _timers: any;
private _stripFirstTwoLinesRegEx: RegExp; private _stripFirstTwoLinesRegEx: RegExp;
@ -250,9 +255,7 @@ export class Console implements definition.Console {
Array.prototype.shift.apply(arguments); Array.prototype.shift.apply(arguments);
let formatedMessage = this.formatParams.apply(this, arguments); let formatedMessage = this.formatParams.apply(this, arguments);
this.error(formatedMessage, trace.messageType.error); this.error(formatedMessage, trace.messageType.error);
if (global.__consoleMessage) { __message(formatedMessage, "error");
global.__consoleMessage(formatedMessage, "error");
}
} }
} }
@ -263,29 +266,23 @@ export class Console implements definition.Console {
public warn(message: any, ...formatParams: any[]): void { public warn(message: any, ...formatParams: any[]): void {
let formatedMessage = this.formatParams.apply(this, arguments); let formatedMessage = this.formatParams.apply(this, arguments);
this.logMessage(formatedMessage, trace.messageType.warn); this.logMessage(formatedMessage, trace.messageType.warn);
if (global.__consoleMessage) { __message(formatedMessage, "warning");
global.__consoleMessage(formatedMessage, "warning");
}
} }
public error(message: any, ...formatParams: any[]): void { public error(message: any, ...formatParams: any[]): void {
let formatedMessage = this.formatParams.apply(this, arguments); let formatedMessage = this.formatParams.apply(this, arguments);
this.logMessage(formatedMessage, trace.messageType.error); this.logMessage(formatedMessage, trace.messageType.error);
if (global.__consoleMessage) { __message(formatedMessage, "error");
global.__consoleMessage(formatedMessage, "error")
}
} }
public log(message: any, ...formatParams: any[]): void { public log(message: any, ...formatParams: any[]): void {
let formatedMessage = this.formatParams.apply(this, arguments); let formatedMessage = this.formatParams.apply(this, arguments);
this.logMessage(formatedMessage, trace.messageType.log); this.logMessage(formatedMessage, trace.messageType.log);
if (global.__consoleMessage) { __message(formatedMessage, "log");
global.__consoleMessage(formatedMessage, "log")
}
} }
private logMessage(message: string, messageType: number): void { private logMessage(message: string, messageType: number): void {
if (!global.android) { if (!(<any>global).android) {
// This case may be entered during heap snapshot where the global.android is not present // This case may be entered during heap snapshot where the global.android is not present
return; return;
} }

View File

@ -98,22 +98,24 @@ declare type RequestInfo = Request|string;
declare function fetch(url: string, init?: RequestInit): Promise<Response>; declare function fetch(url: string, init?: RequestInit): Promise<Response>;
/**
* Allows printing messages to the device's console.
*/
interface Console { interface Console {
time(reportName: string): void; /**
timeEnd(reportName: string): void; * Prints the current stack trace in the console.
assert(test: boolean, message: string, ...formatParams: any[]): void; */
info(message: any, ...formatParams: any[]): void;
warn(message: any, ...formatParams: any[]): void;
error(message: any, ...formatParams: any[]): void;
log(message: any, ...formatParams: any[]): void;
trace(): void; trace(): void;
/**
* Prints the state of the specified object to the console.
* @param obj The object instance to be dumped.
*/
dump(obj: any): void; dump(obj: any): void;
createDump(obj: any): string;
dir(obj: any): void;
} }
declare var console: Console; declare var console: Console;
declare var require: NativeScriptRequire; declare var require: NodeRequire;
// Global functions // Global functions
declare function Deprecated(target: Object, key?: string | symbol, value?: any): void; declare function Deprecated(target: Object, key?: string | symbol, value?: any): void;
@ -179,7 +181,7 @@ declare class WeakRef<T> {
clear(): void; clear(): void;
} }
declare var module: NativeScriptModule; declare var module: NodeModule;
// Same as module.exports // Same as module.exports
declare var exports: any; declare var exports: any;

View File

@ -1,10 +1,10 @@
if (typeof global.__decorate !== "function") { if (typeof (<any>global).__decorate !== "function") {
global.__decorate = function (decorators, target, key, desc) { (<any>global).__decorate = function (decorators, target, key, desc) {
var c = arguments.length; var c = arguments.length;
var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") { if (typeof (<any>global).Reflect === "object" && typeof (<any>global).Reflect.decorate === "function") {
r = global.Reflect.decorate(decorators, target, key, desc); r = (<any>global).Reflect.decorate(decorators, target, key, desc);
} }
else { else {
for (var i = decorators.length - 1; i >= 0; i--) { for (var i = decorators.length - 1; i >= 0; i--) {
@ -17,16 +17,16 @@ if (typeof global.__decorate !== "function") {
} }
} }
if (typeof global.__metadata !== "function") { if (typeof (<any>global).__metadata !== "function") {
global.__metadata = function (k, v) { (<any>global).__metadata = function (k, v) {
if (typeof global.Reflect === "object" && typeof global.Reflect.metadata === "function") { if (typeof (<any>global).Reflect === "object" && typeof (<any>global).Reflect.metadata === "function") {
return global.Reflect.metadata(k, v); return (<any>global).Reflect.metadata(k, v);
} }
}; };
} }
if (typeof global.__param !== "function") { if (typeof (<any>global).__param !== "function") {
global.__param = (global && global.__param) || function (paramIndex, decorator) { (<any>global).__param = (global && (<any>global).__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); } return function (target, key) { decorator(target, key, paramIndex); }
}; };
} }

View File

@ -46,13 +46,13 @@ global.loadModule = function(name: string): any {
} }
global.zonedCallback = function (callback: Function): Function { global.zonedCallback = function (callback: Function): Function {
if (global.zone) { if ((<any>global).zone) {
// Zone v0.5.* style callback wrapping // Zone v0.5.* style callback wrapping
return global.zone.bind(callback); return (<any>global).zone.bind(callback);
} }
if (global.Zone) { if ((<any>global).Zone) {
// Zone v0.6.* style callback wrapping // Zone v0.6.* style callback wrapping
return global.Zone.current.wrap(callback); return (<any>global).Zone.current.wrap(callback);
} else { } else {
return callback; return callback;
} }
@ -86,28 +86,28 @@ function registerOnGlobalContext(name: string, module: string): void {
}); });
} }
if (global.__snapshot) { if ((<any>global).__snapshot) {
// when we have a snapshot, it is better to pre-populate these on the global context to get them saved within the blob // when we have a snapshot, it is better to pre-populate these on the global context to get them saved within the blob
var timer: typeof timerModule = require("timer"); var timer: typeof timerModule = require("timer");
global.setTimeout = timer.setTimeout; (<any>global).setTimeout = timer.setTimeout;
global.clearTimeout = timer.clearTimeout; (<any>global).clearTimeout = timer.clearTimeout;
global.setInterval = timer.setInterval; (<any>global).setInterval = timer.setInterval;
global.clearInterval = timer.clearInterval; (<any>global).clearInterval = timer.clearInterval;
var dialogs: typeof dialogsModule = require("ui/dialogs"); var dialogs: typeof dialogsModule = require("ui/dialogs");
global.alert = dialogs.alert; (<any>global).alert = dialogs.alert;
global.confirm = dialogs.confirm; (<any>global).confirm = dialogs.confirm;
global.prompt = dialogs.prompt; (<any>global).prompt = dialogs.prompt;
var xhr = require("xhr"); var xhr = require("xhr");
global.XMLHttpRequest = xhr.XMLHttpRequest; (<any>global).XMLHttpRequest = xhr.XMLHttpRequest;
global.FormData = xhr.FormData; (<any>global).FormData = xhr.FormData;
var fetch = require("fetch"); var fetch = require("fetch");
global.fetch = fetch.fetch; (<any>global).fetch = fetch.fetch;
global.Headers = fetch.Headers; (<any>global).Headers = fetch.Headers;
global.Request = fetch.Request; (<any>global).Request = fetch.Request;
global.Response = fetch.Response; (<any>global).Response = fetch.Response;
} else { } else {
registerOnGlobalContext("setTimeout", "timer"); registerOnGlobalContext("setTimeout", "timer");
registerOnGlobalContext("clearTimeout", "timer"); registerOnGlobalContext("clearTimeout", "timer");
@ -122,14 +122,14 @@ if (global.__snapshot) {
} }
import * as platform from "platform"; import * as platform from "platform";
import * as consoleModule from "console";
let consoleModule = require("console");
var c = new consoleModule.Console(); var c = new consoleModule.Console();
if (platform.device.os === platform.platformNames.android) { if (platform.device.os === platform.platformNames.android) {
global.console = c; (<any>global).console = c;
} else if (platform.device.os === platform.platformNames.ios) { } else if (platform.device.os === platform.platformNames.ios) {
global.console.dump = function (args) { c.dump(args); }; (<any>global).console.dump = function (args) { c.dump(args); };
} }
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) { export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {

View File

@ -1,13 +1,50 @@
//Base module declarations declare var global: NodeJS.Global;
//Not required in Angular apps since it clashes with its typings.
declare var global: any;
interface NativeScriptRequire { //Augment the NodeJS global type with our own extensions
declare namespace NodeJS {
interface Global {
android?: any;
require(id: string): any;
registerModule(name: string, loader: ((name: string) => any)): void;
loadModule(name: string): any;
moduleExists(name: string): boolean;
moduleMerge(sourceExports: any, destExports: any): void;
zonedCallback(callback: Function): Function;
Reflect?: any;
Deprecated(target: Object, key?: string | symbol, descriptor?: any): any;
Experimental(target: Object, key?: string | symbol, descriptor?: any): any;
__native?: any;
__extends: any;
__onLiveSync: () => void;
__onUncaughtError: (error: NativeScriptError) => void;
TNS_WEBPACK?: boolean;
}
}
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
declare function clearTimeout(timeoutId: number): void;
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
declare function clearInterval(intervalId: number): void;
/**
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
*/
interface NativeScriptError extends Error {
/**
* Represents the native error object.
*/
nativeError: any;
}
// Define a minimal subset of NodeRequire and NodeModule so user apps can compile without
// installing @types/node
interface NodeRequire {
(id: string): any; (id: string): any;
} }
interface NativeScriptModule { interface NodeModule {
exports: any;
id: string; id: string;
filename: string; filename: string;
exports: any;
} }

View File

@ -2,7 +2,7 @@
"name": "tns-core-modules", "name": "tns-core-modules",
"description": "Telerik NativeScript Core Modules", "description": "Telerik NativeScript Core Modules",
"version": "3.0.0", "version": "3.0.0",
"homepage":"https://www.nativescript.org", "homepage": "https://www.nativescript.org",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/NativeScript/NativeScript" "url": "https://github.com/NativeScript/NativeScript"
@ -27,6 +27,7 @@
"tns-core-modules-widgets": "rc" "tns-core-modules-widgets": "rc"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "~7.0.5",
"tns-platform-declarations": "*" "tns-platform-declarations": "*"
}, },
"nativescript": { "nativescript": {

View File

@ -38,9 +38,10 @@ export function setTimeout(callback: Function, milliseconds = 0): number {
} }
export function clearTimeout(id: number): void { export function clearTimeout(id: number): void {
if (timeoutCallbacks[id]) { let index = id;
timeoutHandler.removeCallbacks(timeoutCallbacks[id]); if (timeoutCallbacks[index]) {
delete timeoutCallbacks[id]; timeoutHandler.removeCallbacks(timeoutCallbacks[index]);
delete timeoutCallbacks[index];
} }
} }

View File

@ -27,4 +27,4 @@ declare module "timer" {
* @param id The identifier returned by the setInterval() method. * @param id The identifier returned by the setInterval() method.
*/ */
export function clearInterval(id: number): void; export function clearInterval(id: number): void;
} }

View File

@ -68,7 +68,7 @@ export function setTimeout(callback: Function, milliseconds = 0): number {
} }
export function clearTimeout(id: number): void { export function clearTimeout(id: number): void {
let pair = timeoutCallbacks.get(id); let pair = timeoutCallbacks.get(<number><any>id);
if (pair) { if (pair) {
pair.v.unregister(); pair.v.unregister();
} }
@ -78,4 +78,4 @@ export function setInterval(callback: Function, milliseconds = 0): number {
return createTimerAndGetId(zonedCallback(callback), milliseconds, true); return createTimerAndGetId(zonedCallback(callback), milliseconds, true);
} }
export var clearInterval = clearTimeout; export var clearInterval = clearTimeout;

View File

@ -1,101 +0,0 @@
/// <reference path="application-settings/application-settings.d.ts" />
/// <reference path="application/application.d.ts" />
/// <reference path="camera/camera.d.ts" />
/// <reference path="color/color.d.ts" />
/// <reference path="color/known-colors.d.ts" />
/// <reference path="connectivity/connectivity.d.ts" />
/// <reference path="console/console.d.ts" />
/// <reference path="css-value/reworkcss-value.d.ts" />
/// <reference path="css/reworkcss.d.ts" />
/// <reference path="data/observable-array/observable-array.d.ts" />
/// <reference path="data/observable/observable.d.ts" />
/// <reference path="data/virtual-array/virtual-array.d.ts" />
/// <reference path="declarations.d.ts" />
/// <reference path="file-system/file-name-resolver.d.ts" />
/// <reference path="file-system/file-system-access.d.ts" />
/// <reference path="file-system/file-system.d.ts" />
/// <reference path="fps-meter/fps-meter.d.ts" />
/// <reference path="fps-meter/fps-native.d.ts" />
/// <reference path="http/http-request.d.ts" />
/// <reference path="http/http.d.ts" />
/// <reference path="image-asset/image-asset.d.ts" />
/// <reference path="image-source/image-source.d.ts" />
/// <reference path="js-libs/easysax/easysax.d.ts" />
/// <reference path="js-libs/esprima/esprima.d.ts" />
/// <reference path="js-libs/polymer-expressions/polymer-expressions.d.ts" />
/// <reference path="location/location.d.ts" />
/// <reference path="platform/platform.d.ts" />
/// <reference path="text/formatted-string.d.ts" />
/// <reference path="text/span.d.ts" />
/// <reference path="text/text.d.ts" />
/// <reference path="timer/timer.d.ts" />
/// <reference path="trace/trace.d.ts" />
/// <reference path="ui/definitions.d.ts" />
/// <reference path="ui/action-bar/action-bar.d.ts" />
/// <reference path="ui/activity-indicator/activity-indicator.d.ts" />
/// <reference path="ui/animation/animation.d.ts" />
/// <reference path="ui/animation/keyframe-animation.d.ts" />
/// <reference path="ui/border/border.d.ts" />
/// <reference path="ui/builder/binding-builder.d.ts" />
/// <reference path="ui/builder/builder.d.ts" />
/// <reference path="ui/builder/component-builder.d.ts" />
/// <reference path="ui/builder/special-properties.d.ts" />
/// <reference path="ui/button/button.d.ts" />
/// <reference path="ui/content-view/content-view.d.ts" />
/// <reference path="ui/core/bindable.d.ts" />
/// <reference path="ui/core/control-state-change.d.ts" />
/// <reference path="ui/core/dependency-observable.d.ts" />
/// <reference path="ui/core/view.d.ts" />
/// <reference path="ui/core/weak-event-listener.d.ts" />
/// <reference path="ui/date-picker/date-picker.d.ts" />
/// <reference path="ui/dialogs/dialogs.d.ts" />
/// <reference path="ui/editable-text-base/editable-text-base.d.ts" />
/// <reference path="ui/enums/enums.d.ts" />
/// <reference path="ui/frame/frame.d.ts" />
/// <reference path="ui/gestures/gestures.d.ts" />
/// <reference path="ui/html-view/html-view.d.ts" />
/// <reference path="ui/image-cache/image-cache.d.ts" />
/// <reference path="ui/image/image.d.ts" />
/// <reference path="ui/label/label.d.ts" />
/// <reference path="ui/layouts/absolute-layout/absolute-layout.d.ts" />
/// <reference path="ui/layouts/dock-layout/dock-layout.d.ts" />
/// <reference path="ui/layouts/grid-layout/grid-layout.d.ts" />
/// <reference path="ui/layouts/flexbox-layout/flexbox-layout.d.ts" />
/// <reference path="ui/layouts/layout-base.d.ts" />
/// <reference path="ui/layouts/layout.d.ts" />
/// <reference path="ui/layouts/stack-layout/stack-layout.d.ts" />
/// <reference path="ui/layouts/wrap-layout/wrap-layout.d.ts" />
/// <reference path="ui/list-picker/list-picker.d.ts" />
/// <reference path="ui/list-view/list-view.d.ts" />
/// <reference path="ui/page/page.d.ts" />
/// <reference path="ui/placeholder/placeholder.d.ts" />
/// <reference path="ui/progress/progress.d.ts" />
/// <reference path="ui/proxy-view-container/proxy-view-container.d.ts" />
/// <reference path="ui/repeater/repeater.d.ts" />
/// <reference path="ui/scroll-view/scroll-view.d.ts" />
/// <reference path="ui/search-bar/search-bar.d.ts" />
/// <reference path="ui/segmented-bar/segmented-bar.d.ts" />
/// <reference path="ui/slider/slider.d.ts" />
/// <reference path="ui/styling/background.d.ts" />
/// <reference path="ui/styling/css-selector.d.ts" />
/// <reference path="ui/styling/font.d.ts" />
/// <reference path="ui/styling/style-property.d.ts" />
/// <reference path="ui/styling/style-scope.d.ts" />
/// <reference path="ui/styling/style.d.ts" />
/// <reference path="ui/styling/styling.d.ts" />
/// <reference path="ui/switch/switch.d.ts" />
/// <reference path="ui/tab-view/tab-view.d.ts" />
/// <reference path="ui/text-base/text-base.d.ts" />
/// <reference path="ui/text-field/text-field.d.ts" />
/// <reference path="ui/text-view/text-view.d.ts" />
/// <reference path="ui/time-picker/time-picker.d.ts" />
/// <reference path="ui/transition/fade-transition.d.ts" />
/// <reference path="ui/transition/slide-transition.d.ts" />
/// <reference path="ui/transition/transition.d.ts" />
/// <reference path="ui/utils.d.ts" />
/// <reference path="ui/web-view/web-view.d.ts" />
/// <reference path="utils/debug.d.ts" />
/// <reference path="utils/lazy.d.ts" />
/// <reference path="utils/types.d.ts" />
/// <reference path="utils/utils.d.ts" />
/// <reference path="xml/xml.d.ts" />

View File

@ -1,2 +1,101 @@
/// <reference path="module.d.ts" /> /// <reference path="module.d.ts" />
/// <reference path="tns-core-modules.base.d.ts" /> /// <reference path="application-settings/application-settings.d.ts" />
/// <reference path="application/application.d.ts" />
/// <reference path="camera/camera.d.ts" />
/// <reference path="color/color.d.ts" />
/// <reference path="color/known-colors.d.ts" />
/// <reference path="connectivity/connectivity.d.ts" />
/// <reference path="css-value/reworkcss-value.d.ts" />
/// <reference path="css/reworkcss.d.ts" />
/// <reference path="data/observable-array/observable-array.d.ts" />
/// <reference path="data/observable/observable.d.ts" />
/// <reference path="data/virtual-array/virtual-array.d.ts" />
/// <reference path="declarations.d.ts" />
/// <reference path="file-system/file-name-resolver.d.ts" />
/// <reference path="file-system/file-system-access.d.ts" />
/// <reference path="file-system/file-system.d.ts" />
/// <reference path="fps-meter/fps-meter.d.ts" />
/// <reference path="fps-meter/fps-native.d.ts" />
/// <reference path="http/http-request.d.ts" />
/// <reference path="http/http.d.ts" />
/// <reference path="image-asset/image-asset.d.ts" />
/// <reference path="image-source/image-source.d.ts" />
/// <reference path="js-libs/easysax/easysax.d.ts" />
/// <reference path="js-libs/esprima/esprima.d.ts" />
/// <reference path="js-libs/polymer-expressions/polymer-expressions.d.ts" />
/// <reference path="location/location.d.ts" />
/// <reference path="platform/platform.d.ts" />
/// <reference path="text/formatted-string.d.ts" />
/// <reference path="text/span.d.ts" />
/// <reference path="text/text.d.ts" />
/// <reference path="timer/timer.d.ts" />
/// <reference path="trace/trace.d.ts" />
/// <reference path="ui/definitions.d.ts" />
/// <reference path="ui/action-bar/action-bar.d.ts" />
/// <reference path="ui/activity-indicator/activity-indicator.d.ts" />
/// <reference path="ui/animation/animation.d.ts" />
/// <reference path="ui/animation/keyframe-animation.d.ts" />
/// <reference path="ui/border/border.d.ts" />
/// <reference path="ui/builder/binding-builder.d.ts" />
/// <reference path="ui/builder/builder.d.ts" />
/// <reference path="ui/builder/component-builder.d.ts" />
/// <reference path="ui/builder/special-properties.d.ts" />
/// <reference path="ui/button/button.d.ts" />
/// <reference path="ui/content-view/content-view.d.ts" />
/// <reference path="ui/core/bindable.d.ts" />
/// <reference path="ui/core/control-state-change.d.ts" />
/// <reference path="ui/core/dependency-observable.d.ts" />
/// <reference path="ui/core/view.d.ts" />
/// <reference path="ui/core/weak-event-listener.d.ts" />
/// <reference path="ui/date-picker/date-picker.d.ts" />
/// <reference path="ui/dialogs/dialogs.d.ts" />
/// <reference path="ui/editable-text-base/editable-text-base.d.ts" />
/// <reference path="ui/enums/enums.d.ts" />
/// <reference path="ui/frame/frame.d.ts" />
/// <reference path="ui/gestures/gestures.d.ts" />
/// <reference path="ui/html-view/html-view.d.ts" />
/// <reference path="ui/image-cache/image-cache.d.ts" />
/// <reference path="ui/image/image.d.ts" />
/// <reference path="ui/label/label.d.ts" />
/// <reference path="ui/layouts/absolute-layout/absolute-layout.d.ts" />
/// <reference path="ui/layouts/dock-layout/dock-layout.d.ts" />
/// <reference path="ui/layouts/grid-layout/grid-layout.d.ts" />
/// <reference path="ui/layouts/flexbox-layout/flexbox-layout.d.ts" />
/// <reference path="ui/layouts/layout-base.d.ts" />
/// <reference path="ui/layouts/layout.d.ts" />
/// <reference path="ui/layouts/stack-layout/stack-layout.d.ts" />
/// <reference path="ui/layouts/wrap-layout/wrap-layout.d.ts" />
/// <reference path="ui/list-picker/list-picker.d.ts" />
/// <reference path="ui/list-view/list-view.d.ts" />
/// <reference path="ui/page/page.d.ts" />
/// <reference path="ui/placeholder/placeholder.d.ts" />
/// <reference path="ui/progress/progress.d.ts" />
/// <reference path="ui/proxy-view-container/proxy-view-container.d.ts" />
/// <reference path="ui/repeater/repeater.d.ts" />
/// <reference path="ui/scroll-view/scroll-view.d.ts" />
/// <reference path="ui/search-bar/search-bar.d.ts" />
/// <reference path="ui/segmented-bar/segmented-bar.d.ts" />
/// <reference path="ui/slider/slider.d.ts" />
/// <reference path="ui/styling/background.d.ts" />
/// <reference path="ui/styling/css-selector.d.ts" />
/// <reference path="ui/styling/font.d.ts" />
/// <reference path="ui/styling/style-property.d.ts" />
/// <reference path="ui/styling/style-scope.d.ts" />
/// <reference path="ui/styling/style.d.ts" />
/// <reference path="ui/styling/styling.d.ts" />
/// <reference path="ui/switch/switch.d.ts" />
/// <reference path="ui/tab-view/tab-view.d.ts" />
/// <reference path="ui/text-base/text-base.d.ts" />
/// <reference path="ui/text-field/text-field.d.ts" />
/// <reference path="ui/text-view/text-view.d.ts" />
/// <reference path="ui/time-picker/time-picker.d.ts" />
/// <reference path="ui/transition/fade-transition.d.ts" />
/// <reference path="ui/transition/slide-transition.d.ts" />
/// <reference path="ui/transition/transition.d.ts" />
/// <reference path="ui/utils.d.ts" />
/// <reference path="ui/web-view/web-view.d.ts" />
/// <reference path="utils/debug.d.ts" />
/// <reference path="utils/lazy.d.ts" />
/// <reference path="utils/types.d.ts" />
/// <reference path="utils/utils.d.ts" />
/// <reference path="xml/xml.d.ts" />

View File

@ -1,4 +0,0 @@
/// <reference path="./tns-core-modules.base.d.ts" />
/// <reference path="./module.d.ts" />
// Use this .d.ts with TypeScript 2+ and compiler options "lib": ["es2016", "dom"]

View File

@ -1,2 +0,0 @@
/// <reference path="module.d.ts" />
/// <reference path="tns-core-modules.base.d.ts" />

View File

@ -47,7 +47,7 @@ class AnimationDelegateImpl extends NSObject implements CAAnimationDelegate {
public nextAnimation: Function; public nextAnimation: Function;
// The CAAnimationDelegate protocol has been introduced in the iOS 10 SDK // The CAAnimationDelegate protocol has been introduced in the iOS 10 SDK
static ObjCProtocols = global.CAAnimationDelegate ? [global.CAAnimationDelegate] : []; static ObjCProtocols = (<any>global).CAAnimationDelegate ? [(<any>global).CAAnimationDelegate] : [];
private _finishedCallback: Function; private _finishedCallback: Function;
private _propertyAnimation: PropertyAnimationInfo; private _propertyAnimation: PropertyAnimationInfo;
@ -598,4 +598,4 @@ export function _getTransformMismatchErrorMessage(view: View): string {
} }
return undefined; return undefined;
} }

View File

@ -56,7 +56,7 @@ class TextWatcher extends java.lang.Object implements android.text.TextWatcher {
} }
//https://github.com/NativeScript/NativeScript/issues/2942 //https://github.com/NativeScript/NativeScript/issues/2942
let dismissKeyboardTimeoutId: number; let dismissKeyboardTimeoutId: any;
@Interfaces([android.view.View.OnFocusChangeListener]) @Interfaces([android.view.View.OnFocusChangeListener])
class FocusChangeListener extends java.lang.Object implements android.view.View.OnFocusChangeListener { class FocusChangeListener extends java.lang.Object implements android.view.View.OnFocusChangeListener {
@ -436,4 +436,4 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
this._android.setHintTextColor(value); this._android.setHintTextColor(value);
} }
} }
} }

View File

@ -84,7 +84,7 @@ function _generateAmpMap(): any {
} }
// android-specific implementation, which pre-populates the map to get it saved into the heap blob // android-specific implementation, which pre-populates the map to get it saved into the heap blob
if (global.__snapshot) { if ((<any>global).__snapshot) {
_ampCodes = _generateAmpMap(); _ampCodes = _generateAmpMap();
} }