Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript issue after types change in 3.1.0 #394

Open
jekh opened this issue Nov 2, 2023 · 5 comments
Open

Typescript issue after types change in 3.1.0 #394

jekh opened this issue Nov 2, 2023 · 5 comments

Comments

@jekh
Copy link

jekh commented Nov 2, 2023

The types update in 3.1.0 appears to have caused an issue when importing and using Anvil in a typescript project, at least when using ESM.

In 3.1.0 (but not 3.0.1), typescript appears to think Anvil is a namespace, and doesn't recognize it as a class.
image

This expression is not constructable.
  Type 'typeof import("file:///node_modules/@anvilco/anvil/types/src/index")' has no construct signatures.

The issue appears to occur because of this change in index.d.ts from export = Anvil to export default Anvil. Manually changing that single line back appears to fix the type error.

I'm not totally sure why that change would cause this issue, or what the implications of it are. Only that it does seem to be the culprit!

@newhouse
Copy link
Contributor

newhouse commented Nov 7, 2023

Hi @jekh we'll have a look. Is this blocking you right now, or is it just an annoyance?

1 similar comment
@newhouse
Copy link
Contributor

newhouse commented Nov 7, 2023

Hi @jekh we'll have a look. Is this blocking you right now, or is it just an annoyance?

@jekh
Copy link
Author

jekh commented Dec 9, 2023

Hi @jekh we'll have a look. Is this blocking you right now, or is it just an annoyance?

It does block us from upgrading, yes, since it won't compile.

@newhouse
Copy link
Contributor

@jekh

Can you try changing your import to something like this:

import Anvil from '@anvilco/anvil/dist/index.js'

const client = new Anvil({...})
...

I was able to get TSC to understand the type that way and successfully compile. We will fix the root problem at some point, but I think for now this is a good workaround.

Let me know if this works!

@newhouse
Copy link
Contributor

@jekh did that work for you and allow you to upgrade?

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

No branches or pull requests

2 participants