in src/powerquery-parser/language/type/typeUtils/nameOf.ts [8:63]
export function nameOf(type: Type.TPowerQueryType): string {
if (type.kind === Type.TypeKind.Null) {
return "null";
}
switch (type.maybeExtendedKind) {
case Type.ExtendedTypeKind.NumberLiteral:
case Type.ExtendedTypeKind.TextLiteral:
return prefixNullableIfRequired(type, `${type.literal}`);
case Type.ExtendedTypeKind.AnyUnion:
return type.unionedTypePairs.map((subtype: Type.TPowerQueryType) => nameOf(subtype)).join(" | ");
case Type.ExtendedTypeKind.DefinedFunction:
return prefixNullableIfRequired(type, nameOfFunctionSignature(type, true));
case Type.ExtendedTypeKind.DefinedList:
return prefixNullableIfRequired(type, `{${nameOfIterable(type.elements)}}`);
case Type.ExtendedTypeKind.DefinedListType:
return prefixNullableIfRequired(type, `type {${nameOfIterable(type.itemTypes)}}`);
case Type.ExtendedTypeKind.DefinedRecord:
return prefixNullableIfRequired(type, nameOfFieldSpecificationList(type));
case Type.ExtendedTypeKind.DefinedTable:
return prefixNullableIfRequired(type, `table ${nameOfFieldSpecificationList(type)}`);
case Type.ExtendedTypeKind.FunctionType:
return prefixNullableIfRequired(type, `type function ${nameOfFunctionSignature(type, false)}`);
case Type.ExtendedTypeKind.ListType:
return prefixNullableIfRequired(type, `type {${nameOf(type.itemType)}}`);
case Type.ExtendedTypeKind.LogicalLiteral:
return prefixNullableIfRequired(type, `${type.normalizedLiteral}`);
case Type.ExtendedTypeKind.PrimaryPrimitiveType:
return prefixNullableIfRequired(type, `type ${nameOf(type.primitiveType)}`);
case Type.ExtendedTypeKind.RecordType:
return prefixNullableIfRequired(type, `type ${nameOfFieldSpecificationList(type)}`);
case Type.ExtendedTypeKind.TableType:
return prefixNullableIfRequired(type, `type table ${nameOfFieldSpecificationList(type)}`);
case Type.ExtendedTypeKind.TableTypePrimaryExpression:
return prefixNullableIfRequired(type, `type table ${nameOf(type.primaryExpression)}`);
case undefined:
return prefixNullableIfRequired(type, nameOfTypeKind(type.kind));
default:
throw Assert.isNever(type);
}
}