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

Use brand types to clear up confusion about entity name expressions#10013

Merged
9 commits merged into
mastermicrosoft/TypeScript:masterfrom
resolve_entity_namemicrosoft/TypeScript:resolve_entity_nameCopy head branch name to clipboard
Aug 11, 2016
Merged

Use brand types to clear up confusion about entity name expressions#10013
9 commits merged into
mastermicrosoft/TypeScript:masterfrom
resolve_entity_namemicrosoft/TypeScript:resolve_entity_nameCopy head branch name to clipboard

Conversation

@ghost

@ghost ghost commented Jul 28, 2016

Copy link
Copy Markdown

Fixes #4325.
This introduces the type EntityNameExpression to replace Expression used in a context where it must be an entity name (an identifier, or a property access where the LHS is an entity name).
This also helped to discover a bug where we treated exported property accesses as entity names even if the LHS wasn't propery.

@ghost ghost assigned sandersn Jul 28, 2016
@ghost ghost force-pushed the resolve_entity_name branch from e6ca44e to f763280 Compare July 28, 2016 20:09
Comment thread src/compiler/checker.ts
type = getTypeReferenceType(node, symbol);

links.resolvedSymbol = symbol;
links.resolvedType = type;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were duplicate lines just below these.

@ghost ghost force-pushed the resolve_entity_name branch from 9ed6146 to f9fd496 Compare July 29, 2016 15:12
Comment thread src/compiler/utilities.ts
node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node);
}

export function exportAssignmentIsAlias(node: ExportAssignment): boolean {

@sandersn sandersn Aug 2, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exportAssignmentIsAlias [](start = 20, length = 23)

it seems weird that there are 3 functions whose bodies are all just isEntityNameExpression(node.expression). If you express them as a single function, does any common name look at all good? #Closed

…he expression of each `ExpressionWithTypeArguments` is an `EntityNameExpression`.
Comment thread src/compiler/checker.ts Outdated
* Climbs up parents to an ExpressionWithTypeArguments, and returns its expression,
* but returns undefined if that expression is not an EntityNameExpression.
*/
function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined {

@sandersn sandersn Aug 2, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

climbToEntityNameOfExpressionWithTypeArguments [](start = 17, length = 46)

getEntityNameParent[OfExpressionWithTypeArguments]? (get...Parent is the usual pattern used rather than climbTo...)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one would also be simpler with recursion.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting the child of an ancestor (e.g. an aunt) which is an ExpressionWithTypeArguments. So it's more like getExpressionOfExpressionWithTypeArgumentsParent...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I missed that. Maybe move the .expression access to the caller? This is more like how it works with the rest of your new code post-commit 4 anyway.


In reply to: 73203379 [](ancestors = 73203379)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want to move .expression to the caller because climbToEntityNameOfExpressionWithTypeArguments is responsible for ensuring that .expression is a EntityNameExpression. Maybe it could just be named getEntityNameForExtendingInterface?

@sandersn

sandersn commented Aug 2, 2016

Copy link
Copy Markdown
Member

👍 once @vladima takes a look at the possible recursions, and once you decide whether to change the name for climbToEntity...

Comment thread src/compiler/checker.ts Outdated
* but returns undefined if that expression is not an EntityNameExpression.
*/
function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined {
for (; ; ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Use while (true)

@ghost ghost merged commit e900952 into master Aug 11, 2016
@ghost ghost deleted the resolve_entity_name branch August 11, 2016 16:59
@mhegazy

mhegazy commented Aug 17, 2016

Copy link
Copy Markdown
Contributor

I do not think this is not going to work for things that do not share the same symbol.. e.g.

class C {
    static B: number;
}
namespace C {
    export interface B { c: number }
}

export = C.B;

@ghost ghost mentioned this pull request Aug 18, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

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