Skip to content

Consider property accesses in heritage clauses as type-space references #22746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2018

Conversation

weswigham
Copy link
Member

at least for calculating type reference directives.

Fixes #15487

…es for calculating type reference directives
@weswigham weswigham requested review from sandersn and rbuckton March 20, 2018 22:18
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 21, 2018

Wait, I don't understand; in an implements heritage clause, I would have assumed we'd parse out a type reference, not a property access.

@RyanCavanaugh
Copy link
Member

parseHeritageClause doesn't differentiate implements from extends; it always interprets the operands as expressions:

        function parseHeritageClause(): HeritageClause | undefined {
            const tok = token();
            if (tok === SyntaxKind.ExtendsKeyword || tok === SyntaxKind.ImplementsKeyword) {
                const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
                node.token = tok;
                nextToken();
                node.types = parseDelimitedList(ParsingContext.HeritageClauseElement, parseExpressionWithTypeArguments);
                return finishNode(node);
            }

            return undefined;
        }

e.g. class C implements {} { } is a semantic error, not a syntax error

@weswigham
Copy link
Member Author

weswigham commented Mar 21, 2018

Yeah - it'd be kinda odd to parse them differently (it'd make handling them a pain, at least, since you'd need both type-space and value-space codepaths for everything syntactically heritage-clause related).

@weswigham weswigham merged commit 3acafe5 into microsoft:master Mar 29, 2018
@weswigham weswigham deleted the namespace-dep-types-ref branch March 29, 2018 20:51
@azz
Copy link

azz commented Mar 30, 2018

Thanks for the fix! Does this change also fix #15488?

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
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.

5 participants