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

Commit c8e2f58

Browse filesBrowse files
authored
Completions for asserts and declare (microsoft#36355)
* Add completions for `asserts` * Add declare assertions.
1 parent 5e59eec commit c8e2f58
Copy full SHA for c8e2f58

7 files changed

+28-4Lines changed: 28 additions & 4 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/harness/fourslashInterfaceImpl.ts‎

Copy file name to clipboardExpand all lines: src/harness/fourslashInterfaceImpl.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ namespace FourSlashInterface {
902902
export const keywords: readonly ExpectedCompletionEntryObject[] = keywordsWithUndefined.filter(k => k.name !== "undefined");
903903

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

907907
const globalTypeDecls: readonly ExpectedCompletionEntryObject[] = [
908908
interfaceEntry("Symbol"),
@@ -1058,7 +1058,7 @@ namespace FourSlashInterface {
10581058
}
10591059

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

10631063
export const classElementInJsKeywords = getInJsKeywords(classElementKeywords);
10641064

@@ -1152,6 +1152,7 @@ namespace FourSlashInterface {
11521152
"let",
11531153
"package",
11541154
"yield",
1155+
"asserts",
11551156
"any",
11561157
"async",
11571158
"await",
@@ -1351,6 +1352,7 @@ namespace FourSlashInterface {
13511352
"let",
13521353
"package",
13531354
"yield",
1355+
"asserts",
13541356
"any",
13551357
"async",
13561358
"await",
Collapse file

‎src/services/completions.ts‎

Copy file name to clipboardExpand all lines: src/services/completions.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,7 @@ namespace ts.Completions {
25252525
case SyntaxKind.GetKeyword:
25262526
case SyntaxKind.SetKeyword:
25272527
case SyntaxKind.AsyncKeyword:
2528+
case SyntaxKind.DeclareKeyword:
25282529
return true;
25292530
default:
25302531
return isClassMemberModifier(kind);
Collapse file

‎src/services/utilities.ts‎

Copy file name to clipboardExpand all lines: src/services/utilities.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ namespace ts {
12831283

12841284
export const typeKeywords: readonly SyntaxKind[] = [
12851285
SyntaxKind.AnyKeyword,
1286+
SyntaxKind.AssertsKeyword,
12861287
SyntaxKind.BigIntKeyword,
12871288
SyntaxKind.BooleanKeyword,
12881289
SyntaxKind.FalseKeyword,
Collapse file
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// class C {
4+
//// /*1*/ declare property: number;
5+
//// /*2*/
6+
//// }
7+
8+
verify.completions({marker: "1", exact: completion.classElementKeywords, isNewIdentifierLocation: true});
9+
verify.completions({marker: "2", exact: completion.classElementKeywords, isNewIdentifierLocation: true});
Collapse file

‎tests/cases/fourslash/completionEntryForClassMembers.ts‎

Copy file name to clipboardExpand all lines: tests/cases/fourslash/completionEntryForClassMembers.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ verify.completions(
146146
"classThatStartedWritingIdentifierAfterPrivateModifier",
147147
"classThatStartedWritingIdentifierAfterPrivateStaticModifier",
148148
],
149-
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(
149+
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(
150150
name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
151151
),
152152
isNewIdentifierLocation: true,
Collapse file

‎tests/cases/fourslash/completionListInNamedClassExpression.ts‎

Copy file name to clipboardExpand all lines: tests/cases/fourslash/completionListInNamedClassExpression.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ verify.completions(
1111
{ marker: "0", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } },
1212
{
1313
marker: "1",
14-
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(
14+
exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set"].map(
1515
name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
1616
),
1717
isNewIdentifierLocation: true,
Collapse file
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// const x = "str";
4+
//// function assert1(condition: any, msg?: string): /*1*/ ;
5+
//// function assert2(condition: any, msg?: string): /*2*/ { }
6+
//// function assert3(condition: any, msg?: string): /*3*/
7+
//// hi
8+
9+
verify.completions({marker: "1", exact: completion.globalTypes});
10+
verify.completions({marker: "2", exact: completion.globalTypes});
11+
verify.completions({marker: "3", exact: completion.globalTypes});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.