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

Forward defined types not properly defined in TypeScript #633

Closed
pepone opened this issue Nov 14, 2019 · 0 comments
Closed

Forward defined types not properly defined in TypeScript #633

pepone opened this issue Nov 14, 2019 · 0 comments
Labels
Milestone

Comments

@pepone
Copy link
Member

pepone commented Nov 14, 2019

slice2js wrongly assumes that a forward defined type is defined in the file where the forward declaration is found.

slice2js needs to be aware where the actual definition for a type is when generating the TypeScript definitions, that is required in order to generate the corresponding import statements.

To solve this we will introduce a new metadata directive js:defined-in:<Path> where <Path> is the relative path to the Slice file containing the definition for the given type, the metadata applies to forward definitions.

// forward.ice
module Demo
{
["js:defined-in:point.ice"]
class Point;
}

// point.ice
module Demo
{
class Point
{
    int x;
    int y;
};
}

// line.ice
#include <forward.ice>

module Demo
{
class Line
{
    Point x;
    Point y;
}
}

The generated code will correctly import the defined-in file, instead of the file containing the forward declaration:

import * as iceNS0 from "ice"
import * as iceNS1 from "./point"

export namespace Demo
{
    class Line extends iceNS0.Ice.Value
    {
        /**
         * One-shot constructor to initialize all data members.
         */
        constructor(x?:iceNS1.Demo.Point, y?:iceNS1.Demo.Point);
        x:iceNS1.Demo.Point;
        y:iceNS1.Demo.Point;
    }
}
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

1 participant