-
Notifications
You must be signed in to change notification settings - Fork 0
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
Expected Output File #19
Comments
Some QuestionsName of Field and MethodThere is a conflict between the class filed name and the class method name if we want to implement the The code structure is like this: class Color extends BaseObject {
constructor(private field_arg?: { field: string, type: "quantitative" | "ordinal" }, private value_arg?: string) {
super();
init(this);
}
field(field: string, type: "quantitative" | "ordinal") {
this.field_arg = { field, type };
}
value(value: string) {
this.value_arg = value;
}
} The output json will be: "encode_arg": {
"x_arg": { "field_arg": "meters", "type_arg": "quantitative" },
"y_arg": { "field_arg": "meters", "type_arg": "quantitative" },
"color_arg": { "value_arg": "green" }
} Now I remove those FieldDefAlso as for constructor(private field?: { field: string, type: "quantitative" | "ordinal" }) or interface FieldDef {
field: string
type: "quantitative" | "ordinal"
}
constructor(private field?: FieldDef) I now use the upper one, but when the type become more complicated maybe the second one is better. PositionDefBelow these ones, which should we provide? // whether to have position()
x.position().field("height", "quantitative")
or
x.field("height", "quantitative")
or
x("height", "quantitative") // how to pass fieldDef
x.field("height", "quantitative")
or
x.field({"height", "quantitative"})
or
x.field({"field": "height", "type": "quantitative"}) The input is interface FieldDef {
field: string
type: "quantitative" | "ordinal"
}
type PositionDef = FieldDef;
interface Encoding {
x?: PositionDef;
y?: PositionDef;
color?: ColorDef;
} Specconst spec = vl.spec().mark().data().encode()
or
const spec = vl.spec(vl.mark(), vl.data(), vl.encode())
or
const spec = vl.mark().data().encode |
To solve the naming collision, you might want to make the members private. You can just signal that they are private with |
Created the expected output file using a BaseObject and method chaining: https://github.com/cmudig/apigen/blob/structureCleaning/GeneratedFiles/output.ts.
When run
it generated a json like this
The text was updated successfully, but these errors were encountered: