Skip to content

Commit

Permalink
fixed issue with isOfType handling of null values
Browse files Browse the repository at this point in the history
  • Loading branch information
Na'aman Hirschfeld authored and Na'aman Hirschfeld committed Jun 12, 2021
1 parent 2650b51 commit 2a3d967
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .idea/interfaceForge.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
[1.1.0]

- added required build args

[1.1.1]

- fix issue with handling of null values in isOfType helper
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export function isOfType<T>(
variable: unknown,
property: keyof T,
): variable is T {
return (variable as T)[property] !== undefined;
return !!variable && (variable as T)[property] !== undefined;
}
2 changes: 1 addition & 1 deletion tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ComplexObject {
describe('InterfaceFactory', () => {
const defaults: ComplexObject = {
name: 'testObject',
value: 0,
value: null,
};
describe('.build', () => {
it('builds correctly with defaults object literal', async () => {
Expand Down

0 comments on commit 2a3d967

Please sign in to comment.