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

🐛 Bug Report: Not able to detect Appwrite Web SDK Types #54

Closed
2 tasks done
nimit2801 opened this issue May 7, 2023 · 9 comments · Fixed by appwrite/sdk-generator#653
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@nimit2801
Copy link

nimit2801 commented May 7, 2023

👟 Reproduction steps

Step 1: Initialize a Vite Project

yarn create vite my-vue-app --template vanilla-ts

Root Cause
Because "moduleResolution" is set to "bundler" in my tsconfig.json

Step 2: Install appwrite

yarn add appwrite

Step 3: Import App

import {Client} from "appwrite"

👍 Expected behavior

It should not throw an error!

👎 Actual Behavior

It throws an error

 Could not find a declaration file for module 'appwrite'. 'c:/Users/ASUS/OneDrive/Desktop/my-vue-app/node_modules/appwrite/dist/esm/sdk.js' implicitly has an 'any' type.
  There are types at 'c:/Users/ASUS/OneDrive/Desktop/my-vue-app/node_modules/appwrite/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'appwrite' library may need to update its package.json or typings.

image

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Linux

🧱 Your Environment

Nope!

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@nimit2801 nimit2801 added the bug Something isn't working label May 7, 2023
@stnguyen90
Copy link
Contributor

@nimit2801 thanks for raising this issue!

After googling a bit it seems like this might be a newer typescript config and we can get it to work if we update a few things in the sdk.

Some additional reference:

@nimit2801
Copy link
Author

Possible solution which worked for me

My tsconfig.json file has "moduleResolution": "bundler" and if I set it to "moduleResolution": "node" it works for me!

@stnguyen90
Copy link
Contributor

We should be able to fix the problem If we update the exports in our package.json to:

  "exports": {
    ".": {
      "import": "./dist/esm/sdk.js",
      "require": "./dist/cjs/sdk.js",
      "types": "./types/index.d.ts"
    },
    "./package.json": "./package.json"
  },

@nimit2801
Copy link
Author

Thought for food
gxmari007/vite-plugin-eslint#60
this solves

@nimit2801
Copy link
Author

We should be able to fix the problem If we update the exports in our package.json to:

  "exports": {
    ".": {
      "import": "./dist/esm/sdk.js",
      "require": "./dist/cjs/sdk.js",
      "types": "./types/index.d.ts"
    },
    "./package.json": "./package.json"
  },

Yup, exactly. Can I make a PR?

@subhojit-ghosh
Copy link

subhojit-ghosh commented May 27, 2023

Possible solution which worked for me

My tsconfig.json file has "moduleResolution": "bundler" and if I set it to "moduleResolution": "node" it works for me!

this is not working when I am trying to build the project. I am using Vitejs and react
image

@nimit2801
Copy link
Author

Possible solution which worked for me

My tsconfig.json file has "moduleResolution": "bundler" and if I set it to "moduleResolution": "node" it works for me!

this is not working when I am trying to build the project. I am using Vitejs and react image

Did you make the necessary changes? I suggested in the above solution.

Possible solution which worked for me

My tsconfig.json file has "moduleResolution": "bundler" and if I set it to "moduleResolution": "node" it works for me!

@colbyfayock
Copy link

colbyfayock commented Jul 25, 2023

still seeing this in a fresh vite react project - should this issue still be open?

image

is "moduleResolution": "node" the "right" solution? or a workaround? without knowing the total scope of that change, im wondering if it would be appropriate for all apps or if that might cause conflicts in some, but seems like it may be a package issue?

@stnguyen90
Copy link
Contributor

@colbyfayock

still seeing this in a fresh vite react project - should this issue still be open?

The fix will be in the next release of the SDK.

is "moduleResolution": "node" the "right" solution? or a workaround?

Both? The problem was the newer TS config is incompatible with our SDK.

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 a pull request may close this issue.

4 participants