Socket
Socket
Sign inDemoInstall

make-event-props

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-event-props - npm Package Compare versions

Comparing version 1.4.3 to 1.4.4

2

dist/cjs/index.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc