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

What's the correct way to get URLSearchParams into my project? #12517

Closed
atrauzzi opened this issue Nov 27, 2016 · 9 comments
Closed

What's the correct way to get URLSearchParams into my project? #12517

atrauzzi opened this issue Nov 27, 2016 · 9 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue

Comments

@atrauzzi
Copy link

I have some code where I'd like to be able to build query strings. Unfortunately I can't seem to find a polyfill similar to what I'm currently doing with fetch.

Is there any correct way to get these newer standards into my typescript projects, along with any actual polyfill code to accompany my build?

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Nov 28, 2016
@RyanCavanaugh
Copy link
Member

As indicated in the template, this is not a support forum. Please ask questions on Stack Overflow or similar sites.

@atrauzzi
Copy link
Author

This is not a question or support request.

I'm looking for an implementation of URLSearchParams to use in my TypeScript projects. Similar to how you offer other libraries via the --lib flag.

@RyanCavanaugh
Copy link
Member

I don't understand what about that isn't a question. Are you saying there's a bug in TypeScript?

@mhegazy
Copy link
Contributor

mhegazy commented Nov 29, 2016

URLSearchParams is still an experimental feature. we do not add DOM libraries to the standard library at this stage to avoid breaking users in the future. that said, interfaces are interfaces, and do not need to be in lib.d.ts specifically. you would need to declare it:

declare class URLSearchParams {
    /** Constructor returning a URLSearchParams object. */
    constructor(init?: string| URLSearchParams);

    /**Appends a specified key/value pair as a new search parameter. */
    append(name: string, value: string): void

    /** Deletes the given search parameter, and its associated value, from the list of all search parameters. */
    delete(name: string): void; 

    /** Returns an iterator allowing to go through all key/value pairs contained in this object. */
    entries(): IterableIterator<[string, string]>;

    /** Returns the first value associated to the given search parameter. */
    get(name: string): string;

    /** Returns all the values association with a given search parameter. */
    getAll(name: string): string[];

    /** Returns a Boolean indicating if such a search parameter exists. */
    has(name: string): boolean;

    /** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
    keys(): IterableIterator<string>;

    /** Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. */
    set(name: string, value: string): void;

    /** Returns a string containg a query string suitable for use in a URL. */
    toString(): string;

    /** Returns an iterator allowing to go through all values of the key/ value pairs contained in this object. */
    values(): IterableIterator<string>;

     /** Iterator */
    [Symbol.iterator](): IterableIterator<number>;
}

@mhegazy
Copy link
Contributor

mhegazy commented Nov 30, 2016

Should be fixed by microsoft/TypeScript-DOM-lib-generator#167

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet and removed Question An issue which isn't directly actionable in code labels Dec 1, 2016
@mhegazy mhegazy added this to the TypeScript 2.2 milestone Dec 7, 2016
@donaldpipowitch
Copy link
Contributor

@mhegazy This doesn't seem to be fixed in 2.1.4. I see it has the 2.2 milestone now. Is it available in nightly?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 9, 2017

The fix is checked in the lib repo and needs to be ported in. We do them in patches; once it is in the nightly we will close the issue.

@donaldpipowitch
Copy link
Contributor

Thanks for the explanation.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 2, 2017
@zhengbli zhengbli removed the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Feb 3, 2017
@atrauzzi
Copy link
Author

atrauzzi commented Feb 4, 2017

Yay!

@microsoft microsoft locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

5 participants