Skip to content

Commit 9baec06

Browse files
committed
test: fix typescript error
1 parent 73a55a4 commit 9baec06

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
22
// https://github.com/testing-library/jest-native/issues/46#issuecomment-748674706
33
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
4+
globals: {
5+
__DEV__: 'development',
6+
},
47
};

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type WizardValues = {
3434
isFirstStep: boolean;
3535
/** Indicate if the current step is the last step (aka no next step) */
3636
isLastStep: boolean;
37-
} | null;
37+
};
3838

3939
/** Console log levels */
4040
export type LogLevel = 'info' | 'error' | 'warn';

src/useWizard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22

3+
import { WizardValues } from './types';
34
import WizardContext from './wizardContext';
45

56
const useWizard = () => {
@@ -8,7 +9,7 @@ const useWizard = () => {
89
if (!context && __DEV__) {
910
throw Error('Wrap your step with `Wizard`');
1011
} else {
11-
return context;
12+
return context as WizardValues;
1213
}
1314
};
1415

src/wizard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ const Wizard: React.FC<WizardProps> = React.memo(
7979
logger.log('warn', 'An invalid startIndex is passed to <Wizard>');
8080
}
8181
// Invalid header element
82-
if (!React.isValidElement(header)) {
82+
if (header && !React.isValidElement(header)) {
8383
logger.log('error', 'Invalid header passed to <Wizard>');
8484
}
8585
// Invalid footer element
86-
if (!React.isValidElement(footer)) {
86+
if (footer && !React.isValidElement(footer)) {
8787
logger.log('error', 'Invalid footer passed to <Wizard>');
8888
}
8989
}

src/wizardContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22

33
import { WizardValues } from './types';
44

5-
const WizardContext = React.createContext<WizardValues>(null);
5+
const WizardContext = React.createContext<WizardValues | null>(null);
66
WizardContext.displayName = 'WizardContext';
77

88
export default WizardContext;

0 commit comments

Comments
 (0)