Answer the question
In order to leave comments, you need to log in
How to add new type for function from node_modules?
There is a react-input-mask module .
It has a beforeMaskedStateChange function, for which types have not yet been described.
Type code from node_modules:
import * as React from 'react';
export interface Selection {
start: number;
end: number;
}
export interface InputState {
value: string;
selection: Selection | null;
}
export interface MaskOptions {
mask: string | Array<(string | RegExp)>;
maskChar: string;
alwaysShowMask: boolean;
formatChars: Record<string, string>;
permanents: number[];
}
export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
mask: string | Array<(string | RegExp)>;
maskChar?: string | null;
formatChars?: { [key: string]: string };
alwaysShowMask?: boolean;
inputRef?: React.Ref<HTMLInputElement>;
beforeMaskedValueChange?(
newState: InputState,
oldState: InputState,
userInput: string,
maskOptions: MaskOptions,
): InputState;
}
export class ReactInputMask extends React.Component<Props> {
}
export default ReactInputMask;
declare module 'react-input-mask' {
import * as React from 'react';
export interface Selection {
start: number;
end: number;
}
export interface InputState {
value: string;
selection: Selection | null;
}
export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
mask: string | (string | RegExp)[];
maskChar?: string | null;
formatChars?: { [key: string]: string };
alwaysShowMask?: boolean;
inputRef?: React.Ref<HTMLInputElement>;
beforeMaskedStateChange?({
nextState: InputState,
previousState: InputState,
currentState: InputState,
}): InputState;
}
export class ReactInputMask extends React.Component<Props> {}
export default ReactInputMask;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question