fix(all): update types to be required (#16218)

This commit is contained in:
Manu MA
2018-11-03 20:54:58 +01:00
committed by GitHub
parent a9811169fc
commit 091625df64
11 changed files with 34 additions and 41 deletions

View File

@ -2561,7 +2561,7 @@ export namespace Components {
/** /**
* The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. * The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`.
*/ */
'type': string; 'type'?: string;
} }
interface IonMenuAttributes extends StencilHTMLAttributes { interface IonMenuAttributes extends StencilHTMLAttributes {
/** /**
@ -2611,7 +2611,7 @@ export namespace Components {
/** /**
* The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`. * The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`.
*/ */
'type': string; 'type'?: string;
} }
interface IonModalController { interface IonModalController {
@ -3632,23 +3632,23 @@ export namespace Components {
*/ */
'from': string; '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 { 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. * 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. * 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; '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 { 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. * 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 { 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. * 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 { 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. * 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 { interface IonTabAttributes extends StencilHTMLAttributes {
'active'?: boolean; '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. * 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 { interface IonTabs {

View File

@ -57,7 +57,7 @@ export class Menu implements ComponentInterface, MenuI {
* The display type of the menu. * The display type of the menu.
* Available options: `"overlay"`, `"reveal"`, `"push"`. * Available options: `"overlay"`, `"reveal"`, `"push"`.
*/ */
@Prop({ mutable: true }) type!: string; @Prop({ mutable: true }) type?: string;
@Watch('type') @Watch('type')
typeChanged(type: string, oldType: string | undefined) { typeChanged(type: string, oldType: string | undefined) {
@ -143,7 +143,9 @@ export class Menu implements ComponentInterface, MenuI {
@Event() protected ionMenuChange!: EventEmitter<MenuChangeEventDetail>; @Event() protected ionMenuChange!: EventEmitter<MenuChangeEventDetail>;
async componentWillLoad() { 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) { if (this.isServer) {
this.disabled = true; this.disabled = true;
@ -169,7 +171,7 @@ export class Menu implements ComponentInterface, MenuI {
// add menu's content classes // add menu's content classes
content.classList.add('menu-content'); content.classList.add('menu-content');
this.typeChanged(this.type, undefined); this.typeChanged(this.type!, undefined);
this.sideChanged(); this.sideChanged();
// register this menu with the app's menu controller // register this menu with the app's menu controller
@ -313,7 +315,7 @@ export class Menu implements ComponentInterface, MenuI {
this.animation = undefined; this.animation = undefined;
} }
// Create new animation // 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<void> { private async startAnimation(shouldOpen: boolean, animated: boolean): Promise<void> {

View File

@ -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` | | `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'` | | `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` | | `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 ## Events

View File

@ -8,7 +8,7 @@ This route has only two configurable values:
- `from` - `from`
- `to` - `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. 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. 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 ## Examples
@ -72,9 +72,9 @@ Another approach is to modify the value of `to`, since given `to` the value of `
## Properties ## Properties
| Property | Attribute | Description | Type | Default | | 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` | `''` | | `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 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` | | `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 ## Events

View File

@ -13,7 +13,7 @@ export class RouteRedirect implements ComponentInterface {
* is not specified. * is not specified.
* *
*/ */
@Prop() from = ''; @Prop() from!: string;
/** /**
* A redirect route, redirects "from" a URL "to" another URL. This property is that "to" URL. * 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. * specified in this property.
* *
* The value of this property is always an absolute path inside the scope of routes defined in * 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 * 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. * 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, * When this property is not specified or his value is `undefined` the whole redirect route is noop,
* even if the "from" value matches. * 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, * Internal event that fires when any value of this rule is added/removed from the DOM,

View File

@ -13,7 +13,7 @@ export async function writeNavState(
// find next navigation outlet in the DOM // find next navigation outlet in the DOM
const outlet = searchNavNode(root); 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) { if (index >= chain.length || !outlet) {
return changed; return changed;
} }
@ -29,7 +29,7 @@ export async function writeNavState(
changed = true; changed = true;
} }
// recursivelly set nested outlets // recursively set nested outlets
changed = await writeNavState(result.element, chain, intent, index + 1, changed); changed = await writeNavState(result.element, chain, intent, index + 1, changed);
// once all nested outlets are visible let's make the parent visible too, // once all nested outlets are visible let's make the parent visible too,

View File

@ -5,6 +5,6 @@ export interface TabBarChangedDetail {
} }
export interface TabButtonClickDetail { export interface TabButtonClickDetail {
tab?: string; tab: string;
href?: string; href?: string;
} }

View File

@ -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` | | `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` | | `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` | | `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` |
---------------------------------------------- ----------------------------------------------

View File

@ -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 * 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. * the selected tab or by the router to switch between them.
*/ */
@Prop() tab?: string; @Prop() tab!: string;
/** /**
* The selected tab component * The selected tab component
@ -84,10 +84,6 @@ export class TabButton implements ComponentInterface {
if (this.layout === undefined) { if (this.layout === undefined) {
this.layout = this.config.get('tabButtonLayout', 'icon-top'); 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.
<ion-tab-button tab="TAB_NAME">`);
}
} }
private get hasLabel() { private get hasLabel() {

View File

@ -17,7 +17,7 @@ See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs.
| `active` | `active` | | `boolean` | `false` | | `active` | `active` | | `boolean` | `false` |
| `component` | `component` | The component to display inside of the tab. | `Function \| HTMLElement \| null \| string \| undefined` | `undefined` | | `component` | `component` | The component to display inside of the tab. | `Function \| HTMLElement \| null \| string \| undefined` | `undefined` |
| `delegate` | -- | | `FrameworkDelegate \| 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 ## Methods

View File

@ -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 * 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. * 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. * The component to display inside of the tab.
@ -39,11 +39,6 @@ export class Tab implements ComponentInterface {
` or` + ` or` +
`- Remove the embedded content inside the ion-tab: <ion-tab></ion-tab>`); `- Remove the embedded content inside the ion-tab: <ion-tab></ion-tab>`);
} }
if (this.tab === undefined) {
console.error(`Tab views need to have an unique id attribute:
<ion-tab tab="my-unique-id">`);
}
} }
} }