From b50a2e618fafdc0837da97bc59fc16547e583f3e Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 27 Mar 2021 13:06:43 -0700 Subject: [PATCH] chore: types cleanup --- packages/core/core-types/index.d.ts | 16 +++++----- packages/core/core-types/index.ts | 10 +++---- packages/core/package.json | 2 +- packages/core/ui/core/view/index.d.ts | 4 +-- .../ui/layouts/absolute-layout/index.d.ts | 2 +- packages/core/ui/list-view/index.d.ts | 4 +-- .../core/ui/styling/style-properties.d.ts | 30 +++---------------- packages/core/ui/tab-view/index.d.ts | 1 - packages/core/utils/layout-helper/index.d.ts | 8 ++--- 9 files changed, 27 insertions(+), 50 deletions(-) diff --git a/packages/core/core-types/index.d.ts b/packages/core/core-types/index.d.ts index 3af22c7ba..2a664338b 100644 --- a/packages/core/core-types/index.d.ts +++ b/packages/core/core-types/index.d.ts @@ -708,39 +708,39 @@ export namespace CoreTypes { /** * @deprecated Use `CoreTypes.dip` instead. */ -export type dip = number; +export type dip = CoreTypes.dip; /** * @deprecated Use `CoreTypes.px` instead. */ -export type px = number; +export type px = CoreTypes.px; /** * @deprecated Use `CoreTypes.percent` instead. */ -export type percent = number; +export type percent = CoreTypes.percent; /** * @deprecated Use `CoreTypes.LengthDipUnit` instead. */ -export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; +export type LengthDipUnit = CoreTypes.LengthDipUnit; /** * @deprecated Use `CoreTypes.LengthPxUnit` instead. */ -export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; +export type LengthPxUnit = CoreTypes.LengthPxUnit; /** * @deprecated Use `CoreTypes.LengthPercentUnit` instead. */ -export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; +export type LengthPercentUnit = CoreTypes.LengthPercentUnit; /** * @deprecated Use `CoreTypes.LengthType` instead. */ -export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; +export type LengthType = CoreTypes.LengthType; /** * @deprecated Use `CoreTypes.PercentLengthType` instead. */ -export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; +export type PercentLengthType = CoreTypes.PercentLengthType; /** * @deprecated Use `CoreTypes` instead. Enums will be removed in 9.0 diff --git a/packages/core/core-types/index.ts b/packages/core/core-types/index.ts index 499460d9f..62f835e8f 100644 --- a/packages/core/core-types/index.ts +++ b/packages/core/core-types/index.ts @@ -287,24 +287,24 @@ export type percent = number; /** * @deprecated Use `CoreTypes.LengthDipUnit` instead. */ -export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; +export type LengthDipUnit = CoreTypes.LengthDipUnit; /** * @deprecated Use `CoreTypes.LengthPxUnit` instead. */ -export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; +export type LengthPxUnit = CoreTypes.LengthPxUnit; /** * @deprecated Use `CoreTypes.LengthPercentUnit` instead. */ -export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; +export type LengthPercentUnit = CoreTypes.LengthPercentUnit; /** * @deprecated Use `CoreTypes.LengthType` instead. */ -export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; +export type LengthType = CoreTypes.LengthType; /** * @deprecated Use `CoreTypes.PercentLengthType` instead. */ -export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; +export type PercentLengthType = CoreTypes.PercentLengthType; /** * @deprecated Use `CoreTypes` instead. Enums will be removed in 9.0 diff --git a/packages/core/package.json b/packages/core/package.json index 5a5340946..98be07fad 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "NativeScript Core Modules", - "version": "8.0.0-alpha.7", + "version": "8.0.0-alpha.8", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/ui/core/view/index.d.ts b/packages/core/ui/core/view/index.d.ts index b4cc92eb3..f4d6a2445 100644 --- a/packages/core/ui/core/view/index.d.ts +++ b/packages/core/ui/core/view/index.d.ts @@ -406,12 +406,12 @@ export abstract class View extends ViewBase { /** * Gets or sets the translateX affine transform of the view in device independent pixels. */ - translateX: dip; + translateX: CoreTypes.dip; /** * Gets or sets the translateY affine transform of the view in device independent pixels. */ - translateY: dip; + translateY: CoreTypes.dip; /** * Gets or sets the scaleX affine transform of the view. diff --git a/packages/core/ui/layouts/absolute-layout/index.d.ts b/packages/core/ui/layouts/absolute-layout/index.d.ts index d430b2828..a111f70ac 100644 --- a/packages/core/ui/layouts/absolute-layout/index.d.ts +++ b/packages/core/ui/layouts/absolute-layout/index.d.ts @@ -16,7 +16,7 @@ export class AbsoluteLayout extends LayoutBase { /** * Sets the value of the Left property from a given View. */ - static setLeft(view: View, value: Length): void; + static setLeft(view: View, value: CoreTypes.LengthType): void; /** * Gets the value of the Top property from a given View. diff --git a/packages/core/ui/list-view/index.d.ts b/packages/core/ui/list-view/index.d.ts index 3789ee4e6..e1e6d85d8 100644 --- a/packages/core/ui/list-view/index.d.ts +++ b/packages/core/ui/list-view/index.d.ts @@ -191,12 +191,12 @@ export const separatorColor: Property; /** * Represents the observable property backing the rowHeight property of each ListView instance. */ -export const rowHeightProperty: Property; +export const rowHeightProperty: Property; /** * Represents the observable property backing the iosEstimatedRowHeight property of each ListView instance. */ -export const iosEstimatedRowHeightProperty: Property; +export const iosEstimatedRowHeightProperty: Property; /** * Backing property for separator color property. diff --git a/packages/core/ui/styling/style-properties.d.ts b/packages/core/ui/styling/style-properties.d.ts index 455dc54a8..290aa553f 100644 --- a/packages/core/ui/styling/style-properties.d.ts +++ b/packages/core/ui/styling/style-properties.d.ts @@ -47,7 +47,7 @@ export const colorProperty: InheritedCssProperty; export const backgroundProperty: ShorthandProperty; export const backgroundColorProperty: CssAnimationProperty; export const backgroundImageProperty: CssProperty; -export const backgroundRepeatProperty: CssProperty; +export const backgroundRepeatProperty: CssProperty; export const backgroundSizeProperty: CssProperty; export const backgroundPositionProperty: CssProperty; @@ -70,7 +70,7 @@ export const borderBottomRightRadiusProperty: CssProperty; export const zIndexProperty: CssProperty; -export const visibilityProperty: CssProperty; +export const visibilityProperty: CssProperty; export const opacityProperty: CssAnimationProperty; export const minWidthProperty: CssProperty; @@ -90,8 +90,8 @@ export const paddingRightProperty: CssProperty; export const paddingTopProperty: CssProperty; export const paddingBottomProperty: CssProperty; -export const horizontalAlignmentProperty: CssProperty; -export const verticalAlignmentProperty: CssProperty; +export const horizontalAlignmentProperty: CssProperty; +export const verticalAlignmentProperty: CssProperty; export const fontSizeProperty: InheritedCssProperty; export const fontFamilyProperty: InheritedCssProperty; @@ -103,25 +103,3 @@ export const fontInternalProperty: InheritedCssProperty; export const androidElevationProperty: CssProperty; export const androidDynamicElevationOffsetProperty: CssProperty; - -export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; -export type VisibilityType = 'visible' | 'hidden' | 'collapse'; -export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; -export namespace HorizontalAlignment { - export const LEFT: 'left'; - export const CENTER: 'center'; - export const RIGHT: 'right'; - export const STRETCH: 'stretch'; -} -export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch' | 'text-top' | 'text-bottom' | 'super' | 'sub' | 'baseline'; -export namespace VerticalAlignment { - export const TOP: 'top'; - export const MIDDLE: 'middle'; - export const BOTTOM: 'bottom'; - export const STRETCH: 'stretch'; - export const TEXTTOP: 'text-top'; - export const TEXTBOTTOM: 'text-bottom'; - export const SUPER: 'super'; - export const SUB: 'sub'; - export const BASELINE: 'baseline'; -} diff --git a/packages/core/ui/tab-view/index.d.ts b/packages/core/ui/tab-view/index.d.ts index bfe007e8e..8fcc14a68 100644 --- a/packages/core/ui/tab-view/index.d.ts +++ b/packages/core/ui/tab-view/index.d.ts @@ -9,7 +9,6 @@ import { EventData } from '../../data/observable'; import { Color } from '../../color'; import { CoreTypes } from '../../core-types'; import { Style } from '../styling/style'; -import { TextTransform } from '../text-base'; /** * Represents a tab view entry. */ diff --git a/packages/core/utils/layout-helper/index.d.ts b/packages/core/utils/layout-helper/index.d.ts index 98e68bf93..5d241b496 100644 --- a/packages/core/utils/layout-helper/index.d.ts +++ b/packages/core/utils/layout-helper/index.d.ts @@ -1,4 +1,4 @@ -import { dip, px } from '../../ui/core/view'; +import { CoreTypes } from '../../core-types'; /** * Bits that provide the actual measured size. @@ -45,19 +45,19 @@ export function getDisplayDensity(): number; * Convert device independent pixels to device pixels - dip to px. * @param value - The pixel to convert. */ -export function toDevicePixels(value: dip): px; +export function toDevicePixels(value: CoreTypes.dip): CoreTypes.px; /** * Convert device pixels to device independent pixels - px to dip. * @param value - The pixel to convert. */ -export function toDeviceIndependentPixels(value: px): dip; +export function toDeviceIndependentPixels(value: CoreTypes.px): CoreTypes.dip; /** * Rounds value used in layout. * @param px to round. */ -export function round(px: px): px; +export function round(px: CoreTypes.px): CoreTypes.px; /** * Converts device pixels to device independent pixes and measure the nativeView.