diff --git a/package.json b/package.json index 5b280bb33..d2a5a8edb 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "tslint": "^4.4.2", "typedoc": "^0.5.10", "typedoc-plugin-external-module-name": "git://github.com/PanayotCankov/typedoc-plugin-external-module-name.git#with-js", - "typescript": "~2.2.1" + "typescript": "^2.4.1" }, "scripts": { "setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps", diff --git a/tests/app/TKUnit.ts b/tests/app/TKUnit.ts index bbe2457a8..a8b14b2ba 100644 --- a/tests/app/TKUnit.ts +++ b/tests/app/TKUnit.ts @@ -214,7 +214,7 @@ export function assertNotEqual(actual: any, expected: any, message?: string) { } } -export function assertEqual(actual: T, expected: T, message: string = '') { +export function assertEqual(actual: T, expected: T, message: string = '') { if (!types.isNullOrUndefined(actual) && !types.isNullOrUndefined(expected) && types.getClass(actual) === types.getClass(expected) diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts index ce0731f4f..5dd1f8433 100644 --- a/tns-core-modules/application/application.android.ts +++ b/tns-core-modules/application/application.android.ts @@ -1,6 +1,7 @@ import { AndroidActivityBundleEventData, AndroidActivityEventData, ApplicationEventData, OrientationChangedEventData, - AndroidApplication as AndroidApplicationDefinition + AndroidApplication as AndroidApplicationDefinition, + AndroidActivityResultEventData, AndroidActivityBackPressedEventData, AndroidActivityRequestPermissionsEventData } from "."; import { @@ -102,6 +103,19 @@ export class AndroidApplication extends Observable implements AndroidApplication } } } +export interface AndroidApplication { + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityResumed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "activityStopped", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: "saveActivityState", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + on(event: "activityResult", callback: (args: AndroidActivityResultEventData) => void, thisArg?: any); + on(event: "activityBackPressed", callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any); + on(event: "activityRequestPermissions", callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any); +} const androidApp = new AndroidApplication(); // use the exports object instead of 'export var' due to global namespace collision diff --git a/tns-core-modules/data/observable-array/observable-array.ts b/tns-core-modules/data/observable-array/observable-array.ts index ac2a16b93..6b3c28034 100644 --- a/tns-core-modules/data/observable-array/observable-array.ts +++ b/tns-core-modules/data/observable-array/observable-array.ts @@ -324,3 +324,7 @@ export class ObservableArray extends observable.Observable implements observa return this._array.reduceRight(callbackfn, initialValue); } } +export interface ObservableArray { + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + on(event: "change", callback: (args: observableArrayDef.ChangedData) => void, thisArg?: any); +} \ No newline at end of file diff --git a/tns-core-modules/data/virtual-array/virtual-array.ts b/tns-core-modules/data/virtual-array/virtual-array.ts index ab84307bf..67a4c8da0 100644 --- a/tns-core-modules/data/virtual-array/virtual-array.ts +++ b/tns-core-modules/data/virtual-array/virtual-array.ts @@ -1,4 +1,4 @@ -import { Observable } from "../observable"; +import { Observable, EventData } from "../observable"; import * as virtualArrayDef from "."; const CHANGE = "change"; @@ -158,3 +158,8 @@ export class VirtualArray extends Observable implements virtualArrayDef.Virtu } } } +export interface VirtualArray { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "itemsLoading", callback: (args: virtualArrayDef.ItemsLoading) => void, thisArg?: any); + on(event: "change", callback: (args: virtualArrayDef.ChangedData) => void, thisArg?: any); +} diff --git a/tns-core-modules/globals/globals.ts b/tns-core-modules/globals/globals.ts index d4b5ed6f9..6e8416a12 100644 --- a/tns-core-modules/globals/globals.ts +++ b/tns-core-modules/globals/globals.ts @@ -23,7 +23,7 @@ global.moduleMerge = function (sourceExports: any, destExports: any) { import * as timerModule from "../timer"; import * as dialogsModule from "../ui/dialogs"; -type ModuleLoader = () => any; +type ModuleLoader = (name?: string) => any; const modules: Map = new Map(); global.registerModule = function(name: string, loader: ModuleLoader): void { diff --git a/tns-core-modules/image-source/image-source.android.ts b/tns-core-modules/image-source/image-source.android.ts index 0b7c3ec64..7fb8029a8 100644 --- a/tns-core-modules/image-source/image-source.android.ts +++ b/tns-core-modules/image-source/image-source.android.ts @@ -242,7 +242,7 @@ export function fromNativeSource(source: any): ImageSource { return image.setNativeSource(source) ? image : null; } -export function fromUrl(url: string): Promise { +export function fromUrl(url: string): Promise { ensureHttp(); return http.getImage(url); } diff --git a/tns-core-modules/profiling/profiling.ts b/tns-core-modules/profiling/profiling.ts index 5a49fa1aa..c1daaa488 100644 --- a/tns-core-modules/profiling/profiling.ts +++ b/tns-core-modules/profiling/profiling.ts @@ -161,7 +161,7 @@ const profileMethodUnnamed = (target, key, descriptor) => { } function profileMethodNamed(name: string): MethodDecorator { - return (target, key, descriptor) => { + return (target, key, descriptor: PropertyDescriptor) => { // save a reference to the original method this way we keep the values currently in the // descriptor and don't overwrite what another decorator might have done to the descriptor. diff --git a/tns-core-modules/ui/core/properties/properties.d.ts b/tns-core-modules/ui/core/properties/properties.d.ts index 8e8dabed3..2203721a8 100644 --- a/tns-core-modules/ui/core/properties/properties.d.ts +++ b/tns-core-modules/ui/core/properties/properties.d.ts @@ -45,7 +45,7 @@ export interface CssAnimationPropertyOptions { readonly valueConverter?: (value: string) => U; } -export class Property implements TypedPropertyDescriptor { +export class Property { constructor(options: PropertyOptions); public readonly getDefault: symbol; @@ -55,12 +55,16 @@ export class Property implements TypedPropertyDescriptor< public nativeValueChange(T, U): void; public isSet(instance: T): boolean; } +export interface Property extends TypedPropertyDescriptor { +} -export class CoercibleProperty extends Property implements TypedPropertyDescriptor { +export class CoercibleProperty extends Property { constructor(options: CoerciblePropertyOptions); public readonly coerce: (target: T) => void; } +export interface CoercibleProperty extends TypedPropertyDescriptor { +} export class InheritedProperty extends Property { constructor(options: PropertyOptions); diff --git a/tns-core-modules/ui/dialogs/dialogs.d.ts b/tns-core-modules/ui/dialogs/dialogs.d.ts index 4d58c8252..f9a96d660 100644 --- a/tns-core-modules/ui/dialogs/dialogs.d.ts +++ b/tns-core-modules/ui/dialogs/dialogs.d.ts @@ -27,7 +27,7 @@ export module inputType { * The alert() method displays an alert box with a specified message. * @param message Specifies the text to display in the alert box. */ -export function alert(message: string): Promise; +export function alert(message: string | number | boolean): Promise; /** * The alert() method displays an alert box with a specified message. diff --git a/tns-core-modules/ui/image-cache/image-cache-common.ts b/tns-core-modules/ui/image-cache/image-cache-common.ts index e5feaf70f..b505a390d 100644 --- a/tns-core-modules/ui/image-cache/image-cache-common.ts +++ b/tns-core-modules/ui/image-cache/image-cache-common.ts @@ -184,3 +184,7 @@ export class Cache extends observable.Observable implements definition.Cache { this._download(request); } } +export interface Cache { + on(eventNames: string, callback: (args: observable.EventData) => void , thisArg?: any); + on(event: "downloaded", callback: (args: definition.DownloadedData) => void , thisArg?: any); +} \ No newline at end of file diff --git a/tns-core-modules/ui/list-view/list-view-common.ts b/tns-core-modules/ui/list-view/list-view-common.ts index 89856b5e6..66b45d035 100644 --- a/tns-core-modules/ui/list-view/list-view-common.ts +++ b/tns-core-modules/ui/list-view/list-view-common.ts @@ -1,5 +1,5 @@ -import { ListView as ListViewDefinition, ItemsSource } from "."; -import { CoercibleProperty, CssProperty, Style, View, Template, KeyedTemplate, Length, Property, Color, Observable } from "../core/view"; +import { ListView as ListViewDefinition, ItemsSource, ItemEventData } from "."; +import { CoercibleProperty, CssProperty, Style, View, Template, KeyedTemplate, Length, Property, Color, Observable, EventData } from "../core/view"; import { parse, parseMultipleTemplates } from "../builder"; import { Label } from "../label"; import { ObservableArray, ChangedData } from "../../data/observable-array"; @@ -129,9 +129,15 @@ export abstract class ListViewBase extends View implements ListViewDefinition { rowHeightProperty.coerce(this); } } - ListViewBase.prototype.recycleNativeView = true; +export interface ListViewBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any); + on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any); + on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any); +} + /** * Represents the property backing the items property of each ListView instance. */ diff --git a/tns-core-modules/ui/page/page-common.ts b/tns-core-modules/ui/page/page-common.ts index c8bddc4d5..86fd8289f 100644 --- a/tns-core-modules/ui/page/page-common.ts +++ b/tns-core-modules/ui/page/page-common.ts @@ -1,7 +1,7 @@ import { Page as PageDefinition, NavigatedData, ShownModallyData } from "."; import { ContentView, View, eachDescendant, Property, CssProperty, Color, isIOS, - booleanConverter, resetCSSProperties, Style + booleanConverter, resetCSSProperties, Style, EventData } from "../content-view"; import { Frame, topmost as topmostFrame, resolvePageFromEntry } from "../frame"; import { ActionBar } from "../action-bar"; @@ -297,6 +297,15 @@ export class PageBase extends ContentView implements PageDefinition { eachDescendant(this, resetCssValuesFunc); } } +export interface PageBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void; + on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any): void; + on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; + on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any): void; + on(event: "showingModally", callback: (args: ShownModallyData) => void, thisArg?: any): void; + on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any); +} /** * Dependency property used to hide the Navigation Bar in iOS and the Action Bar in Android. diff --git a/tns-core-modules/ui/placeholder/placeholder.android.ts b/tns-core-modules/ui/placeholder/placeholder.android.ts index f3a79c7ac..c3fe38543 100644 --- a/tns-core-modules/ui/placeholder/placeholder.android.ts +++ b/tns-core-modules/ui/placeholder/placeholder.android.ts @@ -1,5 +1,5 @@ import { Placeholder as PlaceholderDefinition, CreateViewEventData } from "." -import { View } from "../core/view" +import { View, EventData } from "../core/view" export class Placeholder extends View implements PlaceholderDefinition { public static creatingViewEvent = "creatingView"; @@ -9,4 +9,8 @@ export class Placeholder extends View implements PlaceholderDefinition { this.notify(args); return args.view; } +} +export interface Placeholder { + on(eventNames: string, callback: (args: EventData) => void); + on(event: "creatingView", callback: (args: CreateViewEventData) => void); } \ No newline at end of file diff --git a/tns-core-modules/ui/placeholder/placeholder.ts b/tns-core-modules/ui/placeholder/placeholder.ts index b986756c8..271aab412 100644 --- a/tns-core-modules/ui/placeholder/placeholder.ts +++ b/tns-core-modules/ui/placeholder/placeholder.ts @@ -1,5 +1,5 @@ import { Placeholder as PlaceholderDefinition, CreateViewEventData } from "." -import { View } from "../core/view" +import { View, EventData } from "../core/view" export class Placeholder extends View implements PlaceholderDefinition { public static creatingViewEvent = "creatingView"; @@ -9,4 +9,8 @@ export class Placeholder extends View implements PlaceholderDefinition { this.notify(args); return args.view; } +} +export interface Placeholder { + on(eventNames: string, callback: (args: EventData) => void); + on(event: "creatingView", callback: (args: CreateViewEventData) => void); } \ No newline at end of file diff --git a/tns-core-modules/ui/scroll-view/scroll-view-common.ts b/tns-core-modules/ui/scroll-view/scroll-view-common.ts index f0dabf7ac..68109b2a4 100644 --- a/tns-core-modules/ui/scroll-view/scroll-view-common.ts +++ b/tns-core-modules/ui/scroll-view/scroll-view-common.ts @@ -1,5 +1,5 @@ -import { ScrollView as ScrollViewDefinition, Orientation } from "."; -import { ContentView, Property, makeParser, makeValidator } from "../content-view"; +import { ScrollView as ScrollViewDefinition, Orientation, ScrollEventData } from "."; +import { ContentView, Property, makeParser, makeValidator, EventData } from "../content-view"; import { profile } from "../../profiling"; export * from "../content-view"; @@ -81,6 +81,10 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe public abstract scrollToHorizontalOffset(value: number, animated: boolean); public abstract _onOrientationChanged(); } +export interface ScrollViewBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any); +} const converter = makeParser(makeValidator("horizontal", "vertical")); export const orientationProperty = new Property({ diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts index 4d6f2ab99..11eda4db0 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts @@ -1,7 +1,7 @@ import { SegmentedBar as SegmentedBarDefinition, SegmentedBarItem as SegmentedBarItemDefinition, SelectedIndexChangedEventData } from "."; import { ViewBase, View, AddChildFromBuilder, AddArrayFromBuilder, - Property, CoercibleProperty, InheritedCssProperty, Color, Style + Property, CoercibleProperty, InheritedCssProperty, Color, Style, EventData } from "../core/view"; export * from "../core/view"; @@ -89,6 +89,10 @@ export abstract class SegmentedBarBase extends View implements SegmentedBarDefin } } } +export interface SegmentedBarBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); +} SegmentedBarBase.prototype.recycleNativeView = true; diff --git a/tns-core-modules/ui/tab-view/tab-view-common.ts b/tns-core-modules/ui/tab-view/tab-view-common.ts index 92fbe988d..8b3a6750b 100644 --- a/tns-core-modules/ui/tab-view/tab-view-common.ts +++ b/tns-core-modules/ui/tab-view/tab-view-common.ts @@ -1,7 +1,7 @@ import { TabView as TabViewDefinition, TabViewItem as TabViewItemDefinition, SelectedIndexChangedEventData } from "."; import { View, ViewBase, Style, Property, CssProperty, CoercibleProperty, - Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder + Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData } from "../core/view"; export * from "../core/view"; @@ -182,6 +182,10 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom } } } +export interface TabViewBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); +} export const selectedIndexProperty = new CoercibleProperty({ name: "selectedIndex", defaultValue: -1, affectsLayout: isIOS, diff --git a/tns-core-modules/ui/web-view/web-view-common.ts b/tns-core-modules/ui/web-view/web-view-common.ts index 9931ac45b..24a04e61b 100644 --- a/tns-core-modules/ui/web-view/web-view-common.ts +++ b/tns-core-modules/ui/web-view/web-view-common.ts @@ -1,5 +1,5 @@ import { WebView as WebViewDefinition, LoadEventData, NavigationType } from "."; -import { View, Property } from "../core/view"; +import { View, Property, EventData } from "../core/view"; import { File, knownFolders, path } from "../../file-system"; export { File, knownFolders, path, NavigationType }; @@ -92,5 +92,10 @@ export abstract class WebViewBase extends View implements WebViewDefinition { throw new Error("Property url of WebView is deprecated. Use src instead") } } +export interface WebViewBase { + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any); + on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any); +} srcProperty.register(WebViewBase); diff --git a/tns-platform-declarations/android/android17.d.ts b/tns-platform-declarations/android/android17.d.ts index 66224c830..b9c94883c 100644 --- a/tns-platform-declarations/android/android17.d.ts +++ b/tns-platform-declarations/android/android17.d.ts @@ -107930,7 +107930,6 @@ declare module javax { glQueryMatrixxOES(mantissa: java.nio.IntBuffer, exponent: java.nio.IntBuffer): number; } interface IGL { - __javax_microedition_khronos_opengles_IGL?: any; } } export module egl { @@ -107939,7 +107938,6 @@ declare module javax { static class: java.lang.Class; } interface IEGL { - __javax_microedition_khronos_egl_IEGL?: any; } export class EGL10 implements javax.microedition.khronos.egl.IEGL, javax.microedition.khronos.egl.IEGL10 { constructor(implementation: javax.microedition.khronos.egl.IEGL10);