mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Support symbol kind for union properties
This commit is contained in:
@@ -92,7 +92,8 @@ module ts {
|
||||
getContextualType: getContextualType,
|
||||
getFullyQualifiedName: getFullyQualifiedName,
|
||||
getResolvedSignature: getResolvedSignature,
|
||||
getEnumMemberValue: getEnumMemberValue
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
getUnionTypesOfUnionProperty: getUnionTypesOfUnionProperty
|
||||
};
|
||||
|
||||
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||
@@ -1750,6 +1751,10 @@ module ts {
|
||||
return links.type;
|
||||
}
|
||||
|
||||
function getUnionTypesOfUnionProperty(symbol: Symbol): Type[] {
|
||||
return (symbol.flags & SymbolFlags.UnionProperty) ? getSymbolLinks(symbol).unionType.types : undefined;
|
||||
}
|
||||
|
||||
function getTypeOfSymbol(symbol: Symbol): Type {
|
||||
if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) {
|
||||
return getTypeOfVariableOrParameterOrProperty(symbol);
|
||||
@@ -3583,7 +3588,8 @@ module ts {
|
||||
}
|
||||
|
||||
function getBestCommonType(types: Type[], contextualType?: Type): Type {
|
||||
return contextualType && isSupertypeOfEach(contextualType, types) ? contextualType : getUnionType(types);
|
||||
return contextualType && isSupertypeOfEach(contextualType, types) ? contextualType : getUnionType(types);
|
||||
}
|
||||
|
||||
function isTypeOfObjectLiteral(type: Type): boolean {
|
||||
return (type.flags & TypeFlags.Anonymous) && type.symbol && (type.symbol.flags & SymbolFlags.ObjectLiteral) ? true : false;
|
||||
|
||||
@@ -657,6 +657,8 @@ module ts {
|
||||
getContextualType(node: Node): Type;
|
||||
getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
|
||||
getUnionTypesOfUnionProperty(symbol: Symbol): Type[];
|
||||
|
||||
// Returns the constant value of this enum member, or 'undefined' if the enum member has a
|
||||
// computed value.
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
|
||||
@@ -2284,8 +2284,16 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getConcreteSymbol(symbol: Symbol): Symbol {
|
||||
if (symbol.flags & SymbolFlags.UnionProperty) {
|
||||
var types = typeInfoResolver.getUnionTypesOfUnionProperty(symbol);
|
||||
symbol = typeInfoResolver.getPropertyOfType(types[0], symbol.name);
|
||||
}
|
||||
return typeInfoResolver.getRootSymbol(symbol);
|
||||
}
|
||||
|
||||
function getSymbolKind(symbol: Symbol): string {
|
||||
var flags = typeInfoResolver.getRootSymbol(symbol).getFlags();
|
||||
var flags = getConcreteSymbol(symbol).getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Module) return ScriptElementKind.moduleElement;
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
@@ -2344,6 +2352,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getSymbolModifiers(symbol: Symbol): string {
|
||||
symbol = getConcreteSymbol(symbol);
|
||||
return symbol && symbol.declarations && symbol.declarations.length > 0
|
||||
? getNodeModifiers(symbol.declarations[0])
|
||||
: ScriptElementKindModifier.none;
|
||||
|
||||
Reference in New Issue
Block a user