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

URL is missing from Window interface #3753

Closed
xtuc opened this issue Jul 6, 2015 · 5 comments
Closed

URL is missing from Window interface #3753

xtuc opened this issue Jul 6, 2015 · 5 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

@xtuc
Copy link

xtuc commented Jul 6, 2015

From PR #3741

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Jul 6, 2015
@mhegazy mhegazy added this to the TypeScript 1.6 milestone Jul 6, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jul 6, 2015

@zhengbli can you take a look

@mhegazy mhegazy changed the title Error TS2339: Property 'URL' does not exist on type 'Window'. URL is missing from Window interface Jul 6, 2015
@xtuc
Copy link
Author

xtuc commented Jul 6, 2015

I'm trying to help but that's the only thing I can do. The Window Interface is in the dom.generated.d.ts source file: https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L11848. I can't find the way to create the URL object.

@zhengbli
Copy link
Contributor

zhengbli commented Jul 7, 2015

According to https://developer.mozilla.org/en-US/docs/Web/API/Window/URL:

It is good practice to call the URL constructor instead of using this property.

we should add a constructor for interface URL too. It may look like this:

interface URL {
    createObjectURL(object: any, options?: ObjectURLOptions): string;
    revokeObjectURL(url: string): void;
}

declare var URL: {
    prototype: URL;
    new(): URL;
}

Then for window, add:

interface window ... {
    ...
    URL: URL 
    ...
}

@xtuc
Copy link
Author

xtuc commented Jul 7, 2015

The URL interface is already created: https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L10773-L10776 but it isn't instantiated.

@zhengbli
Copy link
Contributor

zhengbli commented Jul 7, 2015

Actually after trying out on various browsers, we found that the constructor of interface URL is not supported in both IE and Spartan. Therefore I think it is safer now to just add the property to window without changing the URL interface.

@zhengbli zhengbli added the Fixed A PR has been merged for this issue label Jul 10, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

3 participants