mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(all): ts strict (part 4)
This commit is contained in:
@ -21,8 +21,8 @@ import mdLeaveAnimation from './animations/md.leave';
|
|||||||
})
|
})
|
||||||
export class Alert implements OverlayInterface {
|
export class Alert implements OverlayInterface {
|
||||||
|
|
||||||
private activeId: string;
|
private activeId: string | undefined;
|
||||||
private inputType: string | null = null;
|
private inputType: string | undefined;
|
||||||
private hdrId: string;
|
private hdrId: string;
|
||||||
|
|
||||||
presented = false;
|
presented = false;
|
||||||
@ -266,7 +266,7 @@ export class Alert implements OverlayInterface {
|
|||||||
// return an object of all the values with the input name as the key
|
// return an object of all the values with the input name as the key
|
||||||
const values: {[k: string]: string} = {};
|
const values: {[k: string]: string} = {};
|
||||||
this.inputs.forEach(i => {
|
this.inputs.forEach(i => {
|
||||||
values[i.name] = i.value;
|
values[i.name] = i.value || '';
|
||||||
});
|
});
|
||||||
|
|
||||||
console.debug('returning', values);
|
console.debug('returning', values);
|
||||||
@ -407,7 +407,7 @@ export class Alert implements OverlayInterface {
|
|||||||
console.warn(`Alert cannot mix input types: ${(inputTypes.join('/'))}. Please see alert docs for more info.`);
|
console.warn(`Alert cannot mix input types: ${(inputTypes.join('/'))}. Please see alert docs for more info.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inputType = inputTypes.length > 0 ? inputTypes[0] : null;
|
this.inputType = inputTypes.length > 0 ? inputTypes[0] : undefined;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<ion-backdrop tappable={this.enableBackdropDismiss}/>,
|
<ion-backdrop tappable={this.enableBackdropDismiss}/>,
|
||||||
|
@ -65,6 +65,6 @@ export interface EffectProperty {
|
|||||||
|
|
||||||
export interface EffectState {
|
export interface EffectState {
|
||||||
val: any;
|
val: any;
|
||||||
num: number|null;
|
num: number;
|
||||||
effectUnit: string;
|
effectUnit: string;
|
||||||
}
|
}
|
||||||
|
@ -211,20 +211,21 @@ export class Animator {
|
|||||||
// add from/to EffectState to the EffectProperty
|
// add from/to EffectState to the EffectProperty
|
||||||
const fxState: EffectState = {
|
const fxState: EffectState = {
|
||||||
val: val,
|
val: val,
|
||||||
num: null,
|
num: 0,
|
||||||
effectUnit: '',
|
effectUnit: '',
|
||||||
};
|
};
|
||||||
fxProp[state] = fxState;
|
fxProp[state] = fxState;
|
||||||
|
|
||||||
if (typeof val === 'string' && val.indexOf(' ') < 0) {
|
if (typeof val === 'string' && val.indexOf(' ') < 0) {
|
||||||
const r = val.match(CSS_VALUE_REGEX);
|
const r = val.match(CSS_VALUE_REGEX);
|
||||||
const num = parseFloat(r[1]);
|
if (r) {
|
||||||
|
const num = parseFloat(r[1]);
|
||||||
|
|
||||||
if (!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
fxState.num = num;
|
fxState.num = num;
|
||||||
|
}
|
||||||
|
fxState.effectUnit = (r[0] !== r[2] ? r[2] : '');
|
||||||
}
|
}
|
||||||
fxState.effectUnit = (r[0] !== r[2] ? r[2] : '');
|
|
||||||
|
|
||||||
} else if (typeof val === 'number') {
|
} else if (typeof val === 'number') {
|
||||||
fxState.num = val;
|
fxState.num = val;
|
||||||
}
|
}
|
||||||
@ -972,19 +973,18 @@ export class Animator {
|
|||||||
* NO RECURSION
|
* NO RECURSION
|
||||||
*/
|
*/
|
||||||
_willChange(addWillChange: boolean) {
|
_willChange(addWillChange: boolean) {
|
||||||
let i = 0;
|
|
||||||
let wc: string[];
|
let wc: string[];
|
||||||
const effects = this._fxProperties;
|
const effects = this._fxProperties;
|
||||||
let willChange: string;
|
let willChange: string;
|
||||||
|
|
||||||
if (addWillChange && effects) {
|
if (addWillChange && effects) {
|
||||||
wc = [];
|
wc = [];
|
||||||
for (i = 0; i < effects.length; i++) {
|
for (let i = 0; i < effects.length; i++) {
|
||||||
const propWC = effects[i].wc;
|
const propWC = effects[i].wc;
|
||||||
if (propWC === 'webkitTransform') {
|
if (propWC === 'webkitTransform') {
|
||||||
wc.push('transform', '-webkit-transform');
|
wc.push('transform', '-webkit-transform');
|
||||||
|
|
||||||
} else {
|
} else if (propWC) {
|
||||||
wc.push(propWC);
|
wc.push(propWC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -994,9 +994,12 @@ export class Animator {
|
|||||||
willChange = '';
|
willChange = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < this._elementTotal; i++) {
|
const elements = this._elements;
|
||||||
// ******** DOM WRITE ****************
|
if (elements) {
|
||||||
(this._elements[i] as any).style.willChange = willChange;
|
for (let i = 0; i < this._elementTotal; i++) {
|
||||||
|
// ******** DOM WRITE ****************
|
||||||
|
(elements[i] as any).style.willChange = willChange;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,7 +1060,7 @@ export class Animator {
|
|||||||
if (this._isReverse) {
|
if (this._isReverse) {
|
||||||
// if the animation is going in reverse then
|
// if the animation is going in reverse then
|
||||||
// flip the step value: 0 becomes 1, 1 becomes 0
|
// flip the step value: 0 becomes 1, 1 becomes 0
|
||||||
currentStepValue = ((currentStepValue * -1) + 1);
|
currentStepValue = 1 - currentStepValue;
|
||||||
}
|
}
|
||||||
const stepValue = shouldComplete ? 1 : 0;
|
const stepValue = shouldComplete ? 1 : 0;
|
||||||
|
|
||||||
@ -1065,10 +1068,10 @@ export class Animator {
|
|||||||
if (dur === undefined) {
|
if (dur === undefined) {
|
||||||
dur = -1;
|
dur = -1;
|
||||||
}
|
}
|
||||||
if (diff < 0.05) {
|
if (dur < 0) {
|
||||||
|
dur = this._duration || 0;
|
||||||
|
} else if (diff < 0.05) {
|
||||||
dur = 0;
|
dur = 0;
|
||||||
} else if (dur < 0) {
|
|
||||||
dur = this._duration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._isAsync = (dur > 30);
|
this._isAsync = (dur > 30);
|
||||||
|
@ -1,30 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
export function transitionEnd(el: HTMLElement, callback: {(ev?: TransitionEvent): void}) {
|
export function transitionEnd(el: HTMLElement|null, callback: {(ev?: TransitionEvent): void}) {
|
||||||
let unRegTrans: Function;
|
let unRegTrans: Function;
|
||||||
let unRegWKTrans: Function;
|
|
||||||
const opts: any = { passive: true };
|
const opts: any = { passive: true };
|
||||||
|
|
||||||
function unregister() {
|
function unregister() {
|
||||||
unRegWKTrans && unRegWKTrans();
|
|
||||||
unRegTrans && unRegTrans();
|
unRegTrans && unRegTrans();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTransitionEnd(ev: TransitionEvent) {
|
function onTransitionEnd(ev: Event) {
|
||||||
if (el === ev.target) {
|
if (el === ev.target) {
|
||||||
unregister();
|
unregister();
|
||||||
callback(ev);
|
callback(ev as TransitionEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el) {
|
if (el) {
|
||||||
el.addEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
el.addEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||||
unRegWKTrans = function() {
|
|
||||||
el.removeEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
|
||||||
};
|
|
||||||
|
|
||||||
el.addEventListener('transitionend', onTransitionEnd, opts);
|
el.addEventListener('transitionend', onTransitionEnd, opts);
|
||||||
|
|
||||||
unRegTrans = function() {
|
unRegTrans = function() {
|
||||||
|
el.removeEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||||
el.removeEventListener('transitionend', onTransitionEnd, opts);
|
el.removeEventListener('transitionend', onTransitionEnd, opts);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export function renderDatetime(template: string, value: DatetimeData, locale: Lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function renderTextFormat(format: string, value: any, date: DatetimeData, locale: LocaleData): string {
|
export function renderTextFormat(format: string, value: any, date: DatetimeData|null, locale: LocaleData): string {
|
||||||
|
|
||||||
if (format === FORMAT_DDDD || format === FORMAT_DDD) {
|
if (format === FORMAT_DDDD || format === FORMAT_DDD) {
|
||||||
try {
|
try {
|
||||||
@ -55,11 +55,11 @@ export function renderTextFormat(format: string, value: any, date: DatetimeData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (format === FORMAT_A) {
|
if (format === FORMAT_A) {
|
||||||
return date ? date.hour < 12 ? 'AM' : 'PM' : value ? value.toUpperCase() : '';
|
return date && date.hour ? date.hour < 12 ? 'AM' : 'PM' : value ? value.toUpperCase() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format === FORMAT_a) {
|
if (format === FORMAT_a) {
|
||||||
return date ? date.hour < 12 ? 'am' : 'pm' : value ? value : '';
|
return date && date.hour ? date.hour < 12 ? 'am' : 'pm' : value ? value : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBlank(value)) {
|
if (isBlank(value)) {
|
||||||
@ -102,45 +102,48 @@ export function renderTextFormat(format: string, value: any, date: DatetimeData,
|
|||||||
|
|
||||||
export function dateValueRange(format: string, min: DatetimeData, max: DatetimeData): any[] {
|
export function dateValueRange(format: string, min: DatetimeData, max: DatetimeData): any[] {
|
||||||
const opts: any[] = [];
|
const opts: any[] = [];
|
||||||
let i: number;
|
|
||||||
|
|
||||||
if (format === FORMAT_YYYY || format === FORMAT_YY) {
|
if (format === FORMAT_YYYY || format === FORMAT_YY) {
|
||||||
// year
|
// year
|
||||||
i = max.year;
|
if (!max.year || !min.year) {
|
||||||
while (i >= min.year) {
|
throw new Error('min and max year is undefined');
|
||||||
opts.push(i--);
|
}
|
||||||
|
|
||||||
|
for (let i = max.year - 1; i >= min.year; i--) {
|
||||||
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_MMMM || format === FORMAT_MMM ||
|
} else if (format === FORMAT_MMMM || format === FORMAT_MMM ||
|
||||||
format === FORMAT_MM || format === FORMAT_M ||
|
format === FORMAT_MM || format === FORMAT_M ||
|
||||||
format === FORMAT_hh || format === FORMAT_h) {
|
format === FORMAT_hh || format === FORMAT_h) {
|
||||||
|
|
||||||
// month or 12-hour
|
// month or 12-hour
|
||||||
for (i = 1; i < 13; i++) {
|
for (let i = 1; i < 13; i++) {
|
||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_DDDD || format === FORMAT_DDD ||
|
} else if (format === FORMAT_DDDD || format === FORMAT_DDD ||
|
||||||
format === FORMAT_DD || format === FORMAT_D) {
|
format === FORMAT_DD || format === FORMAT_D) {
|
||||||
// day
|
// day
|
||||||
for (i = 1; i < 32; i++) {
|
for (let i = 1; i < 32; i++) {
|
||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_HH || format === FORMAT_H) {
|
} else if (format === FORMAT_HH || format === FORMAT_H) {
|
||||||
// 24-hour
|
// 24-hour
|
||||||
for (i = 0; i < 24; i++) {
|
for (let i = 0; i < 24; i++) {
|
||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_mm || format === FORMAT_m) {
|
} else if (format === FORMAT_mm || format === FORMAT_m) {
|
||||||
// minutes
|
// minutes
|
||||||
for (i = 0; i < 60; i++) {
|
for (let i = 0; i < 60; i++) {
|
||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (format === FORMAT_ss || format === FORMAT_s) {
|
} else if (format === FORMAT_ss || format === FORMAT_s) {
|
||||||
// seconds
|
// seconds
|
||||||
for (i = 0; i < 60; i++) {
|
for (let i = 0; i < 60; i++) {
|
||||||
opts.push(i);
|
opts.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,10 +178,10 @@ export function isLeapYear(year: number): boolean {
|
|||||||
const ISO_8601_REGEXP = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
|
const ISO_8601_REGEXP = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
|
||||||
const TIME_REGEXP = /^((\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
|
const TIME_REGEXP = /^((\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
|
||||||
|
|
||||||
export function parseDate(val: any): DatetimeData {
|
export function parseDate(val: any): DatetimeData|null {
|
||||||
// manually parse IS0 cuz Date.parse cannot be trusted
|
// manually parse IS0 cuz Date.parse cannot be trusted
|
||||||
// ISO 8601 format: 1994-12-15T13:47:20Z
|
// ISO 8601 format: 1994-12-15T13:47:20Z
|
||||||
let parse: any[];
|
let parse: any[] = null;
|
||||||
|
|
||||||
if (val && val !== '') {
|
if (val && val !== '') {
|
||||||
// try parsing for just time first, HH:MM
|
// try parsing for just time first, HH:MM
|
||||||
@ -322,7 +325,7 @@ export function getValueFromFormat(date: DatetimeData, format: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function convertFormatToKey(format: string): string {
|
export function convertFormatToKey(format: string): string|null {
|
||||||
for (const k in FORMAT_KEYS) {
|
for (const k in FORMAT_KEYS) {
|
||||||
if (FORMAT_KEYS[k].f === format) {
|
if (FORMAT_KEYS[k].f === format) {
|
||||||
return FORMAT_KEYS[k].k;
|
return FORMAT_KEYS[k].k;
|
||||||
@ -448,15 +451,15 @@ export function convertToArrayOfNumbers(input: any[] | string | number, type: st
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function twoDigit(val: number): string {
|
function twoDigit(val: number | undefined): string {
|
||||||
return ('0' + (val ? Math.abs(val) : '0')).slice(-2);
|
return ('0' + (val ? Math.abs(val) : '0')).slice(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function threeDigit(val: number): string {
|
function threeDigit(val: number | undefined): string {
|
||||||
return ('00' + (val ? Math.abs(val) : '0')).slice(-3);
|
return ('00' + (val ? Math.abs(val) : '0')).slice(-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fourDigit(val: number): string {
|
function fourDigit(val: number | undefined): string {
|
||||||
return ('000' + (val ? Math.abs(val) : '0')).slice(-4);
|
return ('000' + (val ? Math.abs(val) : '0')).slice(-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ export class Picker implements OverlayInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
addButton(button: any) {
|
addButton(button: PickerButton) {
|
||||||
this.buttons.push(button);
|
this.buttons.push(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +201,8 @@ export class Picker implements OverlayInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
getColumn(name: string): PickerColumn {
|
getColumn(name: string): PickerColumn|undefined {
|
||||||
return this.getColumns().find(column => column.name === name);
|
return this.columns.find(column => column.name === name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
@ -232,10 +232,10 @@ export class Picker implements OverlayInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSelected(): any {
|
private getSelected() {
|
||||||
const selected: {[k: string]: any} = {};
|
const selected: {[k: string]: any} = {};
|
||||||
this.columns.forEach((col, index) => {
|
this.columns.forEach((col, index) => {
|
||||||
const selectedColumn = col.options[col.selectedIndex];
|
const selectedColumn = col.selectedIndex ? col.options[col.selectedIndex] : null;
|
||||||
selected[col.name] = {
|
selected[col.name] = {
|
||||||
text: selectedColumn ? selectedColumn.text : null,
|
text: selectedColumn ? selectedColumn.text : null,
|
||||||
value: selectedColumn ? selectedColumn.value : null,
|
value: selectedColumn ? selectedColumn.value : null,
|
||||||
@ -354,13 +354,13 @@ export interface PickerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PickerColumn {
|
export interface PickerColumn {
|
||||||
name?: string;
|
name: string;
|
||||||
align?: string;
|
align?: string;
|
||||||
selectedIndex?: number;
|
selectedIndex?: number;
|
||||||
prevSelected?: number;
|
prevSelected?: number;
|
||||||
prefix?: string;
|
prefix?: string;
|
||||||
suffix?: string;
|
suffix?: string;
|
||||||
options?: PickerColumnOption[];
|
options: PickerColumnOption[];
|
||||||
cssClass?: string;
|
cssClass?: string;
|
||||||
columnWidth?: string;
|
columnWidth?: string;
|
||||||
prefixWidth?: string;
|
prefixWidth?: string;
|
||||||
|
@ -47,7 +47,7 @@ export function matchesIDs(ids: string[], chain: RouteChain): number {
|
|||||||
export function matchesPath(path: string[], chain: RouteChain): RouteChain | null {
|
export function matchesPath(path: string[], chain: RouteChain): RouteChain | null {
|
||||||
const segments = new RouterSegments(path);
|
const segments = new RouterSegments(path);
|
||||||
let matchesDefault = false;
|
let matchesDefault = false;
|
||||||
let allparams: any[];
|
let allparams: any[]|undefined = undefined;
|
||||||
for (let i = 0; i < chain.length; i++) {
|
for (let i = 0; i < chain.length; i++) {
|
||||||
const path = chain[i].path;
|
const path = chain[i].path;
|
||||||
if (path[0] === '') {
|
if (path[0] === '') {
|
||||||
@ -125,7 +125,7 @@ export function routerIDsToChain(ids: RouteID[], chains: RouteChain[]): RouteCha
|
|||||||
|
|
||||||
|
|
||||||
export function routerPathToChain(path: string[], chains: RouteChain[]): RouteChain|null {
|
export function routerPathToChain(path: string[], chains: RouteChain[]): RouteChain|null {
|
||||||
let match: RouteChain = null;
|
let match: RouteChain|null = null;
|
||||||
let matches = 0;
|
let matches = 0;
|
||||||
for (const chain of chains) {
|
for (const chain of chains) {
|
||||||
const matchedChain = matchesPath(path, chain);
|
const matchedChain = matchesPath(path, chain);
|
||||||
|
@ -34,9 +34,9 @@ export function writePath(history: History, base: string, usePath: boolean, path
|
|||||||
}
|
}
|
||||||
if (isPop) {
|
if (isPop) {
|
||||||
// history.back();
|
// history.back();
|
||||||
history.replaceState(state, null, url);
|
history.replaceState(state, '', url);
|
||||||
} else {
|
} else {
|
||||||
history.pushState(state, null, url);
|
history.pushState(state, '', url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +51,8 @@ export function readPath(loc: Location, base: string, useHash: boolean): string[
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parsePath(path: string): string[] {
|
export function parsePath(path: string|null|undefined): string[] {
|
||||||
if (path === null || path === undefined) {
|
if (path == null) {
|
||||||
return [''];
|
return [''];
|
||||||
}
|
}
|
||||||
const segments = path.split('/')
|
const segments = path.split('/')
|
||||||
|
Reference in New Issue
Block a user