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
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
6 changes: 4 additions & 2 deletions 6 src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ namespace FourSlashInterface {
export const keywords: readonly ExpectedCompletionEntryObject[] = keywordsWithUndefined.filter(k => k.name !== "undefined");

export const typeKeywords: readonly ExpectedCompletionEntryObject[] =
["false", "null", "true", "void", "any", "boolean", "keyof", "never", "readonly", "number", "object", "string", "symbol", "undefined", "unique", "unknown", "bigint"].map(keywordEntry);
["false", "null", "true", "void", "asserts", "any", "boolean", "keyof", "never", "readonly", "number", "object", "string", "symbol", "undefined", "unique", "unknown", "bigint"].map(keywordEntry);

const globalTypeDecls: readonly ExpectedCompletionEntryObject[] = [
interfaceEntry("Symbol"),
Expand Down Expand Up @@ -1058,7 +1058,7 @@ namespace FourSlashInterface {
}

export const classElementKeywords: readonly ExpectedCompletionEntryObject[] =
["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(keywordEntry);
["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(keywordEntry);

export const classElementInJsKeywords = getInJsKeywords(classElementKeywords);

Expand Down Expand Up @@ -1152,6 +1152,7 @@ namespace FourSlashInterface {
"let",
"package",
"yield",
"asserts",
"any",
"async",
"await",
Expand Down Expand Up @@ -1351,6 +1352,7 @@ namespace FourSlashInterface {
"let",
"package",
"yield",
"asserts",
"any",
"async",
"await",
Expand Down
1 change: 1 addition & 0 deletions 1 src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,7 @@ namespace ts.Completions {
case SyntaxKind.GetKeyword:
case SyntaxKind.SetKeyword:
case SyntaxKind.AsyncKeyword:
case SyntaxKind.DeclareKeyword:
return true;
default:
return isClassMemberModifier(kind);
Expand Down
1 change: 1 addition & 0 deletions 1 src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ namespace ts {

export const typeKeywords: readonly SyntaxKind[] = [
SyntaxKind.AnyKeyword,
SyntaxKind.AssertsKeyword,
SyntaxKind.BigIntKeyword,
SyntaxKind.BooleanKeyword,
SyntaxKind.FalseKeyword,
Expand Down
9 changes: 9 additions & 0 deletions 9 tests/cases/fourslash/completionAmbientPropertyDeclaration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />

//// class C {
//// /*1*/ declare property: number;
//// /*2*/
//// }

verify.completions({marker: "1", exact: completion.classElementKeywords, isNewIdentifierLocation: true});
verify.completions({marker: "2", exact: completion.classElementKeywords, isNewIdentifierLocation: true});
2 changes: 1 addition & 1 deletion 2 tests/cases/fourslash/completionEntryForClassMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ verify.completions(
"classThatStartedWritingIdentifierAfterPrivateModifier",
"classThatStartedWritingIdentifierAfterPrivateStaticModifier",
],
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(
name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
),
isNewIdentifierLocation: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ verify.completions(
{ marker: "0", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } },
{
marker: "1",
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(
name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
),
isNewIdentifierLocation: true,
Expand Down
11 changes: 11 additions & 0 deletions 11 tests/cases/fourslash/completionTypeGuard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />

//// const x = "str";
//// function assert1(condition: any, msg?: string): /*1*/ ;
//// function assert2(condition: any, msg?: string): /*2*/ { }
//// function assert3(condition: any, msg?: string): /*3*/
//// hi

verify.completions({marker: "1", exact: completion.globalTypes});
verify.completions({marker: "2", exact: completion.globalTypes});
verify.completions({marker: "3", exact: completion.globalTypes});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.