From 8a08ac4d85156dca7712d758b3ea737375948f52 Mon Sep 17 00:00:00 2001 From: Tony Pinkevych Date: Sun, 2 Jun 2024 23:55:34 +0200 Subject: [PATCH] chore: handle null pointer in instances (#40) * chore: handle null pointer in instances * chore: update test --- src/index.test.ts | 4 +++- src/index.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.test.ts b/src/index.test.ts index e4b4eae..61c40d2 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -422,6 +422,8 @@ describe('mapEntityInstanceProperties', () => { nodeId: 'some-node-id', } ) - ).rejects.toThrow() + ).resolves.toEqual({ + mainNodeComponentId: '', + }) }) }) diff --git a/src/index.ts b/src/index.ts index 8716bf2..26a0951 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 {