From 091625df648cd5911198f6084ce9e12d85228961 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Sat, 3 Nov 2018 20:54:58 +0100 Subject: [PATCH] fix(all): update types to be required (#16218) --- core/src/components.d.ts | 22 +++++++++---------- core/src/components/menu/menu.tsx | 10 +++++---- core/src/components/menu/readme.md | 2 +- core/src/components/route-redirect/readme.md | 12 +++++----- .../route-redirect/route-redirect.tsx | 6 ++--- core/src/components/router/utils/dom.ts | 4 ++-- .../components/tab-bar/tab-bar-interface.ts | 2 +- core/src/components/tab-button/readme.md | 2 +- core/src/components/tab-button/tab-button.tsx | 6 +---- core/src/components/tab/readme.md | 2 +- core/src/components/tab/tab.tsx | 7 +----- 11 files changed, 34 insertions(+), 41 deletions(-) diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 268a175f08d..2f31b036cd4 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -2561,7 +2561,7 @@ export namespace Components { /** * The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. */ - 'type': string; + 'type'?: string; } interface IonMenuAttributes extends StencilHTMLAttributes { /** @@ -2611,7 +2611,7 @@ export namespace Components { /** * The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. */ - 'type': string; + 'type'?: string; } interface IonModalController { @@ -3632,23 +3632,23 @@ export namespace Components { */ 'from': string; /** - * A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perfom a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. + * A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perform a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. */ - 'to'?: string; + 'to': string | undefined | null; } interface IonRouteRedirectAttributes extends StencilHTMLAttributes { /** * A redirect route, redirects "from" a URL "to" another URL. This property is that "from" URL. It needs to be an exact match of the navigated URL in order to apply. The path specified in this value is always an absolute path, even if the initial `/` slash is not specified. */ - 'from'?: string; + 'from': string; /** * Internal event that fires when any value of this rule is added/removed from the DOM, or any of his public properties changes. `ion-router` captures this event in order to update his internal registry of router rules. */ 'onIonRouteRedirectChanged'?: (event: CustomEvent) => void; /** - * A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perfom a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. + * A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perform a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. */ - 'to'?: string; + 'to': string | undefined | null; } interface IonRoute { @@ -4504,7 +4504,7 @@ export namespace Components { /** * A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. */ - 'tab'?: string; + 'tab': string; } interface IonTabButtonAttributes extends StencilHTMLAttributes { /** @@ -4534,7 +4534,7 @@ export namespace Components { /** * A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. */ - 'tab'?: string; + 'tab': string; } interface IonTab { @@ -4551,7 +4551,7 @@ export namespace Components { /** * A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. */ - 'tab'?: string; + 'tab': string; } interface IonTabAttributes extends StencilHTMLAttributes { 'active'?: boolean; @@ -4563,7 +4563,7 @@ export namespace Components { /** * A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. */ - 'tab'?: string; + 'tab': string; } interface IonTabs { diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 50d66710619..d5f9707a5fa 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -57,7 +57,7 @@ export class Menu implements ComponentInterface, MenuI { * The display type of the menu. * Available options: `"overlay"`, `"reveal"`, `"push"`. */ - @Prop({ mutable: true }) type!: string; + @Prop({ mutable: true }) type?: string; @Watch('type') typeChanged(type: string, oldType: string | undefined) { @@ -143,7 +143,9 @@ export class Menu implements ComponentInterface, MenuI { @Event() protected ionMenuChange!: EventEmitter; async componentWillLoad() { - this.type = this.type || this.config.get('menuType', this.mode === 'ios' ? 'reveal' : 'overlay'); + if (this.type === undefined) { + this.type = this.config.get('menuType', this.mode === 'ios' ? 'reveal' : 'overlay'); + } if (this.isServer) { this.disabled = true; @@ -169,7 +171,7 @@ export class Menu implements ComponentInterface, MenuI { // add menu's content classes content.classList.add('menu-content'); - this.typeChanged(this.type, undefined); + this.typeChanged(this.type!, undefined); this.sideChanged(); // register this menu with the app's menu controller @@ -313,7 +315,7 @@ export class Menu implements ComponentInterface, MenuI { this.animation = undefined; } // Create new animation - this.animation = await this.menuCtrl!._createAnimation(this.type, this); + this.animation = await this.menuCtrl!._createAnimation(this.type!, this); } private async startAnimation(shouldOpen: boolean, animated: boolean): Promise { diff --git a/core/src/components/menu/readme.md b/core/src/components/menu/readme.md index 68925e1e9c4..91a47167905 100644 --- a/core/src/components/menu/readme.md +++ b/core/src/components/menu/readme.md @@ -21,7 +21,7 @@ These can be controlled from the templates, or programmatically using the MenuCo | `menuId` | `menu-id` | An id for the menu. | `string \| undefined` | `undefined` | | `side` | `side` | Which side of the view the menu should be placed. | `"end" \| "start"` | `'start'` | | `swipeGesture` | `swipe-gesture` | If `true`, swiping the menu is enabled. | `boolean` | `true` | -| `type` | `type` | The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. | `string` | `undefined` | +| `type` | `type` | The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. | `string \| undefined` | `undefined` | ## Events diff --git a/core/src/components/route-redirect/readme.md b/core/src/components/route-redirect/readme.md index fb6a0897d2a..15b4368e509 100644 --- a/core/src/components/route-redirect/readme.md +++ b/core/src/components/route-redirect/readme.md @@ -8,7 +8,7 @@ This route has only two configurable values: - `from` - `to` -Their meaning is obvious under the context of a redirection, that ocurrs `from` a given URL `to` another given URL. +Their meaning is obvious under the context of a redirection, that occurs `from` a given URL `to` another given URL. In other for a redirection to occurs the `from` path needs to be an exact match of the navigated URL. @@ -29,7 +29,7 @@ Let's say we have this two redirection rules: And the user navigates to `/admin`. The router will then redirect to `/login` and stop there. -It WILL NOT never evalute more than one redirection rule in a roll. +It WILL NOT never evaluate more than one redirection rule in a roll. ## Examples @@ -71,10 +71,10 @@ Another approach is to modify the value of `to`, since given `to` the value of ` ## Properties -| Property | Attribute | Description | Type | Default | -| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------- | -| `from` | `from` | A redirect route, redirects "from" a URL "to" another URL. This property is that "from" URL. It needs to be an exact match of the navigated URL in order to apply. The path specified in this value is always an absolute path, even if the initial `/` slash is not specified. | `string` | `''` | -| `to` | `to` | A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perfom a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. | `string \| undefined` | `undefined` | +| Property | Attribute | Description | Type | Default | +| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------- | ----------- | +| `from` | `from` | A redirect route, redirects "from" a URL "to" another URL. This property is that "from" URL. It needs to be an exact match of the navigated URL in order to apply. The path specified in this value is always an absolute path, even if the initial `/` slash is not specified. | `string` | `undefined` | +| `to` | `to` | A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. When the defined `ion-route-redirect` rule matches, the router will redirect to the path specified in this property. The value of this property is always an absolute path inside the scope of routes defined in `ion-router` it can't be used with another router or to perform a redirection to a different domain. Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's a redirect inside the context of ion-router. When this property is not specified or his value is `undefined` the whole redirect route is noop, even if the "from" value matches. | `null \| string \| undefined` | `undefined` | ## Events diff --git a/core/src/components/route-redirect/route-redirect.tsx b/core/src/components/route-redirect/route-redirect.tsx index cb308c3673e..5ba3c1260c8 100644 --- a/core/src/components/route-redirect/route-redirect.tsx +++ b/core/src/components/route-redirect/route-redirect.tsx @@ -13,7 +13,7 @@ export class RouteRedirect implements ComponentInterface { * is not specified. * */ - @Prop() from = ''; + @Prop() from!: string; /** * A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. @@ -21,7 +21,7 @@ export class RouteRedirect implements ComponentInterface { * specified in this property. * * The value of this property is always an absolute path inside the scope of routes defined in - * `ion-router` it can't be used with another router or to perfom a redirection to a different domain. + * `ion-router` it can't be used with another router or to perform a redirection to a different domain. * * Note that this is a virtual redirect, it will not cause a real browser refresh, again, it's * a redirect inside the context of ion-router. @@ -29,7 +29,7 @@ export class RouteRedirect implements ComponentInterface { * When this property is not specified or his value is `undefined` the whole redirect route is noop, * even if the "from" value matches. */ - @Prop() to?: string; + @Prop() to!: string | undefined | null; /** * Internal event that fires when any value of this rule is added/removed from the DOM, diff --git a/core/src/components/router/utils/dom.ts b/core/src/components/router/utils/dom.ts index 88621bebc0e..0e728763ede 100644 --- a/core/src/components/router/utils/dom.ts +++ b/core/src/components/router/utils/dom.ts @@ -13,7 +13,7 @@ export async function writeNavState( // find next navigation outlet in the DOM const outlet = searchNavNode(root); - // make sure we can continue interating the DOM, otherwise abort + // make sure we can continue interacting the DOM, otherwise abort if (index >= chain.length || !outlet) { return changed; } @@ -29,7 +29,7 @@ export async function writeNavState( changed = true; } - // recursivelly set nested outlets + // recursively set nested outlets changed = await writeNavState(result.element, chain, intent, index + 1, changed); // once all nested outlets are visible let's make the parent visible too, diff --git a/core/src/components/tab-bar/tab-bar-interface.ts b/core/src/components/tab-bar/tab-bar-interface.ts index 3a77b6235aa..ed086dd023b 100644 --- a/core/src/components/tab-bar/tab-bar-interface.ts +++ b/core/src/components/tab-bar/tab-bar-interface.ts @@ -5,6 +5,6 @@ export interface TabBarChangedDetail { } export interface TabButtonClickDetail { - tab?: string; + tab: string; href?: string; } diff --git a/core/src/components/tab-button/readme.md b/core/src/components/tab-button/readme.md index 32b50d41201..d4eb87a562e 100644 --- a/core/src/components/tab-button/readme.md +++ b/core/src/components/tab-button/readme.md @@ -17,7 +17,7 @@ See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs. | `href` | `href` | The URL which will be used as the `href` within this tab's button anchor. | `string \| undefined` | `undefined` | | `layout` | `layout` | Set the layout of the text and icon in the tab bar. It defaults to `'icon-top'`. | `"icon-bottom" \| "icon-end" \| "icon-hide" \| "icon-start" \| "icon-top" \| "label-hide" \| undefined` | `undefined` | | `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` | -| `tab` | `tab` | A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. | `string \| undefined` | `undefined` | +| `tab` | `tab` | A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. | `string` | `undefined` | ---------------------------------------------- diff --git a/core/src/components/tab-button/tab-button.tsx b/core/src/components/tab-button/tab-button.tsx index d4106e69dc8..9fd43d4edce 100644 --- a/core/src/components/tab-button/tab-button.tsx +++ b/core/src/components/tab-button/tab-button.tsx @@ -51,7 +51,7 @@ export class TabButton implements ComponentInterface { * A tab id must be provided for each `ion-tab`. It's used internally to reference * the selected tab or by the router to switch between them. */ - @Prop() tab?: string; + @Prop() tab!: string; /** * The selected tab component @@ -84,10 +84,6 @@ export class TabButton implements ComponentInterface { if (this.layout === undefined) { this.layout = this.config.get('tabButtonLayout', 'icon-top'); } - if (this.tab === undefined) { - console.warn(`ion-tab-button needs a tab name, so it can be selected. - `); - } } private get hasLabel() { diff --git a/core/src/components/tab/readme.md b/core/src/components/tab/readme.md index be44dda60d3..64296bd1824 100644 --- a/core/src/components/tab/readme.md +++ b/core/src/components/tab/readme.md @@ -17,7 +17,7 @@ See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs. | `active` | `active` | | `boolean` | `false` | | `component` | `component` | The component to display inside of the tab. | `Function \| HTMLElement \| null \| string \| undefined` | `undefined` | | `delegate` | -- | | `FrameworkDelegate \| undefined` | `undefined` | -| `tab` | `tab` | A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. | `string \| undefined` | `undefined` | +| `tab` | `tab` | A tab id must be provided for each `ion-tab`. It's used internally to reference the selected tab or by the router to switch between them. | `string` | `undefined` | ## Methods diff --git a/core/src/components/tab/tab.tsx b/core/src/components/tab/tab.tsx index 99cd748d8fc..23902e643b4 100644 --- a/core/src/components/tab/tab.tsx +++ b/core/src/components/tab/tab.tsx @@ -23,7 +23,7 @@ export class Tab implements ComponentInterface { * A tab id must be provided for each `ion-tab`. It's used internally to reference * the selected tab or by the router to switch between them. */ - @Prop() tab?: string; + @Prop() tab!: string; /** * The component to display inside of the tab. @@ -39,11 +39,6 @@ export class Tab implements ComponentInterface { ` or` + `- Remove the embedded content inside the ion-tab: `); } - - if (this.tab === undefined) { - console.error(`Tab views need to have an unique id attribute: - `); - } } }