You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// first, judge whether path is accessable to all type.
20967
20984
// second, use expression to filter correct types
20968
20985
// third, return filtered types.
20969
20986
20970
20987
// return one non-negative number if match
20971
-
function getTypeDepthIfMatch(expression: Expression, type: Type): number {
20988
+
// type(Type) a.b.c
20989
+
// reference(Node) a.b.c
20990
+
// expression(Node) a.b.c?.d.e
20991
+
// I think type(Type) is better than reference(Node), but it meets some conditions, especially when expression contians optional chain. a?.b would add undefined to b and it is not b. maybe we could use isTypeSubtypeOf? would this meet some other strange condition?
20992
+
//
20993
+
function getTypeDepthIfMatch(expression: Expression, _type: Type): number {
// If expression is a.b["c"].d, the result would be ["b","c","d"]
21006
21031
// NOTE: If element expression is not known in compile progress like a.b[f()].d, the result would be undefined
21007
21032
// //NOTE: this function need improvement, ElementAccessExpression argument might could be known in compile time, like "1"+"2", we should check "12" in the path, but how to get the value?
21008
21033
// if given depth, the array.length would be the length. --- this property need have pre-knowledge of expression.
21009
-
function getPropertyPathsOfAccessExpression(expressionOri: AccessExpression, depth?: number): __String[] | undefined {
21034
+
function getPropertyPathsOfAccessExpression(expressionOri: AccessExpression, depth: number): __String[] | undefined {
21010
21035
const properties = [];
21011
21036
let exprTmp: LeftHandSideExpression = expressionOri;
21012
21037
let propName: __String;
@@ -21051,35 +21076,14 @@ namespace ts {
21051
21076
}
21052
21077
return result;
21053
21078
}
21054
-
// is it must be ObjectType? For it is not primitive type?
21055
-
let currentSymbol = nonUntionType.symbol;
21056
21079
21057
-
function tryGetPropertySymbolFromSymbol(s: Symbol, propertyName: __String) {
21058
-
if (s.flags & SymbolFlags.Interface) {
21059
-
return s.members?.get(propertyName);
21060
-
}
21061
-
if (s.flags & SymbolFlags.Property) {
21062
-
if (s.valueDeclaration.kind === SyntaxKind.PropertySignature) {
// if it is not last path, and is union or intersection, do not deal with this condition now.
21093
-
// this could be improved, if union and all types has the property, it could go on. But it is further concerned.
21094
-
if (!(type.flags & TypeFlags.Primitive) && (type.flags & TypeFlags.Union || type.flags & TypeFlags.Intersection)) { // this could be improved, if union and all types has the property, it could go on.
21095
-
break;
21096
-
}
21097
-
currentSymbol = nextSymbol;
21098
-
i = i + 1;
21096
+
curType = type;
21099
21097
}
21098
+
21100
21099
return result;
21101
21100
}
21102
21101
21103
-
// for now, TypeOfExpression is like ```typeof a.b.c.e```, need this to remove typeof.
0 commit comments