Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Various typing improvements #283

Merged
merged 4 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/ColorPicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ class ColorPicker extends Element implements IBindable {

this._changing = true;

// @ts-ignore
const hex = this._fieldHex.value.trim().toLowerCase();
if (/^([0-9a-f]{2}){3,4}$/.test(hex)) {
for (let i = 0; i < this._channelsNumber; i++) {
Expand Down Expand Up @@ -676,7 +675,6 @@ class ColorPicker extends Element implements IBindable {
}

if (different) {
// @ts-ignore
this.value = null;
this.dom.classList.add(CLASS_MULTIPLE_VALUES);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@ class Container extends Element {
* @returns The recursively appended element node.
*
*/
protected _buildDomNode(node: { [x: string]: any; root?: any; children?: any; }) {
protected _buildDomNode(node: { [x: string]: any; root?: any; children?: any; }): Container {
const keys = Object.keys(node);
let rootNode: { append: (arg0: any) => void; };
let rootNode: Container;
if (keys.includes('root')) {
rootNode = this._buildDomNode(node.root);
node.children.forEach((childNode: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/GridView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface GridViewArgs extends ContainerArgs {
class GridView extends Container {
protected _vertical: boolean;

protected _clickFn: (evt: MouseEvent, item: GridViewItem) => void;

protected _filterFn: (item: GridViewItem) => boolean;

protected _filterAnimationFrame: number;
Expand All @@ -48,8 +50,6 @@ class GridView extends Container {

protected _selected: GridViewItem[];

protected _clickFn: any;

constructor(args: Readonly<GridViewArgs> = {}) {
super(args);

Expand Down
4 changes: 2 additions & 2 deletions src/components/Label/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface LabelArgs extends ElementArgs, IBindableArgs, IPlaceholderArgs,
/**
* Sets the text of the Label. Defaults to ''.
*/
text?: string | number,
text?: string,
/**
* If `true`, the {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML innerHTML} property will be
* used to set the text. Otherwise, {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent textContent}
Expand All @@ -32,7 +32,7 @@ export interface LabelArgs extends ElementArgs, IBindableArgs, IPlaceholderArgs,
/**
* Sets the value of the Label. Defaults to ''.
*/
value?: any,
value?: string
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/components/NumericInput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NumericInput extends InputElement {

protected _stepPrecision: number;

protected _oldValue: any;
protected _oldValue: number;

protected _historyCombine: boolean;

Expand Down Expand Up @@ -186,7 +186,7 @@ class NumericInput extends InputElement {
}
};

protected _onInputChange(evt: any) {
protected _onInputChange(evt: Event) {
// get the content of the input, normalize it and set it as the current value
this.value = this._normalizeValue(this._domInput.value);
}
Expand Down Expand Up @@ -309,7 +309,6 @@ class NumericInput extends InputElement {

get value() : number {
const val = this._domInput.value;
// @ts-ignore
return val !== '' ? parseFloat(val) : null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectInput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class SelectInput extends Element implements IBindable, IFocusable {

protected _value: any;

protected _createLabelContainer: any;
protected _createLabelContainer: Container;

protected _options: any;

Expand Down Expand Up @@ -571,7 +571,7 @@ class SelectInput extends Element implements IBindable, IFocusable {
return container;
}

protected _removeTag(tagElement: any, value: string) {
protected _removeTag(tagElement: Container, value: string) {
tagElement.destroy();

const label = this._valueToLabel[value];
Expand Down
7 changes: 4 additions & 3 deletions src/components/TextInput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const CLASS_TEXT_INPUT = 'pcui-text-input';
*/
export interface TextInputArgs extends InputElementArgs, IBindableArgs, IPlaceholderArgs {
/**
* A function that validates the value that is entered into the input and returns `true` if it is valid or `false` otherwise.
* If `false` then the input will be set in an error state and the value will not propagate to the binding.
* A function that validates the value that is entered into the input and returns `true` if it
* is valid or `false` otherwise. If `false` then the input will be set in an error state and
* the value will not propagate to the binding.
*/
onValidate?: (value: string) => boolean,
}
Expand All @@ -19,7 +20,7 @@ export interface TextInputArgs extends InputElementArgs, IBindableArgs, IPlaceho
* The TextInput is an input element of type text.
*/
class TextInput extends InputElement {
protected _onValidate: any;
protected _onValidate: (value: string) => boolean;

constructor(args: Readonly<TextInputArgs> = {}) {
super(args);
Expand Down
4 changes: 2 additions & 2 deletions src/components/TreeView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface TreeViewArgs extends ContainerArgs {
/**
* A function to be called when we right click on a {@link TreeViewItem}.
*/
onContextMenu?: any,
onContextMenu?: (evt: MouseEvent, item: TreeViewItem) => void,
/**
* A function to be called when we try to reparent tree items. If a function is provided then the
* tree items will not be reparented by the {@link TreeView} but instead will rely on the function to
Expand Down Expand Up @@ -166,7 +166,7 @@ class TreeView extends Container {

protected _dragScrollElement: any;

protected _onContextMenu: any;
protected _onContextMenu: (evt: MouseEvent, item: TreeViewItem) => void;

protected _onReparentFn: any;

Expand Down