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 error on Visual Studio Code #6

Open
christosf opened this issue Jan 19, 2024 · 9 comments
Open

Typescript error on Visual Studio Code #6

christosf opened this issue Jan 19, 2024 · 9 comments

Comments

@christosf
Copy link

christosf commented Jan 19, 2024

I get the following error in VS Code when trying to call the methods.
The code runs just fine.

import SimpleSchema from 'simpl-schema'
import { createMethod } from 'meteor/jam:method'
import { Contacts } from '../../database'
import { ContactsQueue } from '../collection'
import { ContactMethodTypesEnum } from '../enums'
import { increaseCounter } from '../../counters/methods'
import { CounterNamesEnum } from '../../counters/enums'

const insertContact = createMethod({
  name: 'contacts:insert',
  serverOnly: true,

  validate: new SimpleSchema({
    contact: {
      type: Object,
      blackbox: true
    }
  }).validator(),

  async run(params) {
    const { contact } = params

    const task = ContactsQueue.add(async() => {
      // Generate unique contact code.
      contact.code = `C${await increaseCounter({ name: CounterNamesEnum.CONTACTS })}`

      // Remove contact method if it is the same as the main phone number.
      contact.contactMethods.forEach((method, index) => {
        if (method.type === ContactMethodTypesEnum.PHONE && method.value === contact.phoneNumber) {
          contact.contactMethods.splice(index, 1)
        }
      })

      return { _id: await Contacts.insertAsync(contact), code: contact.code }
    })

    return task.promise
  }
})

export default insertContact

const { _id, code } = await insertContact({ contact })

This expression is not callable.
  Not all constituents of type '((...args?: any[]) => Promise<Promise<{ _id: string; code: any; }>>) | { pipe: (...fns: Function[]) => { (): any; (...args?: any[]): Promise<Promise<{ _id: string; code: any; }>>; }; }' are callable.
ts(2349)
@jamauro
Copy link
Owner

jamauro commented Jan 19, 2024

Hey, thanks for reporting. I just published a fix in v1.4.1

@christosf
Copy link
Author

Thanks for the quick response. I get a different error now. I get that it has to do with typescript, but I don't use typescript on my project.

Screenshot 2024-01-20 003016

@jamauro
Copy link
Owner

jamauro commented Jan 23, 2024

Ok, I made some changes to the typescript declarations and I think it's fixed. Can you do meteor remove jam:method and then then meteor add jam:[email protected]. After you confirm it's fixed, I can remove the beta tag. Thanks!

@christosf
Copy link
Author

christosf commented Jan 23, 2024

Ok, I made some changes to the typescript declarations and I think it's fixed. Can you do meteor remove jam:method and then then meteor add jam:[email protected]. After you confirm it's fixed, I can remove the beta tag. Thanks!

Screenshot 2024-01-23 091816

I get this error when trying to install the package. I had to install jam:method locally in the packages folder to work. The beta version you just released is not available in github to test if it working.

@jamauro
Copy link
Owner

jamauro commented Jan 23, 2024

Ok I uploaded the new release to GitHub so you can work with it locally.

The found multiple packages error is strange. Did you get it when you first tried to add the package? How about when you tried to add it with the explicit version number, i.e. meteor add jam:[email protected]?

If you’re still seeing it, then I'll have to report to the Meteor team. I think the only way to get rid of it is remove the local cache. On a Mac it would be like this, not sure about Windows:

1. sudo rm /usr/local/bin/meteor
2. rm -rf ~/.meteor
3. curl https://install.meteor.com/ | sh

@christosf
Copy link
Author

Ok I uploaded the new release to GitHub so you can work with it locally.

The issue is still there. Same error on the beta release

The found multiple packages error is strange. Did you get it when you first tried to add the package? How about when you tried to add it with the explicit version number, i.e. meteor add jam:[email protected]?

Yes the error was there when I first tried to add the package. Also tried with the explicit version number and same result.
I deleted the folder ./meteor/local inside my project and the error is gone now.

IMPORTANT
Trying to download your package from Chrome or add it through meteor add command leads to an error because the Windows Defender detects a virus. This is the result:

Screenshot 2024-01-24 090743

@jamauro
Copy link
Owner

jamauro commented Jan 24, 2024

Hmm I haven't been able to reproduce the issue. If you're getting the exact same error as before, then I think something might be cached within Visual Code Studio. Might be worth closing the project and reopening. If you're willing to point me to a GitHub repo, I may be able to investigate further. I can't really reproduce the code that you're using with the ContactsQueue.

Since you're not using typescript at all, you could adjust your config files so that the typescript compiler in Visual Code Studio doesn't check your js files or you can use // @ts-nocheck at the top of your file. More info here

Trying to download your package from Chrome or add it through meteor add command leads to an error because the Windows Defender detects a virus

Very strange. I have no idea what would cause that. If you have any ideas, let me know.

@christosf
Copy link
Author

christosf commented Jan 25, 2024

Hmm I haven't been able to reproduce the issue.

I found out that this error occurs when the extension Vue Language Features (Volar) is installed, which is the official extension from vuejs.org.

Thank you

@christosf
Copy link
Author

Property 'updated' does not exist on type '{ updated: boolean; } | { pipe: (...fns: Function[]) => (...args?: any[]) => Promise<Promise<{ updated: boolean; }>>; }'.

i would suspect the problem is somewhere around this part?

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