-
Notifications
You must be signed in to change notification settings - Fork 55
Intersection Type #1603
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
base: v1
Are you sure you want to change the base?
Intersection Type #1603
Conversation
…n and using union type in BRS mode
| } | ||
| let rightParen = this.advance(); | ||
|
|
||
| let rightParen = this.consume( |
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 has been a bug a for a while? If the token was not ) it would just assume it was. :)
| expressionsWithOperator.push({ expression: expr }); | ||
|
|
||
| // handle expressions with order of operations - first "and", then "or" | ||
| const combineExpressions = (opToken: TokenKind) => { |
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.
Potentially there is a better way of doing this...
This algorithm just gets a list of <type> <operator?>, and then first loops through it to combine all ands into binary expressions, then again to combine all ors
| if (this.match(TokenKind.LeftCurlyBrace)) { | ||
| expr = this.inlineInterface(); | ||
| } else if (this.match(TokenKind.LeftParen)) { | ||
| let left = this.previous(); |
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 type expression is a GroupingExpxression, eg. (integer or float)
| getSymbolType: (innerName: string, innerOptions: GetTypeOptions) => { | ||
| const referenceTypeInnerMemberTypes = this.getMemberTypeFromInnerTypes(name, options); | ||
| if (!innerTypesMemberTypes || innerTypesMemberTypes.includes(undefined)) { | ||
| if (!referenceTypeInnerMemberTypes || referenceTypeInnerMemberTypes.includes(undefined)) { |
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.
Fixes typo in code.. fixed an issue, but I can't remember exactly what ...
| } | ||
| return this.isTypeCompatible(targetType) && targetType.isTypeCompatible(this); | ||
|
|
||
| if (this.types.length !== targetType.types.length) { |
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.
More exact check for wquality
Adds
IntersectionTypemodelled after TypeScript's intersection typesIntersectionType<type> and <type>(type1 or type2) and (type3 or type4))type foo = myType1 or myType2 and myType3 or myType4=>myType1 or (myType2 and myType3) or myType4type MyKlassAA = MyKlass and roAssociativeArrayworks properly