make-event-props
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -35,3 +35,3 @@ export declare const clipboardEvents: readonly ["onCopy", "onCut", "onPaste"]; | ||
*/ | ||
export default function makeEventProps<ArgsType, PropsType extends Props<ArgsType>>(props: PropsType, getArgs?: (eventName: string) => ArgsType): EventProps<ArgsType, PropsType>; | ||
export default function makeEventProps<ArgsType, PropsType extends Props<ArgsType> = Props<ArgsType>>(props: PropsType, getArgs?: (eventName: string) => ArgsType): EventProps<ArgsType, PropsType>; | ||
export {}; |
@@ -187,2 +187,32 @@ "use strict"; | ||
}); | ||
(0, vitest_1.it)('should allow onClick handler with valid extra args to be passed with args explicitly typed', function () { | ||
var props = { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
onClick: function (event, args) { | ||
// Intentionally empty | ||
}, | ||
}; | ||
// @ts-expect-no-error | ||
(0, index_1.default)(props, function () { return 'hello'; }); | ||
}); | ||
(0, vitest_1.it)('should not allow onClick handler with invalid extra args to be passed with args explicitly typed', function () { | ||
var props = { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
onClick: function (event, args) { | ||
// Intentionally empty | ||
}, | ||
}; | ||
// @ts-expect-error-next-line | ||
(0, index_1.default)(props, function () { return 'hello'; }); | ||
}); | ||
(0, vitest_1.it)('should allow getArgs returning valid type to be passed with args explicitly typed', function () { | ||
var props = {}; | ||
// @ts-expect-no-error | ||
(0, index_1.default)(props, function () { return 'hello'; }); | ||
}); | ||
(0, vitest_1.it)('should not allow getArgs returning invalid type to be passed with args explicitly typed', function () { | ||
var props = {}; | ||
// @ts-expect-error-next-line | ||
(0, index_1.default)(props, function () { return 5; }); | ||
}); | ||
}); | ||
@@ -189,0 +219,0 @@ (0, vitest_1.describe)('allEvents', function () { |
@@ -35,3 +35,3 @@ export declare const clipboardEvents: readonly ["onCopy", "onCut", "onPaste"]; | ||
*/ | ||
export default function makeEventProps<ArgsType, PropsType extends Props<ArgsType>>(props: PropsType, getArgs?: (eventName: string) => ArgsType): EventProps<ArgsType, PropsType>; | ||
export default function makeEventProps<ArgsType, PropsType extends Props<ArgsType> = Props<ArgsType>>(props: PropsType, getArgs?: (eventName: string) => ArgsType): EventProps<ArgsType, PropsType>; | ||
export {}; |
@@ -162,2 +162,32 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
}); | ||
it('should allow onClick handler with valid extra args to be passed with args explicitly typed', function () { | ||
var props = { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
onClick: function (event, args) { | ||
// Intentionally empty | ||
}, | ||
}; | ||
// @ts-expect-no-error | ||
makeEventProps(props, function () { return 'hello'; }); | ||
}); | ||
it('should not allow onClick handler with invalid extra args to be passed with args explicitly typed', function () { | ||
var props = { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
onClick: function (event, args) { | ||
// Intentionally empty | ||
}, | ||
}; | ||
// @ts-expect-error-next-line | ||
makeEventProps(props, function () { return 'hello'; }); | ||
}); | ||
it('should allow getArgs returning valid type to be passed with args explicitly typed', function () { | ||
var props = {}; | ||
// @ts-expect-no-error | ||
makeEventProps(props, function () { return 'hello'; }); | ||
}); | ||
it('should not allow getArgs returning invalid type to be passed with args explicitly typed', function () { | ||
var props = {}; | ||
// @ts-expect-error-next-line | ||
makeEventProps(props, function () { return 5; }); | ||
}); | ||
}); | ||
@@ -164,0 +194,0 @@ describe('allEvents', function () { |
{ | ||
"name": "make-event-props", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Returns an object with on-event callback props curried with provided args.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -134,6 +134,6 @@ // As defined on the list of supported events: https://reactjs.org/docs/events.html | ||
*/ | ||
export default function makeEventProps<ArgsType, PropsType extends Props<ArgsType>>( | ||
props: PropsType, | ||
getArgs?: (eventName: string) => ArgsType, | ||
): EventProps<ArgsType, PropsType> { | ||
export default function makeEventProps< | ||
ArgsType, | ||
PropsType extends Props<ArgsType> = Props<ArgsType>, | ||
>(props: PropsType, getArgs?: (eventName: string) => ArgsType): EventProps<ArgsType, PropsType> { | ||
const eventProps: EventProps<ArgsType, PropsType> = {} as EventProps<ArgsType, PropsType>; | ||
@@ -140,0 +140,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50677
1078
0