The Wayback Machine - https://web.archive.org/web/20200917084145/https://github.com/microsoft/TypeScript/issues/40432
Skip to content
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

`as` keyword is missing in completion lists within function bodies #40432

Open
busyscout opened this issue Sep 8, 2020 · 4 comments · May be fixed by #40481
Open

`as` keyword is missing in completion lists within function bodies #40432

busyscout opened this issue Sep 8, 2020 · 4 comments · May be fixed by #40481

Comments

@busyscout
Copy link

@busyscout busyscout commented Sep 8, 2020

Try to write

const s = 1 as number;

The "as" keyword is missing in VS2019 intellisense suggestion list. TS version is 3.9. If you press space after "as", then "async" keyword is inserted.
TS AS

@DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Sep 8, 2020

Looks like this should have been fixed in 3.8. See #34814

Unable to reproduce the issue on my end. Is your project using the same version of TypeScript?

Microsoft Visual Studio Enterprise 2019
Version 16.5.2
VisualStudio.16.Release/16.5.2+29926.136
Microsoft .NET Framework
Version 4.8.03752

TypeScript Tools   16.0.20225.2001
TypeScript Tools for Microsoft Visual Studio

image

@busyscout
Copy link
Author

@busyscout busyscout commented Sep 10, 2020

Microsoft Visual Studio Professional 2019
Version 16.7.2
VisualStudio.16.Release/16.7.2+30413.136
TypeScript Tools 16.0.20702.2001

It depends on context.
To reproduce just create simple ts file with the following content

const x = 100 as number; //OK. as in suggestion list

function main() {
    const x = 100 as number; //WRONG. as is not in suggestion list
}

TS-AS-Correct
TS-AS-Wrong

@DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Sep 10, 2020

I think the logic for

function isFunctionLikeBodyKeyword(kind: SyntaxKind) {
return kind === SyntaxKind.AsyncKeyword
|| kind === SyntaxKind.AwaitKeyword
|| !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
is off.
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.1.1 milestone Sep 10, 2020
@DanielRosenwasser DanielRosenwasser changed the title AS Keyword Is Missing From Suggestion List In VS2019 `as` keyword is missing in completion lists within function bodies Sep 10, 2020
@DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Sep 10, 2020

I think this should be a matter of adding a test and making an exception like with async/await

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.