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

Support for typescript definitions #200

Closed
GaikwadPratik opened this issue Mar 21, 2019 · 8 comments
Closed

Support for typescript definitions #200

GaikwadPratik opened this issue Mar 21, 2019 · 8 comments
Labels

Comments

@GaikwadPratik
Copy link

Why don't you add typescript definitions in the package? I mean there is one created https://www.npmjs.com/package/@types/xmlbuilder by @wallymathieu. But those are not updated for quiet a long time. It would be easier to maintain them in the project.

@oozcitak
Copy link
Owner

Will do. Thanks. 🥂

@GaikwadPratik
Copy link
Author

If you are okay, without any objections from @wallymathieu, I can import existing ones for quick resolution in a PR. I am sort of blocked because of them. As is I have created a PR DefinitelyTyped/DefinitelyTyped#34084 for 782540c. Would be easier for any new consumer to get going.

@wallymathieu
Copy link

Are there named parameters in typescript nowadays?

@oozcitak
Copy link
Owner

@GaikwadPratik a PR from existing definitions would be much appreciated if @wallymathieu agrees. I can then just package the types with the library.

@wallymathieu
Copy link

I think it makes more sense to have the types in the package. If you could look at the PR to tell me if it's ok? I'm away from computers for a few days so won't be able to verify the PR.

@oozcitak
Copy link
Owner

oozcitak commented Mar 22, 2019

XMLCreateOptions looks good in the PR.

We need to add an options argument to XMLWriter because of b6c2503:

interface XMLWriter {
    [x: string]: ((e: XMLElementOrXMLNode, options: WriterOptions, level?: number) => void);
}

where WriterOptions is:

interface WriterOptions {
    pretty?: boolean;
    indent?: string;
    newline?: string;
    offset?: number;
    allowEmpty?: boolean;
    dontPrettyTextNodes?: boolean;
    spaceBeforeSlash?: string | boolean;
    user? :any;
    state?: WriterState;
}

and WriterState is:

enum WriterState {
    None = 0,
    OpenTag = 1,
    InsideTag = 2,
    CloseTag = 3
}

If you're in a hurry you can just add options as any, and I can fix it later.

This should make the types mostly compatible with the current release, I can add the rest of the changes on top of this PR.

@GaikwadPratik
Copy link
Author

@oozcitak I have added the WriteOptions as indicated above in the #201. Please have a look.

@oozcitak
Copy link
Owner

Perfect thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants