Skip to content

Fix import with SyntheticDefaultImports enabled#525

Merged
willem-delbare merged 2 commits intomainfrom
fix-synthetic-default-imports
Feb 12, 2025
Merged

Fix import with SyntheticDefaultImports enabled#525
willem-delbare merged 2 commits intomainfrom
fix-synthetic-default-imports

Conversation

@timokoessler
Copy link
Member

@timokoessler timokoessler commented Feb 10, 2025

In TypeScript you can write import Zen from '@aikidosec/firewall'; instead of import * as Zen from '@aikidosec/firewall'; if allowSyntheticDefaultImports is true.

This is also the case if esModuleInterop is set to true or if moduleResolution is set to bundler. See https://www.typescriptlang.org/tsconfig/#Interop_Constraints_6252 for more information.

But because we don't have a default export, at runtime you will get a crash like this:

import_firewall.default.addHonoMiddleware(app);
                        ^

TypeError: Cannot read properties of undefined (reading 'addHonoMiddleware')

@codecov
Copy link

codecov bot commented Feb 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@timokoessler timokoessler added the bug Something isn't working label Feb 10, 2025
@willem-delbare willem-delbare merged commit 02f25f1 into main Feb 12, 2025
11 checks passed
@willem-delbare willem-delbare deleted the fix-synthetic-default-imports branch February 12, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants