Fix TypeScript 1.8 compile errors. Get rid of "ui" imports.

This commit is contained in:
Hristo Deshev
2016-02-24 09:48:37 +02:00
parent c9eb4d5890
commit 32ff1f3cfc
17 changed files with 83 additions and 92 deletions

View File

@ -1,4 +1,4 @@
import {Page} from "ui"; import {Page} from "ui/page";
import {EventData as ObservableEventData} from "data/observable"; import {EventData as ObservableEventData} from "data/observable";
// Event handler for Page "navigatedTo" event attached in details-page.xml // Event handler for Page "navigatedTo" event attached in details-page.xml

View File

@ -1,5 +1,7 @@
import {EventData as ObservableEventData} from "data/observable"; import {EventData as ObservableEventData} from "data/observable";
import {Page, ItemEventData, topmost as topmostFrame, ItemEventData as ListViewItemEventData} from "ui"; import {Page} from "ui/page";
import {ItemEventData as ListViewItemEventData} from "ui/list-view";
import {topmost as topmostFrame} from "ui/frame";
import {AppViewModel} from "./reddit-app-view-model"; import {AppViewModel} from "./reddit-app-view-model";
var appViewModel = new AppViewModel(); var appViewModel = new AppViewModel();

View File

@ -1,7 +1,8 @@
import application = require("application"); import * as application from "application";
import navPageModule = require("../nav-page"); import {NavPage} from "../nav-page";
import {Page} from "ui/page";
import * as trace from "trace";
import trace = require("trace");
trace.enable(); trace.enable();
trace.setCategories(trace.categories.concat( trace.setCategories(trace.categories.concat(
trace.categories.NativeLifecycle, trace.categories.NativeLifecycle,
@ -11,8 +12,7 @@ trace.setCategories(trace.categories.concat(
)); ));
application.mainEntry = { application.mainEntry = {
create: function () { create: () => new NavPage({
return new navPageModule.NavPage({
index: 0, index: 0,
backStackVisible: true, backStackVisible: true,
clearHistory: false, clearHistory: false,
@ -20,9 +20,6 @@ application.mainEntry = {
transition: 0, transition: 0,
curve: 0, curve: 0,
duration: 0, duration: 0,
}); })
}
//backstackVisible: false,
//clearHistory: true
}; };
application.start(); application.start();

View File

@ -1,4 +1,5 @@
import {Page, ListPicker} from "ui"; import {Page} from "ui/page";
import {ListPicker} from "ui/list-picker";
var closeCallback: Function; var closeCallback: Function;
var page: Page; var page: Page;

View File

@ -1,7 +1,17 @@
import definition = require("controls-page"); import definition = require("controls-page");
import {View, Page, topmost as topmostFrame, NavigationTransition, Orientation, AnimationCurve, StackLayout, Button, Label, TextField, Switch, ListPicker, Slider} from "ui"; import {View} from "ui/core/view";
import {Page} from "ui/page";
import {topmost as topmostFrame, NavigationTransition} from "ui/frame";
import {Orientation, AnimationCurve} from "ui/enums";
import {StackLayout} from "ui/layouts/stack-layout";
import {Button} from "ui/button";
import {Label} from "ui/label";
import {TextField} from "ui/text-field";
import {Switch} from "ui/switch";
import {ListPicker} from "ui/list-picker";
import {Slider} from "ui/slider";
import {Color} from "color"; import {Color} from "color";
import platform = require("platform"); import * as platform from "platform";
var availableTransitions = ["default", "custom", "flip", "flipRight", "flipLeft", "slide", "slideLeft", "slideRight", "slideTop", "slideBottom", "fade"]; var availableTransitions = ["default", "custom", "flip", "flipRight", "flipLeft", "slide", "slideLeft", "slideRight", "slideTop", "slideBottom", "fade"];
if (platform.device.os === platform.platformNames.ios) { if (platform.device.os === platform.platformNames.ios) {

View File

@ -1,15 +1,12 @@
import TKUnit = require("../TKUnit"); import * as TKUnit from "../TKUnit";
import platform = require("platform"); import {Page} from "ui/page";
import {Frame, Page, topmost as topmostFrame, NavigationEntry, NavigationTransition, AnimationCurve, WrapLayout, Button} from "ui"; import {topmost as topmostFrame} from "ui/frame";
import color = require("color"); import {Color} from "color";
import helper = require("../ui/helper");
import utils = require("utils/utils");
import trace = require("trace");
// Creates a random colorful page full of meaningless stuff. // Creates a random colorful page full of meaningless stuff.
var pageFactory = function(): Page { var pageFactory = function(): Page {
var page = new Page(); var page = new Page();
page.style.backgroundColor = new color.Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255)); page.style.backgroundColor = new Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255));
return page; return page;
}; };

View File

@ -1,11 +1,12 @@
import TKUnit = require("../TKUnit"); import * as TKUnit from "../TKUnit";
import platform = require("platform"); import * as helper from "../ui/helper";
import transitionModule = require("ui/transition"); import * as platform from "platform";
import color = require("color"); import * as trace from "trace";
import helper = require("../ui/helper"); import {Color} from "color";
import utils = require("utils/utils"); import {GC} from "utils/utils";
import trace = require("trace"); import {NavigationEntry, NavigationTransition} from "ui/frame";
import {Frame, Page, topmost as topmostFrame, NavigationEntry, NavigationTransition, AnimationCurve, WrapLayout, Button} from "ui"; import {Page} from "ui/page";
import {AnimationCurve} from "ui/enums"
function _testTransition(navigationTransition: NavigationTransition) { function _testTransition(navigationTransition: NavigationTransition) {
var testId = `Transition[${JSON.stringify(navigationTransition)}]`; var testId = `Transition[${JSON.stringify(navigationTransition)}]`;
@ -14,7 +15,7 @@ function _testTransition(navigationTransition: NavigationTransition) {
create: function (): Page { create: function (): Page {
var page = new Page(); var page = new Page();
page.id = testId; page.id = testId;
page.style.backgroundColor = new color.Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255)); page.style.backgroundColor = new Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255));
return page; return page;
}, },
animated: true, animated: true,
@ -25,7 +26,7 @@ function _testTransition(navigationTransition: NavigationTransition) {
TKUnit.wait(0.100); TKUnit.wait(0.100);
helper.goBack(); helper.goBack();
TKUnit.wait(0.100); TKUnit.wait(0.100);
utils.GC(); GC();
} }
// Extremely slow. Run only if needed. // Extremely slow. Run only if needed.
@ -33,7 +34,7 @@ export var test_Transitions = function () {
helper.navigate(() => { helper.navigate(() => {
var page = new Page(); var page = new Page();
page.id = "TransitionsTestPage_MAIN" page.id = "TransitionsTestPage_MAIN"
page.style.backgroundColor = new color.Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255)); page.style.backgroundColor = new Color(255, Math.round(Math.random() * 255), Math.round(Math.random() * 255), Math.round(Math.random() * 255));
return page; return page;
}); });

View File

@ -27,16 +27,12 @@ export function getNativeTextAlignment(button: buttonModule.Button): string {
switch (button.ios.titleLabel.textAlignment) { switch (button.ios.titleLabel.textAlignment) {
case NSTextAlignment.NSTextAlignmentLeft: case NSTextAlignment.NSTextAlignmentLeft:
return enums.TextAlignment.left; return enums.TextAlignment.left;
break;
case NSTextAlignment.NSTextAlignmentCenter: case NSTextAlignment.NSTextAlignmentCenter:
return enums.TextAlignment.center; return enums.TextAlignment.center;
break;
case NSTextAlignment.NSTextAlignmentRight: case NSTextAlignment.NSTextAlignmentRight:
return enums.TextAlignment.right; return enums.TextAlignment.right;
break;
default: default:
return "unexpected value"; return "unexpected value";
break;
} }
} }

View File

@ -7,16 +7,12 @@ export function getNativeTextAlignment(label: labelModule.Label): string {
switch (label.ios.textAlignment) { switch (label.ios.textAlignment) {
case NSTextAlignment.NSTextAlignmentLeft: case NSTextAlignment.NSTextAlignmentLeft:
return enums.TextAlignment.left; return enums.TextAlignment.left;
break;
case NSTextAlignment.NSTextAlignmentCenter: case NSTextAlignment.NSTextAlignmentCenter:
return enums.TextAlignment.center; return enums.TextAlignment.center;
break;
case NSTextAlignment.NSTextAlignmentRight: case NSTextAlignment.NSTextAlignmentRight:
return enums.TextAlignment.right; return enums.TextAlignment.right;
break;
default: default:
return "unexpected value"; return "unexpected value";
break;
} }
} }

View File

@ -1,18 +1,20 @@
import TKUnit = require("../../TKUnit"); import * as TKUnit from "../../TKUnit";
import helper = require("../helper"); import * as helper from "../helper";
import viewModule = require("ui/core/view"); import {View} from "ui/core/view";
import observable = require("data/observable"); import {Button} from "ui/button";
import color = require("color"); import {Page} from "ui/page";
import platform = require("platform"); import {ScrollView} from "ui/scroll-view";
import {TabView, TabViewItem} from "ui/tab-view";
import {LayoutBase} from "ui/layouts/layout-base"
import {StackLayout} from "ui/layouts/stack-layout"
import {GridLayout} from "ui/layouts/grid-layout"
import {ProxyViewContainer} from "ui/proxy-view-container"; import {ProxyViewContainer} from "ui/proxy-view-container";
import {View, Button, LayoutBase, StackLayout, GridLayout, Page, ScrollView, TabView, TabViewItem} from "ui";
export function test_add_children_to_attached_proxy() { export function test_add_children_to_attached_proxy() {
var outer = new StackLayout(); var outer = new StackLayout();
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
outer.addChild(createBtn("1")); outer.addChild(createBtn("1"));
outer.addChild(proxy); outer.addChild(proxy);
proxy.addChild(createBtn("2")); proxy.addChild(createBtn("2"));
@ -31,7 +33,7 @@ export function test_children_immediately_registered_in_parent_grid_layout() {
var outer = new GridLayout(); var outer = new GridLayout();
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
outer.addChild(proxy); outer.addChild(proxy);
proxy.addChild(createBtn("1")); proxy.addChild(createBtn("1"));
@ -45,7 +47,7 @@ export function test_children_registered_in_parent_grid_layout_on_attach() {
var outer = new GridLayout(); var outer = new GridLayout();
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
proxy.addChild(createBtn("1")); proxy.addChild(createBtn("1"));
outer.addChild(proxy); outer.addChild(proxy);
@ -59,7 +61,7 @@ export function test_add_children_to_detached_proxy() {
var outer = new StackLayout(); var outer = new StackLayout();
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
outer.addChild(createBtn("1")); outer.addChild(createBtn("1"));
proxy.addChild(createBtn("2")); proxy.addChild(createBtn("2"));
@ -88,7 +90,7 @@ export function test_remove_proxy() {
outer.addChild(createBtn("5")); outer.addChild(createBtn("5"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]); assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
outer.removeChild(proxy); outer.removeChild(proxy);
assertNativeChildren(outer, ["1", "5"]); assertNativeChildren(outer, ["1", "5"]);
@ -111,7 +113,7 @@ export function test_remove_child_of_attached_proxy() {
outer.addChild(createBtn("5")); outer.addChild(createBtn("5"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]); assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
proxy.removeChild(testBtn); proxy.removeChild(testBtn);
assertNativeChildren(outer, ["1", "2", "4", "5"]); assertNativeChildren(outer, ["1", "2", "4", "5"]);
@ -132,7 +134,7 @@ export function test_insert_inside_porxy() {
outer.addChild(createBtn("5")); outer.addChild(createBtn("5"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
assertNativeChildren(outer, ["1", "2", "4", "5"]); assertNativeChildren(outer, ["1", "2", "4", "5"]);
proxy.insertChild(createBtn("3"), 1); proxy.insertChild(createBtn("3"), 1);
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]); assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
@ -152,7 +154,7 @@ export function test_insert_after_porxy() {
proxy.addChild(createBtn("3")); proxy.addChild(createBtn("3"));
proxy.addChild(createBtn("4")); proxy.addChild(createBtn("4"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
assertNativeChildren(outer, ["1", "2", "3", "4"]); assertNativeChildren(outer, ["1", "2", "3", "4"]);
outer.insertChild(createBtn("5"), 2); outer.insertChild(createBtn("5"), 2);
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]); assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
@ -170,7 +172,7 @@ export function test_proxy_does_not_stop_request_layout_bubble() {
var btn = createBtn("2"); var btn = createBtn("2");
proxy.addChild(btn); proxy.addChild(btn);
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
assertNativeChildren(outer, ["1", "2"]); assertNativeChildren(outer, ["1", "2"]);
waitUntilElementLayoutIsValid(outer); waitUntilElementLayoutIsValid(outer);
TKUnit.assert(outer.isLayoutValid, "outer container isLayoutValid should be true"); TKUnit.assert(outer.isLayoutValid, "outer container isLayoutValid should be true");
@ -185,7 +187,7 @@ export function test_proxy_iniside_page() {
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1")); proxy.addChild(createBtn("1"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
var page = <Page>views[1]; var page = <Page>views[1];
waitUntilElementLayoutIsValid(page); waitUntilElementLayoutIsValid(page);
}; };
@ -200,7 +202,7 @@ export function test_proxy_iniside_scroll_view() {
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1")); proxy.addChild(createBtn("1"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
var page = <Page>views[1]; var page = <Page>views[1];
waitUntilElementLayoutIsValid(page); waitUntilElementLayoutIsValid(page);
}; };
@ -215,7 +217,7 @@ export function test_proxy_iniside_border() {
var proxy = new ProxyViewContainer(); var proxy = new ProxyViewContainer();
proxy.addChild(createBtn("1")); proxy.addChild(createBtn("1"));
function testAction(views: Array<viewModule.View>) { function testAction(views: Array<View>) {
var page = <Page>views[1]; var page = <Page>views[1];
waitUntilElementLayoutIsValid(page); waitUntilElementLayoutIsValid(page);
}; };
@ -233,7 +235,7 @@ export function test_proxy_iniside_border() {
// items.push(new TabViewItem({ title: "tab with proxy", view: proxy })); // items.push(new TabViewItem({ title: "tab with proxy", view: proxy }));
// tab.items = items; // tab.items = items;
// function testAction(views: Array<viewModule.View>) { // function testAction(views: Array<View>) {
// var page = <Page>views[1]; // var page = <Page>views[1];
// waitUntilElementLayoutIsValid(page); // waitUntilElementLayoutIsValid(page);
// }; // };
@ -243,7 +245,7 @@ export function test_proxy_iniside_border() {
// TODO: Proxy as a direct child to of ActionBar is not supported. Not sure if we want to support it. // TODO: Proxy as a direct child to of ActionBar is not supported. Not sure if we want to support it.
//export function test_proxy_iniside_actionBar() { //export function test_proxy_iniside_actionBar() {
// function testAction(views: Array<viewModule.View>) { // function testAction(views: Array<View>) {
// var page = <Page>views[1]; // var page = <Page>views[1];
// var proxy = new ProxyViewContainer(); // var proxy = new ProxyViewContainer();
// proxy.addChild(createBtn("1")); // proxy.addChild(createBtn("1"));

View File

@ -67,8 +67,7 @@ var _clickHandlerFactory = function (index: number) {
} }
export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithAListViewTheListViewIsThere() { export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithAListViewTheListViewIsThere() {
return; /*
var topFrame = frameModule.topmost(); var topFrame = frameModule.topmost();
var oldChache; var oldChache;
@ -126,6 +125,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
var listView = mainPage.getViewById<ListView>("ListView"); var listView = mainPage.getViewById<ListView>("ListView");
TKUnit.assert(listView !== undefined, "ListView should be created when navigating back to the main page."); TKUnit.assert(listView !== undefined, "ListView should be created when navigating back to the main page.");
*/
} }
/* /*
export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack_NoPageCaching() { export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack_NoPageCaching() {

View File

@ -31,16 +31,12 @@ export function getNativeTextAlignment(textField: textFieldModule.TextField): st
switch (textField.ios.textAlignment) { switch (textField.ios.textAlignment) {
case NSTextAlignment.NSTextAlignmentLeft: case NSTextAlignment.NSTextAlignmentLeft:
return enums.TextAlignment.left; return enums.TextAlignment.left;
break;
case NSTextAlignment.NSTextAlignmentCenter: case NSTextAlignment.NSTextAlignmentCenter:
return enums.TextAlignment.center; return enums.TextAlignment.center;
break;
case NSTextAlignment.NSTextAlignmentRight: case NSTextAlignment.NSTextAlignmentRight:
return enums.TextAlignment.right; return enums.TextAlignment.right;
break;
default: default:
return "unexpected value"; return "unexpected value";
break;
} }
} }

View File

@ -36,16 +36,12 @@ export function getNativeTextAlignment(textView: textViewModule.TextView): strin
switch (textView.ios.textAlignment) { switch (textView.ios.textAlignment) {
case NSTextAlignment.NSTextAlignmentLeft: case NSTextAlignment.NSTextAlignmentLeft:
return enums.TextAlignment.left; return enums.TextAlignment.left;
break;
case NSTextAlignment.NSTextAlignmentCenter: case NSTextAlignment.NSTextAlignmentCenter:
return enums.TextAlignment.center; return enums.TextAlignment.center;
break;
case NSTextAlignment.NSTextAlignmentRight: case NSTextAlignment.NSTextAlignmentRight:
return enums.TextAlignment.right; return enums.TextAlignment.right;
break;
default: default:
return "unexpected value"; return "unexpected value";
break;
} }
} }

View File

@ -1,4 +1,6 @@
import { Page, View, TextView } from "ui"; import {View} from "ui/core/view";
import {Page} from "ui/page";
import {TextView} from "ui/text-view";
import gestures = require("ui/gestures"); import gestures = require("ui/gestures");
export function onTouch(args: gestures.TouchGestureEventData) { export function onTouch(args: gestures.TouchGestureEventData) {

View File

@ -264,7 +264,6 @@ export class Animation extends common.Animation implements definition.Animation
default: default:
throw new Error("Cannot animate " + propertyAnimation.property); throw new Error("Cannot animate " + propertyAnimation.property);
break;
} }
var i = 0; var i = 0;

View File

@ -57,7 +57,6 @@ export class EditableTextBase extends common.EditableTextBase {
break; break;
default: default:
throw new Error("Invalid updateTextTrigger: " + owner.updateTextTrigger); throw new Error("Invalid updateTextTrigger: " + owner.updateTextTrigger);
break;
} }
} }
}); });

View File

@ -228,7 +228,6 @@ class CssCompositeSelector extends CssSelector {
} }
if (!result) { if (!result) {
break; break;
return result;
} }
} }
return result; return result;
@ -282,11 +281,9 @@ function matchesAttr(attrExpression: string, view: view.View): boolean {
break; break;
} }
return !types.isNullOrUndefined(view[attrName]) && attrCheckRegex.test(view[attrName]+""); return !types.isNullOrUndefined(view[attrName]) && attrCheckRegex.test(view[attrName]+"");
} } else {
else {
return !types.isNullOrUndefined(view[attrExpression]); return !types.isNullOrUndefined(view[attrExpression]);
} }
return false;
} }
export class CssVisualStateSelector extends CssSelector { export class CssVisualStateSelector extends CssSelector {