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

Latest release breaks some type imports #149

Closed
codinronan opened this issue Oct 19, 2023 · 5 comments · Fixed by #161
Closed

Latest release breaks some type imports #149

codinronan opened this issue Oct 19, 2023 · 5 comments · Fixed by #161
Assignees
Labels
bug Something isn't working makerx

Comments

@codinronan
Copy link

Release version: 4.0.0

What I'm trying to do:

import { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec';

Last version this worked with: 2.3.3 (I did not try the 3.x releases)

Error message received by webpack bundler using TSC as its build tool, this actually looks like an eslint error though so it's not even getting to the bundler:

image

And in fact I see the same error in VSCode, although the path is getting rewritten to @algorandfoundation/algokit-utils/types/types/app-spec I believe due to the typesVersions key in this project's package.json

What I've tried:

  • Importing the direct types/types path, same error
  • Clearing my VSCode and node_modules cache, reinstalling node modules, & restarting VSCode

Not sure what changed, for now as a workaround I'm simply going to copy that file into my project as it's just being used for type safety in my appkit calls.

@Loedn Loedn added bug Something isn't working makerx labels Nov 12, 2023
@neilcampbell
Copy link
Contributor

@codinronan What version of TypeScript are you using? Also what are your TypeScript settings for both module and moduleResolution?

@neilcampbell
Copy link
Contributor

@codinronan Are you able to install 5.0.0 and see if that fixes the issue?

@codinronan
Copy link
Author

@neilcampbell apologies didn't see your messages!

TS version: 4.9.5 (need to check if I can pull this forward to 5.x)
module/Resolution values: ES2022, node

I'll give your 5.0.0 a try today :)

@codinronan
Copy link
Author

codinronan commented Nov 16, 2023

@neilcampbell seems I still have the issue. I have done the following:

  1. Updated @algorandfoundation/algokit-utils to 5.0.0
  2. Updated algosdk to 2.7.0
  3. Updated Typescript for the project to 5.2.2
  4. Removed our shim for AppSpec
  5. Replaced the import with the one from @algorandfoundation/algokit-utils: import { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec';

I still see the following behavior from VSCode, however when I Command+Click on the import it does successfully take me to the file where the type is exported, for some reason:
image

However, webpack (which is using tsc underneath, this is being built with serverless-bundle), does throw the following error:

image

I'm not sure what the solution is here honestly, this is arcane magic inside TS's import resolver I'd imagine... what changed from 2.3.3 to 4?

Edit: adding a bit more info for you:
This is on macOS Sonoma, late model MBP M2 chip, node 18.18

@codinronan
Copy link
Author

@neilcampbell ok I have fixed this, I also needed to upgrade:

  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/eslint-parser
  • eslint-plugin-import
  • eslint-import-resolver-typescript

To their latest versions, and now it works. Seems like later versions of TS resolve imports differently and the older linting versions didn't use the newer resolver.

Feel free to close, all good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working makerx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants