ca98am79 / connect-dynamodb

DynamoDB session store for Connect
http://ca98am79.github.com/connect-dynamodb/
MIT License
144 stars 66 forks source link

fix: `exports and export assignments are not permitted` and not use export default #84

Closed yutak23 closed 1 year ago

yutak23 commented 1 year ago

This PR will fix https://github.com/ca98am79/connect-dynamodb/issues/81.

I have made the following two modifications.

1、Remove declare module "connect-dynamodb" to eliminate exports and export assignments are not permitted error. 2、Change export default to export = to avoid the error This expression is not callable when developing with ES Module.

About 1

Declaration declare module "connect-dynamodb" is, in other words, a declaration that the type definition of connect-dynamodb is being done, which will be merged with the contents of index.d.ts (Module Augmentation).

Thus, index.d.ts will be equivalent to the following state.

export = ConnectDynamoDB;.
export default ConnectDynamoDB;.

The above is NG because of the mixed module system, and I believe that this PR change will unify them into export = ConnectDynamoDB;, so the error will no longer occur.

About 2

ES Module seems incompatible in CommonJS project with default export (see https://github.com/microsoft/TypeScript/issues/52086). To keep TypeScript types compatible with both CommonJS and ES Module, based on Module: Function and Default Exports, it is easy to use export =.

Although the difference appears large, the only part that has been changed is that interfaces and types, which were individually exported, are now defined in the namespace and the namespace is also exported.

yutak23 commented 1 year ago

@ca98am79

How about my suggestion here? I would appreciate your reply.

ca98am79 commented 1 year ago

thanks!