improve types
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* @param value Function or any value.
|
||||
* @param context Optional context to bind to function.
|
||||
*/
|
||||
export default function callOrReturn(value: any, context?: any) {
|
||||
export default function callOrReturn(value: any, context?: any): any {
|
||||
if (typeof value === 'function') {
|
||||
if (context) {
|
||||
return value.bind(context)()
|
||||
|
||||
@@ -5,7 +5,7 @@ import { AnyObject } from '../types'
|
||||
* @param obj Object
|
||||
* @param key Key to remove
|
||||
*/
|
||||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]) {
|
||||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]): AnyObject {
|
||||
const props = typeof propOrProps === 'string'
|
||||
? [propOrProps]
|
||||
: propOrProps
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function fromString(value: any) {
|
||||
export default function fromString(value: any): any {
|
||||
if (typeof value !== 'string') {
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isEmptyObject(object = {}) {
|
||||
export default function isEmptyObject(object = {}): boolean {
|
||||
return Object.keys(object).length === 0 && object.constructor === Object
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function magicMethods(Clazz: any) {
|
||||
export default function magicMethods(Clazz: any): any {
|
||||
const classHandler = Object.create(null)
|
||||
|
||||
classHandler.construct = (_: any, args: any) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function mergeAttributes(...objects: AnyObject[]) {
|
||||
export default function mergeAttributes(...objects: AnyObject[]): AnyObject {
|
||||
return objects
|
||||
.filter(item => !!item)
|
||||
.reduce((items, item) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AnyObject } from '../types'
|
||||
import isObject from './isObject'
|
||||
|
||||
export default function mergeDeep(target: AnyObject, source: AnyObject) {
|
||||
export default function mergeDeep(target: AnyObject, source: AnyObject): AnyObject {
|
||||
const output = { ...target }
|
||||
|
||||
if (isObject(target) && isObject(source)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function removeElement(element: HTMLElement) {
|
||||
export default function removeElement(element: HTMLElement): void {
|
||||
if (element && element.parentNode) {
|
||||
element.parentNode.removeChild(element)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user