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 definitions #30

Closed
DmitryEfimenko opened this issue Jan 19, 2016 · 7 comments
Closed

TypeScript definitions #30

DmitryEfimenko opened this issue Jan 19, 2016 · 7 comments

Comments

@DmitryEfimenko
Copy link

I didn't see any TypeScript definitions so I cooked this quickly. Hopefully this can be developed further and added to docs:

/// <reference path="../meteor/meteor.d.ts" />

declare class ValidatedMethod<T> extends MeteorValidatedMethod.ValidatedMethod<T> { }

declare module MeteorValidatedMethod {
    export class ValidatedMethod<T> {
        constructor(options: ValidatedMethodOptions<T>);
        call(options?: T, cb?: (err, res)=> void): void;
    }

    interface ValidatedMethodOptions<T> {
        name: string;
        mixins?: Function[];
        validate: any;
        run(opts: T);
    }
}
@stubailo
Copy link
Contributor

What's the preferred way to ship typescript definitions? Should they be in the package source code somehow? How can I test that they are correct? Also, does this allow for mixins?

@DmitryEfimenko
Copy link
Author

There is a Github Repository: DefinitelyTyped where willing people upload definitions if they are missing. I believe definitions need to be maintained manually. Here they write a bit about requirements and Tests for uploaded definitions.

@stubailo
Copy link
Contributor

If you like, you can upload your definition there. Since I don't use typescript myself, I'd need someone who actually uses it frequently to maintain the definition.

@stubailo
Copy link
Contributor

I'm going to close this issue since there isn't really an actionable resolution.

@twastvedt
Copy link

I've added @DmitryEfimenko's typings to a repository here: https://github.com/twastvedt/typed-meteor-validated-method. I'm planning to add to them while I use this in a project, and then link to the registry when it's more complete. Pull requests are welcome, though, to speed up the process!

@twastvedt
Copy link

Also, since I had to figure this out, thought it was worth adding here:
You can use the repository for typings in a project, before it gets integrated into the registry, like this:

"meteor-validated-method": "github:twastvedt/typed-meteor-validated-method"

@stubailo
Copy link
Contributor

@twastvedt to make it easier for people to find in the future, would you mind sending a PR to the README to add directions for typescript?

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

3 participants