Skip to content

Commit

Permalink
remove some ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
uNmAnNeR committed Jun 21, 2023
1 parent 3f15c4c commit c16f160
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 23 deletions.
Expand Up @@ -6,7 +6,6 @@ export default
class HTMLContenteditableMaskElement extends HTMLMaskElement {
declare input: HTMLElement;
/** Returns HTMLElement selection start */
// @ts-ignore
override get _unsafeSelectionStart (): number {
const root = this.rootElement;
const selection = root.getSelection && root.getSelection();
Expand All @@ -19,7 +18,6 @@ class HTMLContenteditableMaskElement extends HTMLMaskElement {
}

/** Returns HTMLElement selection end */
// @ts-ignore
override get _unsafeSelectionEnd (): number {
const root = this.rootElement;
const selection = root.getSelection && root.getSelection();
Expand Down Expand Up @@ -47,7 +45,6 @@ class HTMLContenteditableMaskElement extends HTMLMaskElement {
}

/** HTMLElement value */
// @ts-ignore
override get value (): string {
return this.input.textContent;
}
Expand Down
3 changes: 0 additions & 3 deletions packages/imask/src/controls/html-input-mask-element.ts
Expand Up @@ -17,13 +17,11 @@ class HTMLInputMaskElement extends HTMLMaskElement {
}

/** Returns InputElement selection start */
// @ts-ignore
override get _unsafeSelectionStart (): number {
return this.input.selectionStart;
}

/** Returns InputElement selection end */
// @ts-ignore
override get _unsafeSelectionEnd (): number {
return this.input.selectionEnd;
}
Expand All @@ -33,7 +31,6 @@ class HTMLInputMaskElement extends HTMLMaskElement {
this.input.setSelectionRange(start, end);
}

// @ts-ignore
override get value (): string {
return this.input.value;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/imask/src/controls/html-mask-element.ts
Expand Up @@ -4,7 +4,7 @@ import IMask from '../core/holder';

/** Bridge between HTMLElement and {@link Masked} */
export default
class HTMLMaskElement extends MaskElement {
abstract class HTMLMaskElement extends MaskElement {
/** Mapping between HTMLElement events and mask internal events */
static EVENTS_MAP = {
selectionChange: 'keydown',
Expand All @@ -17,6 +17,7 @@ class HTMLMaskElement extends MaskElement {
/** HTMLElement to use mask on */
declare input: HTMLElement;
declare _handlers: {[k: string]: EventListener};
abstract value: string;

constructor (input: HTMLElement) {
super();
Expand Down
3 changes: 1 addition & 2 deletions packages/imask/src/controls/input.ts
Expand Up @@ -354,8 +354,7 @@ class InputMask<Opts extends FactoryArg> {
/** Unbind view events and removes element reference */
destroy () {
this._unbindEvents();
// @ts-ignore why not
this._listeners.length = 0;
(this._listeners as any).length = 0;
delete this.el;
}
}
Expand Down
22 changes: 11 additions & 11 deletions packages/imask/src/controls/mask-element.ts
Expand Up @@ -12,13 +12,13 @@ type ElementEvent =

/** Generic element API to use with mask */
export default
class MaskElement {
abstract class MaskElement {
/** */
declare readonly _unsafeSelectionStart: number;
abstract get _unsafeSelectionStart(): number;
/** */
declare readonly _unsafeSelectionEnd: number;
abstract get _unsafeSelectionEnd(): number;
/** */
declare value: string;
abstract value: string;

/** Safely returns selection start */
get selectionStart (): number {
Expand Down Expand Up @@ -54,14 +54,14 @@ class MaskElement {
} catch {}
}

/** Should be overriden in subclasses */
_unsafeSelect (start: number, end: number): void {}
/** Should be overriden in subclasses */
/** */
get isActive (): boolean { return false; }
/** Should be overriden in subclasses */
bindEvents (handlers: {[key in ElementEvent]: Function}) {}
/** Should be overriden in subclasses */
unbindEvents (): void {}
/** */
abstract _unsafeSelect (start: number, end: number): void;
/** */
abstract bindEvents (handlers: {[key in ElementEvent]: Function}): void;
/** */
abstract unbindEvents (): void
}


Expand Down
2 changes: 1 addition & 1 deletion packages/imask/src/masked/base.ts
Expand Up @@ -47,7 +47,7 @@ type MaskedOptions<M extends Masked=Masked, Props extends keyof M=never> = Parti

/** Provides common masking stuff */
export default
class Masked<Value=any> {
abstract class Masked<Value=any> {
static DEFAULTS: Partial<MaskedOptions> = {
skipInvalid: true,
};
Expand Down
1 change: 1 addition & 0 deletions packages/imask/src/masked/function.ts
Expand Up @@ -9,6 +9,7 @@ type MaskedFunctionOptions = MaskedOptions<MaskedFunction>;
export default
class MaskedFunction<Value=any> extends Masked<Value> {
declare mask: (value: string, masked: this) => boolean;

override updateOptions (opts: Partial<MaskedFunctionOptions>) {
super.updateOptions(opts);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-imask/src/component3-options.ts
@@ -1,4 +1,4 @@
import IMask, { type FactoryOpts, type InputMask } from 'imask';
import IMask, { type FactoryOpts } from 'imask';
import { h, defineComponent, type PropType } from 'vue-demi';
import props from './props';
import { extractOptionsFromProps } from './utils';
Expand Down Expand Up @@ -89,7 +89,7 @@ export default defineComponent<MaskProps>({
if (maskOptions.mask) {
if (this.maskRef) {
this.maskRef.updateOptions(maskOptions);
const [cprop, mprop] = this._getMaskProps();
const [cprop] = this._getMaskProps();

if (cprop) this._updateValue();
} else {
Expand Down

0 comments on commit c16f160

Please sign in to comment.