Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3659,9 +3659,9 @@ namespace ts {
return containingNodeKind === SyntaxKind.Parameter;

case SyntaxKind.AsKeyword:
containingNodeKind === SyntaxKind.ImportSpecifier ||
containingNodeKind === SyntaxKind.ExportSpecifier ||
containingNodeKind === SyntaxKind.NamespaceImport;
return containingNodeKind === SyntaxKind.ImportSpecifier ||

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Would be nice if our linter told us about side effect-free statements!

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.

no-unused-expression - I'll add it.

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.

Actually we use this pattern in the checker to short-circuit error reporting. Also, apparently the services sources aren't linted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually we use this pattern in the checker to short-circuit error reporting

What's an example of this? Just curious

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.

// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That should be fine -- I want a rule that says every expression statement must contain a function call or assignment operation.

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.

@DanielRosenwasser Yeah I tried that rule and it wasn't usable with some of our patterns. And yeah services is not linted because I didn't turn on linting for any files I didn't clean up yet.

containingNodeKind === SyntaxKind.ExportSpecifier ||
containingNodeKind === SyntaxKind.NamespaceImport;

case SyntaxKind.ClassKeyword:
case SyntaxKind.EnumKeyword:
Expand Down Expand Up @@ -7811,6 +7811,7 @@ namespace ts {
case SyntaxKind.GreaterThanEqualsToken:
case SyntaxKind.InstanceOfKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.AsKeyword:
case SyntaxKind.EqualsEqualsToken:
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
Expand Down
8 changes: 8 additions & 0 deletions tests/cases/fourslash/asOperatorCompletion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />

//// type T = number;
//// var x;
//// var y = x as /**/

goTo.marker();
verify.completionListContains('T');