Skip to content

MissingDeclaration is only ever a Statement#23485

Merged
1 commit merged into
masterfrom
missing_declaration
Apr 18, 2018
Merged

MissingDeclaration is only ever a Statement#23485
1 commit merged into
masterfrom
missing_declaration

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 17, 2018

The only time we create one of these is in parseDeclarationWorker, which returns a Statement. In parseClassElement and parseTypeMember, we'll parse a property declaration if all we see is a name. In parseObjectLiteralElement we'll parse a shorthand property assignment.

@ghost ghost requested review from mhegazy and rbuckton April 17, 2018 21:06
@ghost ghost mentioned this pull request Apr 17, 2018
@ghost ghost force-pushed the missing_declaration branch from a391167 to b3583a0 Compare April 17, 2018 21:29
Comment thread src/compiler/utilities.ts
|| kind === SyntaxKind.SetAccessor
|| kind === SyntaxKind.IndexSignature
|| kind === SyntaxKind.SemicolonClassElement
|| kind === SyntaxKind.MissingDeclaration;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the parser can still add it in a class element context.. we have not changed the parser not to do that.. e.g. ; in a class body would be parsed as MissingDeclaration.

Copy link
Copy Markdown
Author

@ghost ghost Apr 17, 2018

Choose a reason for hiding this comment

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

Looks like that is a SemicolonClassElement:

import ts = require("typescript");
const sourceFile = ts.createSourceFile("foo.ts", "class C { ; }", ts.ScriptTarget.ESNext);
const member = (sourceFile.statements[0] as ts.ClassDeclaration).members[0];
console.log(ts.SyntaxKind[member.kind]); // SemicolonClassElement

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

u are right.. sorry about that.

@ghost ghost merged commit afde2b5 into master Apr 18, 2018
@ghost ghost deleted the missing_declaration branch April 18, 2018 14:56
@microsoft microsoft locked and limited conversation to collaborators Jul 30, 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.

2 participants