Skip to content

Commit 6772043

Browse files
authored
Merge pull request #60 from gnsharma/main
fix: support providing props to NiceModal.create as interface without…
2 parents 111671c + d34731a commit 6772043

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,26 @@ module.exports = {
1515
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
1616
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
1717
},
18+
overrides: [
19+
{
20+
// For react component files, we want to allow types of the form `type Props = {}`
21+
// as Props is guaranteed to be an object by React. Without overriding this rule,
22+
// we would need to extend the Props generic from Record<string, unknown>
23+
// which causes issues when consumer props are defined as interface without an index signature.
24+
// Refer to react part of the comment for more details.
25+
// https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492
26+
excludedFiles: "src/*.tsx",
27+
rules: {
28+
"@typescript-eslint/ban-types": [
29+
"error",
30+
{
31+
extendDefaults: true,
32+
types: {
33+
"{}": false,
34+
},
35+
},
36+
],
37+
},
38+
},
39+
],
1840
};

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export function useModal(modal?: any, args?: any): any {
346346
resolveHide,
347347
};
348348
}
349-
export const create = <P extends Record<string, unknown>>(
349+
export const create = <P extends {}>(
350350
Comp: React.ComponentType<P>,
351351
): React.FC<P & NiceModalHocProps> => {
352352
return ({ defaultVisible, keepMounted, id, ...props }) => {

0 commit comments

Comments
 (0)