Skip to content

Commit

Permalink
chore: handle null pointer in instances (#40)
Browse files Browse the repository at this point in the history
* chore: handle null pointer in instances

* chore: update test
  • Loading branch information
tonypinkevych authored Jun 2, 2024
1 parent 6815602 commit 8a08ac4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ describe('mapEntityInstanceProperties', () => {
nodeId: 'some-node-id',
}
)
).rejects.toThrow()
).resolves.toEqual({
mainNodeComponentId: '',
})
})
})
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,13 @@ export const mapEntityInstanceProperties = async (
const mainComponent = await node.getMainComponentAsync()

if (mainComponent == null) {
throw new Error(
console.warn(
`Main component should NOT be null. Please check the Figma related code.
Node id "${node.id}", name "${node.name}"`
)
return {
mainNodeComponentId: '',
}
}

return {
Expand Down

0 comments on commit 8a08ac4

Please sign in to comment.