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
Add some modules/methods on webgme server module of type-defs #1788
base: master
Are you sure you want to change the base?
Conversation
Also add compile check of types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It mostly looks good to me. The only major issue I have is with export type Node = object;
(see the comment for more info).
@@ -1574,7 +1681,7 @@ declare namespace GmeClasses { | |||
* @return a dictionary where every the key of every entry is an absolute path of a set owner node. | |||
* The value of each entry is an array with the set names in which the node can be found as a member. | |||
*/ | |||
isMemberOf(node: Core.Node): Core.DataObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was Core.DataObject again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used wrongly throughout, but I think the intention was that it should represent the raw data that maps to a node. In other words the json objects stored in the monodb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*It was
typings/webgme.d.ts
Outdated
isReadOnly(): boolean; | ||
|
||
} | ||
export type Node = object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... This isn't great since it will result in the following code no longer throwing a type error:
const notANode = {};
const name = core.getAttribute(notANode, 'name')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point and I agree. Do you know if there is a way to define a type w/o specifying anything about it, but at the same time constrain anyone from passing anything that isn't of that type.
These Core.Node
s are only being returned from a core instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to work around it could be, but feels like there should be a better way..
export interface Node {
_internal: string;
}
This is still very much WIP, but might as well merge it in now.