Skip to content

URLSearchParams should be iterable #15243

@zh99998

Description

@zh99998

TypeScript Version: 2.2.2

according to https://url.spec.whatwg.org/#urlsearchparams
URLSearchParams is iterable, but it is not iterable in typescript now.

this code failed to compile but run successful as plain JavaScript in google chrome.
Code

// A *self-contained* demonstration of the problem follows...
const params = new URLSearchParams()
params.set('k', 'v')
for(let [key, value] of params) {
    console.log(key, value)
}

Expected behavior:
compile successfully
Actual behavior:
error TS2488: Type must have a 'Symbol.iterator' method that returns an iterator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions