Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee7e9fc

Browse filesBrowse files
author
Arthur Ozga
committed
handle todo's
1 parent 8915cb9 commit ee7e9fc
Copy full SHA for ee7e9fc

1 file changed

+15-20Lines changed: 15 additions & 20 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+15-20Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ namespace ts {
22572257
return createKeywordTypeNode(SyntaxKind.BooleanKeyword);
22582258
}
22592259
if (type.flags & TypeFlags.Enum) {
2260-
const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2260+
const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
22612261
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
22622262
}
22632263
if (type.flags & (TypeFlags.StringLiteral)) {
@@ -2270,7 +2270,7 @@ namespace ts {
22702270
return (<IntrinsicType>type).intrinsicName === "true" ? createTrue() : createFalse();
22712271
}
22722272
if (type.flags & TypeFlags.EnumLiteral) {
2273-
const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2273+
const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
22742274
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
22752275
}
22762276
if (type.flags & TypeFlags.Void) {
@@ -2306,18 +2306,18 @@ namespace ts {
23062306
}
23072307
if (objectFlags & ObjectFlags.ClassOrInterface) {
23082308
Debug.assert(!!(type.flags & TypeFlags.Object));
2309-
const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2309+
const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
23102310
// TODO(aozgaa): handle type arguments.
23112311
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
23122312
}
23132313
if (type.flags & TypeFlags.TypeParameter) {
2314-
const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2314+
const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
23152315
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
23162316
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
23172317
}
23182318

23192319
if (checkAlias && type.aliasSymbol) {
2320-
const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2320+
const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
23212321
const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments);
23222322
return createTypeReferenceNode(name, typeArgumentNodes);
23232323
}
@@ -2381,7 +2381,7 @@ namespace ts {
23812381
const typeAlias = getTypeAliasForTypeLiteral(type);
23822382
if (typeAlias) {
23832383
// The specified symbol flags need to be reinterpreted as type flags
2384-
const entityName = symbolToName(typeAlias, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2384+
const entityName = symbolToName(typeAlias, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
23852385
return createTypeReferenceNode(entityName, /*typeArguments*/ undefined);
23862386
}
23872387
else {
@@ -2452,7 +2452,7 @@ namespace ts {
24522452
function createTypeQueryNodeFromType(type: Type) {
24532453
const symbol = type.symbol;
24542454
if (symbol) {
2455-
const entityName = symbolToName(symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags);
2455+
const entityName = symbolToName(symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags);
24562456
return createTypeQueryNode(entityName);
24572457
}
24582458
}
@@ -2482,7 +2482,7 @@ namespace ts {
24822482
// When type parameters are their own type arguments for the whole group (i.e. we have
24832483
// the default outer type arguments), we don't show the group.
24842484
if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) {
2485-
const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*mustBeIdentifier*/ true, flags);
2485+
const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*expectsIdentifier*/ true, flags);
24862486
if (!qualifiedName) {
24872487
qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined);
24882488
}
@@ -2495,7 +2495,7 @@ namespace ts {
24952495
}
24962496
}
24972497
let entityName: EntityName = undefined;
2498-
const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags);
2498+
const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags);
24992499
if (qualifiedName) {
25002500
Debug.assert(!qualifiedName.right);
25012501
qualifiedName.right = nameIdentifier;
@@ -2606,7 +2606,7 @@ namespace ts {
26062606
const constraintNode = constraint && typeToTypeNodeHelper(constraint, enclosingDeclaration, flags);
26072607
const defaultParameter = getDefaultFromTypeParameter(type);
26082608
const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, enclosingDeclaration, flags);
2609-
const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags);
2609+
const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags);
26102610
return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
26112611
}
26122612

@@ -2627,30 +2627,26 @@ namespace ts {
26272627
return parameterNode;
26282628
}
26292629

2630-
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: true, flags: NodeBuilderFlags): Identifier;
2631-
function symbolToName(symbol: Symbol, enclosingDeclaration: Node, mustBeIdentifier: false, flags: NodeBuilderFlags): EntityName;
2632-
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: boolean, flags: NodeBuilderFlags): EntityName {
2630+
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: true, flags: NodeBuilderFlags): Identifier;
2631+
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: false, flags: NodeBuilderFlags): EntityName;
2632+
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: boolean, flags: NodeBuilderFlags): EntityName {
26332633
let parentSymbol: Symbol;
26342634
let meaning: SymbolFlags;
26352635

2636-
// Get qualified name if the symbol is not a type parameter
2637-
// and there is an enclosing declaration.
2636+
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
26382637
let chain: Symbol[];
26392638
const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter;
26402639
if (!isTypeParameter && enclosingDeclaration) {
26412640
chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true);
2642-
// TODO(aozgaa): check whether type pointed to by symbol requires type arguments to be printed.
26432641
Debug.assert(chain && chain.length > 0);
26442642
}
26452643
else {
26462644
chain = [symbol];
26472645
}
26482646

26492647
parentSymbol = undefined;
2650-
if (mustBeIdentifier && chain.length !== 1) {
2648+
if (expectsIdentifier && chain.length !== 1) {
26512649
encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier);
2652-
// TODO(aozgaa): failing to get an identifier when we expect one generates an unprintable node.
2653-
// Should error handling be more severe?
26542650
}
26552651
return createEntityNameFromSymbolChain(chain, chain.length - 1);
26562652

@@ -2660,7 +2656,6 @@ namespace ts {
26602656
const symbol = chain[index];
26612657
let typeParameterString = "";
26622658
if (index > 0) {
2663-
// TODO(aozgaa): is the parentSymbol wrong?
26642659
const parentSymbol = chain[index - 1];
26652660
let typeParameters: TypeParameter[];
26662661
if (getCheckFlags(symbol) & CheckFlags.Instantiated) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.