-
Notifications
You must be signed in to change notification settings - Fork 106
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 errors (multiple) #567
Comments
Try installing |
FYI this is more of a general TypeScript usage question rather than one related to arangojs. I'd recommend trying out Visual Studio Code (free, lightweight and cross-platform) which has awesome TypeScript integration and makes it easy to catch and auto-fix these problems before even compiling once. |
I installed @types/node. The above typescript errors went away, except for the type Blob. No other package I've installed has required me to manually install various components. The type "Blob" is in the arangojs file referenced in the below error, which is the one that I meant to post in the issue. I can "fix" the problem by removing "Blob" as a type for the downloadService function signature response so that it is a Promise, but no idea where to get "blob" type imported. I have VS Code and have used for over a year - it does not automagically fix problems like this. Thanks for the suggestion though.
What do you suggest I do about this error if @types/node install doesn't fix? |
Hm... odd. Can you try setting I wonder why you're not getting similar issues with other libraries that use node built-in modules (and especially The I didn't mean to imply VSCode makes the errors go away by itself, but VSCode's autofix (light bulb) feature usually provides ways to solve these problems (e.g. suggesting missing type definitions or imports). |
Can you tell me what version of TypeScript you're using and paste your |
FYI, I tested the following: mkdir ts-demo
cd ts-demo
yarn init -y
yarn add --dev typescript @types/node
yarn add arangojs
yarn tsc --init
cat <<EOF > index.ts
import { Database } from "arangojs"
const db = new Database();
db.acquireHostList();
EOF
yarn tsc and it doesn't result in any errors. I also don't see any errors doing the same with typescript@2. EDIT: Omitting the EDIT2: Any library I can think of that would use built-in node modules (e.g. express) doesn't provide its own typings. Those libraries usually have |
Okay, looks like the best practice is hidden in this guide: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html ... and it's to add the typing as an explicit dependency. So I guess this is a bug after all. |
The fix for the missing If you can provide a way to reproduce the error concerning EDIT: Ideally we'd like to be able to provide separate typings for the browser and node versions of arangojs, but the overhead of allowing TS to use the DOM lib (the default) seems negligible compared to the effort required to maintain two separate versions with separate typings. |
@sshillyer I had to rewrite history a bit but the fix is now released as 6.6.0 on npm along with the changes to |
Sorry to resurrect this, I lost track of it as I was moved on to another project and we sidelined our project. I have created a minimal example project that recreates my problem: It involves only a couple of lines of code and only typescript and arangojs modules. I tried using @types/node in the example as well but also has the problems aforementioned. Open to ideas! Thanks |
Make sure to add I'll add a sentence about that to the README to help other users in the future. |
Trying to bootstrap a project with arangojs integration and getting errors trying to compile into typescript.
I ran in a new project 'npm install --save arangojs' then setup the below index.ts and tried running typscript compile 'tsc index.ts' and received multiple errors.
The code I'm executing is basically the sample from the tutorials.
contents of index.ts:
errors:
The text was updated successfully, but these errors were encountered: