Skip to content

Add typescript definitions#9

Open
orgads wants to merge 1 commit intomongoosejs:masterfrom
orgads:ts
Open

Add typescript definitions#9
orgads wants to merge 1 commit intomongoosejs:masterfrom
orgads:ts

Conversation

@orgads
Copy link
Copy Markdown
Contributor

@orgads orgads commented Feb 7, 2024

No description provided.

Copy link
Copy Markdown
Member

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, I had a few questions

Comment thread index.d.ts
@@ -0,0 +1,9 @@
import { Schema } from "mongoose";
declare namespace wrapCallback {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this declare namespace call about? Shouldn't we just have interface WrapCallbackOptions {} and just use that? And export default function wrapCallback()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but without the namespace I get the following error.

test.ts:1:31 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

1 import * as wrapCallback from '.';

test.ts is:

import * as wrapCallback from '.';

wrapCallback({} as any);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants