feat(core): TypeScript 4 + cleanup (#8967)

This commit is contained in:
Nathan Walker
2020-10-19 09:28:05 -07:00
committed by GitHub
parent 99bb067420
commit 2243660080
266 changed files with 677 additions and 1014 deletions

View File

@ -1,5 +1,6 @@
dist
*.js
!jest.config.js
*.map
!xml/xml.js
!js-libs/**/*.*

View File

@ -3,4 +3,5 @@ dist
*.tgz
**/*.ts
!**/*.d.ts
jest.config.js
npm-debug.log

View File

@ -504,3 +504,8 @@ declare namespace com {
}
}
}
// core exports this symbol so apps may import them in general
// technically they are only available for use when running that platform
// helps avoid a webpack nonexistent warning
export const iOSApplication = undefined;

View File

@ -528,3 +528,8 @@ global.__onLiveSync = function __onLiveSync(context?: ModuleContext) {
const rootView = getRootView();
livesync(rootView, context);
};
// core exports this symbol so apps may import them in general
// technically they are only available for use when running that platform
// helps avoid a webpack nonexistent warning
export const AndroidApplication = undefined;

View File

@ -15,6 +15,7 @@ export class ImageAsset extends ImageAssetBase {
this.android = fileName;
}
// @ts-ignore
get android(): string {
return this._android;
}

View File

@ -21,6 +21,7 @@ export class ImageAsset extends ImageAssetBase {
}
}
// @ts-ignore
get ios(): PHAsset {
return this._ios;
}

View File

@ -0,0 +1,4 @@
module.exports = {
preset: '../../jest.preset.js',
displayName: 'core',
};

View File

@ -31,7 +31,7 @@
"css-tree": "^1.0.0-alpha.39",
"@nativescript/hook": "~2.0.0",
"reduce-css-calc": "^2.1.7",
"tslib": "2.0.0"
"tslib": "~2.0.0"
},
"nativescript": {
"platforms": {

View File

@ -1,25 +1,27 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmitOnError": true,
"noEmitHelpers": true,
"declaration": true,
"noImplicitAny": false,
"noImplicitUseStrict": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"diagnostics": true,
"sourceMap": true,
"inlineSourceMap": false,
"baseUrl": ".",
"outDir": "../../dist/out-tsc",
"rootDir": "./",
"types": ["node"],
"plugins": [
{ "transform": "../../../packages/webpack/transformers/ns-transform-native-classes.ts", "type": "raw" }
]
},
"exclude": ["**/*.spec.ts", "dist", "__tests__"],
"include": ["**/*.ts", "./references.d.ts"]
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmitOnError": true,
"noEmitHelpers": true,
"declaration": true,
"noImplicitAny": false,
"noImplicitUseStrict": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"diagnostics": true,
"sourceMap": true,
"inlineSourceMap": false,
"baseUrl": ".",
"outDir": "../../dist",
"types": ["node"],
"plugins": [
{
"transform": "../webpack/transformers/ns-transform-native-classes.ts",
"type": "raw"
}
]
},
"exclude": ["**/*.spec.ts", "dist", "__tests__"],
"include": ["**/*.ts", "./references.d.ts"]
}

View File

@ -102,10 +102,12 @@ export class ActionBarBase extends View implements ActionBarDefinition {
this.style.androidContentInsetRight = value;
}
// @ts-ignore
get ios(): any {
return undefined;
}
// @ts-ignore
get android(): AndroidActionBarSettings {
return undefined;
}
@ -262,7 +264,9 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition {
private _actionBar: ActionBarDefinition;
private _actionView: View;
// @ts-ignore
public ios: IOSActionItemSettings;
// @ts-ignore
public android: AndroidActionItemSettings;
public text: string;

View File

@ -96,6 +96,7 @@ export class ActionItem extends ActionItemBase {
this._itemId = generateItemId();
}
// @ts-ignore
public get android(): AndroidActionItemSettings {
return this._androidPosition;
}

View File

@ -64,6 +64,7 @@ export class ActionItem extends ActionItemBase {
systemIcon: undefined,
};
// @ts-ignore
public get ios(): IOSActionItemSettings {
return this._ios;
}

View File

@ -20,6 +20,7 @@ export class ActivityIndicator extends ActivityIndicatorBase {
return view;
}
// @ts-ignore
get ios(): UIActivityIndicatorView {
return this.nativeViewProtected;
}

View File

@ -316,6 +316,7 @@ export class BottomNavigation extends TabNavigationBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): UITabBarController {
return this._ios;
}

View File

@ -33,6 +33,7 @@ export class Button extends ButtonBase {
super.disposeNativeView();
}
// @ts-ignore
get ios() {
return this.nativeViewProtected;
}

View File

@ -33,6 +33,7 @@ export class DatePicker extends DatePickerBase {
super.disposeNativeView();
}
// @ts-ignore
get ios(): UIDatePicker {
return this.nativeViewProtected;
}

View File

@ -130,6 +130,7 @@ export class Frame extends FrameBase {
return this._containerViewId;
}
// @ts-ignore
get android(): AndroidFrame {
return this._android;
}

View File

@ -46,6 +46,7 @@ export class Frame extends FrameBase {
super.disposeNativeView();
}
// @ts-ignore
public get ios(): iOSFrame {
return this._ios;
}

View File

@ -32,6 +32,7 @@ export class HtmlView extends HtmlViewBase {
this.nativeViewProtected.textContainerInset = (UIEdgeInsets as any).zero;
}
// @ts-ignore
get ios(): UITextView {
return this.nativeViewProtected;
}

View File

@ -1,6 +1,7 @@
export { ActionBar, ActionItem, ActionItems, NavigationButton } from './action-bar';
export { ActivityIndicator } from './activity-indicator';
export { Animation, AnimationDefinition, KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation';
export { Animation, KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation';
export type { AnimationDefinition } from './animation';
export { BottomNavigation } from './bottom-navigation';
export type { SelectedIndexChangedEventData } from './bottom-navigation';
export { Builder } from './builder';
@ -45,7 +46,8 @@ export { ListView } from './list-view';
export type { ItemEventData, TemplatedItemsView, ItemsSource } from './list-view';
export { Page, PageBase } from './page';
export type { NavigatedData } from './page';
export { Placeholder, CreateViewEventData } from './placeholder';
export { Placeholder } from './placeholder';
export type { CreateViewEventData } from './placeholder';
export { Progress } from './progress';
export { ProxyViewContainer } from './proxy-view-container';
export { Repeater } from './repeater';

View File

@ -27,6 +27,7 @@ export class Label extends TextBase implements LabelDefinition {
return view;
}
// @ts-ignore
get ios(): TNSLabel {
return this.nativeTextViewProtected;
}

View File

@ -28,6 +28,7 @@ export class ListPicker extends ListPickerBase {
super.disposeNativeView();
}
// @ts-ignore
get ios() {
return this.nativeViewProtected;
}

View File

@ -291,6 +291,7 @@ export class ListView extends ListViewBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): UITableView {
return this.nativeViewProtected;
}

View File

@ -309,6 +309,7 @@ class UIViewControllerImpl extends UIViewController {
}
}
// @ts-ignore
public get preferredStatusBarStyle(): UIStatusBarStyle {
const owner = this._owner.get();
if (owner) {
@ -340,6 +341,7 @@ export class Page extends PageBase {
return this.viewController.view;
}
// @ts-ignore
get ios(): UIViewController {
return this._ios;
}

View File

@ -11,6 +11,7 @@ export class Progress extends ProgressBase {
return UIProgressView.new();
}
// @ts-ignore
get ios() {
return this.nativeViewProtected;
}

View File

@ -1,4 +1,3 @@
import { ProxyViewContainer as ProxyViewContainerDefinition } from '.';
import { View, CSSType } from '../core/view';
import { LayoutBase } from '../layouts/layout-base';
import { Property } from '../core/properties';
@ -14,7 +13,7 @@ import { Trace } from '../../trace';
// * Child is removed from attached proxy. Handled in _removeViewFromNativeVisualTree.
// * Proxy (with children) is removed form the DOM. In _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent.
@CSSType('ProxyViewContainer')
export class ProxyViewContainer extends LayoutBase implements ProxyViewContainerDefinition {
export class ProxyViewContainer extends LayoutBase {
private proxiedLayoutProperties = new Set<string>();
constructor() {
@ -23,10 +22,12 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer
}
// No native view for proxy container.
// @ts-ignore
get ios(): any {
return null;
}
// @ts-ignore
get android(): any {
return null;
}

View File

@ -103,6 +103,7 @@ export class SearchBar extends SearchBarBase {
(<UIResponder>this.ios).resignFirstResponder();
}
// @ts-ignore
get ios(): UISearchBar {
return this.nativeViewProtected;
}

View File

@ -36,6 +36,7 @@ export class SegmentedBar extends SegmentedBarBase {
super.disposeNativeView();
}
// @ts-ignore
get ios(): UISegmentedControl {
return this.nativeViewProtected;
}

View File

@ -52,6 +52,7 @@ export class Slider extends SliderBase {
super.disposeNativeView();
}
// @ts-ignore
get ios(): UISlider {
return this.nativeViewProtected;
}

View File

@ -55,6 +55,7 @@ export class Switch extends SwitchBase {
super.disposeNativeView();
}
// @ts-ignore
get ios(): UISwitch {
return this.nativeViewProtected;
}

View File

@ -330,6 +330,7 @@ export class TabView extends TabViewBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): UITabBarController {
return this._ios;
}

View File

@ -466,6 +466,7 @@ export class Tabs extends TabsBase {
// public offscreenTabLimit: number;
// public tabsPosition: "top" | "bottom";
public _canSelectItem: boolean;
// @ts-ignore
public isLoaded: boolean;
public viewController: UIPageViewControllerImpl;
public items: TabContentItem[];
@ -530,6 +531,7 @@ export class Tabs extends TabsBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): UIPageViewController {
return this._ios;
}

View File

@ -164,6 +164,7 @@ function initializeBaselineAdjustedSpan(): void {
export class TextBase extends TextBaseCommon {
nativeViewProtected: android.widget.TextView;
// @ts-ignore
nativeTextViewProtected: android.widget.TextView;
private _defaultTransformationMethod: android.text.method.TransformationMethod;
private _paintFlags: number;

View File

@ -79,6 +79,7 @@ class UILabelClickHandlerImpl extends NSObject {
export class TextBase extends TextBaseCommon {
public nativeViewProtected: UITextField | UITextView | UILabel | UIButton;
// @ts-ignore
public nativeTextViewProtected: UITextField | UITextView | UILabel | UIButton;
private _tappable: boolean = false;
private _tapGestureRecognizer: UITapGestureRecognizer;

View File

@ -145,6 +145,7 @@ export class TextField extends TextFieldBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): UITextField {
return this.nativeViewProtected;
}

View File

@ -123,6 +123,7 @@ export class TextView extends TextViewBaseCommon {
super.onUnloaded();
}
// @ts-ignore
get ios(): UITextView {
return this.nativeViewProtected;
}

View File

@ -51,6 +51,7 @@ export class TimePicker extends TimePickerBase {
super.initNativeView();
}
// @ts-ignore
get ios(): UIDatePicker {
return this.nativeViewProtected;
}

View File

@ -130,6 +130,7 @@ export class WebView extends WebViewBase {
super.onUnloaded();
}
// @ts-ignore
get ios(): WKWebView {
return this.nativeViewProtected;
}