Skip to content

To fix #2583 - #44

Closed
York Yao (plantain-00) wants to merge 8 commits into
microsoft:masterfrom
plantain-00:i2583
Closed

York Yao (plantain-00) wants to merge 8 commits into
microsoft:masterfrom
plantain-00:i2583

Conversation

@plantain-00

Copy link
Copy Markdown
Contributor

microsoft/TypeScript#2583

It seems the constructor of interface URL is not generated, is this a bug?

@msftclas

Hi York Yao (@plantain-00), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@mhegazy

Copy link
Copy Markdown
Contributor

that is not the correct change. this adds a new type called URLConstructor. what you want is to enable URL to be called with new.

the desired output is:

interface URL{
    hash: string;
    search: string;
    pathname: string;
    port: string;
    hostname: string;
    host: string;
    password: string;
    username: string;
    protocol: string;
    origin: string;
    href: string;
}
declare var URL: {
    revokeObjectURL(url: string): void;
    createObjectURL(object: any, options?: ObjectURLOptions): string;
    new(url: string, base?: string): URL;
};

@plantain-00

Copy link
Copy Markdown
Contributor Author

Did I miss something? Locally I added these into overridingTypes.json or addedTypes.json, but nothings changes:

    {
        "kind": "constructor",
        "interface": "URL",
        "signatures": [
            "new (url: string, base?: string): URL"
        ]
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "hash",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "search",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "pathname",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "port",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "hostname",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "host",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "password",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "username",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "protocol",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "origin",
        "type": "number"
    },
    {
        "kind": "property",
        "interface": "URL",
        "name": "href",
        "type": "number"
    }

I also put these into overridingTypes.json, nothing changes too:

    {
        "kind": "interface",
        "name": "URL",
        "properties": [
            {
                "name": "hash",
                "type": "string"
            },
            {
                "name": "search",
                "type": "string"
            },
            {
                "name": "pathname",
                "type": "string"
            },
            {
                "name": "port",
                "type": "string"
            },
            {
                "name": "hostname",
                "type": "string"
            },
            {
                "name": "host",
                "type": "string"
            },
            {
                "name": "password",
                "type": "string"
            },
            {
                "name": "username",
                "type": "string"
            },
            {
                "name": "protocol",
                "type": "string"
            },
            {
                "name": "origin",
                "type": "string"
            },
            {
                "name": "href",
                "type": "string"
            }
        ]
    }

@mhegazy

Copy link
Copy Markdown
Contributor

Zhengbo Li (@zhengbli) ideas?

@zhengbli

Copy link
Copy Markdown

This is because an issue in the script. Because the URL interface is marked as a static interface in the XML file, the script doesn't pick up added constructors. I'll fix soon.

@zhengbli

Copy link
Copy Markdown

York Yao (@plantain-00) Now adding the content to addedTypes.json should do the right thing. Can you give it a try? Thanks

Conflicts:
	inputfiles/addedTypes.json
Conflicts:
	inputfiles/addedTypes.json
	inputfiles/overridingTypes.json
	inputfiles/removedTypes.json
@plantain-00

Copy link
Copy Markdown
Contributor Author

The tests fails, but build.cmd works fine locally.

Also I have no idea how to change the type of variable URL to

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

I tried to add the following into addedTypes.json or overridingTypes.json, the result is it added it into all interfaces, or changed the URL property in interface Document:

{
        "kind": "property",
        "name": "URL",
        "type": "any"
    }

So need help.

Comment thread inputfiles/removedTypes.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be added on a new interface URLConstructor, and var URL: URLConstructor

@plantain-00

Copy link
Copy Markdown
Contributor Author

Error appears when run npm install in Typescript. See the last build: https://ci.appveyor.com/project/zhengbli/tsjs-lib-generator/build/1.0.78-oncrkjps .
The message is:

npm ERR! peerinvalid Peer tslint@3.3.0-dev.1 wants typescript@>=1.7.3 || >=1.7.0-dev.20151003 || >=1.8.0-dev

@mhegazy

Copy link
Copy Markdown
Contributor

thanks. Vladimir Matveev (@vladima) is fixing this.

@plantain-00

Copy link
Copy Markdown
Contributor Author

Can not rerun the failed build, so restart a new one at #58

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

Successfully merging this pull request may close these issues.

4 participants