Skip to content

Commit efd0b0b

Browse files
authored
Fourslash conversion script improvements + fix (#1503)
1 parent a57f4e0 commit efd0b0b

File tree

90 files changed

+3583
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3583
-190
lines changed

internal/fourslash/_scripts/convertFourslash.mts

Lines changed: 231 additions & 111 deletions
Large diffs are not rendered by default.

internal/fourslash/_scripts/failingTests.txt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
TestAliasMergingWithNamespace
22
TestAmbientShorthandGotoDefinition
3+
TestArgumentsAreAvailableAfterEditsAtEndOfFunction
34
TestAugmentedTypesClass1
45
TestAugmentedTypesClass3Fourslash
56
TestBestCommonTypeObjectLiterals
@@ -21,12 +22,8 @@ TestCompletionExportFrom
2122
TestCompletionForComputedStringProperties
2223
TestCompletionForMetaProperty
2324
TestCompletionForStringLiteral
24-
TestCompletionForStringLiteral12
25-
TestCompletionForStringLiteral15
26-
TestCompletionForStringLiteral2
27-
TestCompletionForStringLiteral3
25+
TestCompletionForStringLiteral4
2826
TestCompletionForStringLiteralExport
29-
TestCompletionForStringLiteralFromSignature
3027
TestCompletionForStringLiteralImport1
3128
TestCompletionForStringLiteralImport2
3229
TestCompletionForStringLiteralNonrelativeImport12
@@ -71,7 +68,6 @@ TestCompletionInJsDoc
7168
TestCompletionInJsDocQualifiedNames
7269
TestCompletionInNamedImportLocation
7370
TestCompletionInUncheckedJSFile
74-
TestCompletionInfoWithExplicitTypeArguments
7571
TestCompletionJSDocNamePath
7672
TestCompletionListBuilderLocations_VariableDeclarations
7773
TestCompletionListForDerivedType1
@@ -98,7 +94,10 @@ TestCompletionListInUnclosedTaggedTemplate01
9894
TestCompletionListInUnclosedTaggedTemplate02
9995
TestCompletionListInUnclosedTemplate01
10096
TestCompletionListInUnclosedTemplate02
97+
TestCompletionListInvalidMemberNames
10198
TestCompletionListInvalidMemberNames2
99+
TestCompletionListInvalidMemberNames_escapeQuote
100+
TestCompletionListInvalidMemberNames_startWithSpace
102101
TestCompletionListInvalidMemberNames_withExistingIdentifier
103102
TestCompletionListObjectMembersInTypeLocationWithTypeof
104103
TestCompletionListOfGenericSymbol
@@ -110,28 +109,35 @@ TestCompletionListsStringLiteralTypeAsIndexedAccessTypeObject
110109
TestCompletionNoAutoInsertQuestionDotForThis
111110
TestCompletionNoAutoInsertQuestionDotForTypeParameter
112111
TestCompletionNoAutoInsertQuestionDotWithUserPreferencesOff
112+
TestCompletionOfAwaitPromise1
113+
TestCompletionOfAwaitPromise2
114+
TestCompletionOfAwaitPromise3
115+
TestCompletionOfAwaitPromise5
113116
TestCompletionOfAwaitPromise6
117+
TestCompletionOfAwaitPromise7
114118
TestCompletionOfInterfaceAndVar
115119
TestCompletionPreferredSuggestions1
116120
TestCompletionWithConditionalOperatorMissingColon
117121
TestCompletionsAfterJSDoc
118122
TestCompletionsBeforeRestArg1
123+
TestCompletionsElementAccessNumeric
119124
TestCompletionsExportImport
120125
TestCompletionsGenericTypeWithMultipleBases1
126+
TestCompletionsImportOrExportSpecifier
127+
TestCompletionsInExport
128+
TestCompletionsInExport_moduleBlock
121129
TestCompletionsInRequire
122130
TestCompletionsJSDocImportTagAttributesEmptyModuleSpecifier1
123131
TestCompletionsJSDocImportTagAttributesErrorModuleSpecifier1
124132
TestCompletionsJSDocImportTagEmptyModuleSpecifier1
125133
TestCompletionsJSDocNoCrash1
126134
TestCompletionsJSDocNoCrash2
127135
TestCompletionsJSDocNoCrash3
128-
TestCompletionsJsPropertyAssignment
129136
TestCompletionsJsdocParamTypeBeforeName
130137
TestCompletionsJsdocTag
131138
TestCompletionsJsdocTypeTagCast
132139
TestCompletionsJsxAttribute2
133140
TestCompletionsJsxAttributeInitializer2
134-
TestCompletionsKeyof
135141
TestCompletionsLiteralFromInferenceWithinInferredType3
136142
TestCompletionsLiterals
137143
TestCompletionsMergedDeclarations1
@@ -156,12 +162,13 @@ TestCompletionsPaths_pathMapping_nonTrailingWildcard1
156162
TestCompletionsPaths_pathMapping_parentDirectory
157163
TestCompletionsRecommended_union
158164
TestCompletionsRedeclareModuleAsGlobal
159-
TestCompletionsStringLiteral_fromTypeConstraint
160165
TestCompletionsStringsWithTriggerCharacter
161166
TestCompletionsSymbolMembers
162167
TestCompletionsTriggerCharacter
168+
TestCompletionsTuple
163169
TestCompletionsUniqueSymbol1
164-
TestCompletionsWithStringReplacementMode1
170+
TestConstEnumQuickInfoAndCompletionList
171+
TestConstQuickInfoAndCompletionList
165172
TestContextuallyTypedFunctionExpressionGeneric1
166173
TestDoubleUnderscoreCompletions
167174
TestEditJsdocType
@@ -191,7 +198,6 @@ TestGetJavaScriptCompletions13
191198
TestGetJavaScriptCompletions15
192199
TestGetJavaScriptCompletions18
193200
TestGetJavaScriptCompletions20
194-
TestGetJavaScriptCompletions21
195201
TestGetJavaScriptCompletions8
196202
TestGetJavaScriptCompletions9
197203
TestGetJavaScriptGlobalCompletions1
@@ -281,6 +287,7 @@ TestJsdocTypedefTag2
281287
TestJsdocTypedefTagNamespace
282288
TestJsdocTypedefTagTypeExpressionCompletion
283289
TestJsxFindAllReferencesOnRuntimeImportWithPaths1
290+
TestLetQuickInfoAndCompletionList
284291
TestLocalFunction
285292
TestLocalGetReferences
286293
TestMemberListInReopenedEnum
@@ -344,12 +351,10 @@ TestPathCompletionsTypesVersionsWildcard3
344351
TestPathCompletionsTypesVersionsWildcard4
345352
TestPathCompletionsTypesVersionsWildcard5
346353
TestPathCompletionsTypesVersionsWildcard6
347-
TestProto
348354
TestProtoVarVisibleWithOuterScopeUnderscoreProto
349355
TestQuickInfoAlias
350356
TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1
351357
TestQuickInfoBindingPatternInJsdocNoCrash1
352-
TestQuickInfoCallProperty
353358
TestQuickInfoClassKeyword
354359
TestQuickInfoContextualTyping
355360
TestQuickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1
@@ -359,7 +364,6 @@ TestQuickInfoForConstTypeReference
359364
TestQuickInfoForContextuallyTypedArrowFunctionInSuperCall
360365
TestQuickInfoForContextuallyTypedIife
361366
TestQuickInfoForContextuallyTypedParameters
362-
TestQuickInfoForDecorators
363367
TestQuickInfoForGenericConstraints1
364368
TestQuickInfoForGenericPrototypeMember
365369
TestQuickInfoForGenericTaggedTemplateExpression
@@ -388,7 +392,6 @@ TestQuickInfoJSDocFunctionThis
388392
TestQuickInfoJSExport
389393
TestQuickInfoJsDocGetterSetterNoCrash1
390394
TestQuickInfoJsDocNonDiscriminatedUnionSharedProp
391-
TestQuickInfoJsDocTags2
392395
TestQuickInfoJsPropertyAssignedAfterMethodDeclaration
393396
TestQuickInfoJsdocTypedefMissingType
394397
TestQuickInfoMappedSpreadTypes
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
8+
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
9+
"github.com/microsoft/typescript-go/internal/testutil"
10+
)
11+
12+
func TestArgumentsAreAvailableAfterEditsAtEndOfFunction(t *testing.T) {
13+
t.Parallel()
14+
t.Skip()
15+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
16+
const content = `module Test1 {
17+
class Person {
18+
children: string[];
19+
constructor(public name: string, children: string[]) {
20+
/**/
21+
}
22+
}
23+
}`
24+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
25+
f.GoToMarker(t, "")
26+
f.Insert(t, "this.children = ch")
27+
f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{
28+
IsIncomplete: false,
29+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
30+
CommitCharacters: &[]string{},
31+
EditRange: Ignored,
32+
},
33+
Items: &fourslash.CompletionsExpectedItems{
34+
Includes: []fourslash.CompletionsExpectedItem{
35+
&lsproto.CompletionItem{
36+
Label: "children",
37+
Detail: PtrTo("(parameter) children: string[]"),
38+
},
39+
},
40+
},
41+
})
42+
}

internal/fourslash/tests/gen/commentsUnion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ func TestCommentsUnion(t *testing.T) {
1414
const content = `var a: Array<string> | Array<number>;
1515
a./*1*/length`
1616
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
17-
f.VerifyQuickInfoAt(t, "1", "(property) Array<T>.length: number", "(property) Array<T>.length: number")
17+
f.VerifyQuickInfoAt(t, "1", "(property) Array<T>.length: number", "Gets or sets the length of the array. This is a number one higher than the highest index in the array.")
1818
}

internal/fourslash/tests/gen/completionAfterQuestionDot_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class User {
4444
Label: "postal code",
4545
InsertText: PtrTo("?.[\"postal code\"]"),
4646
Detail: PtrTo("(property) \"postal code\": string"),
47+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
48+
TextEdit: &lsproto.TextEdit{
49+
NewText: "postal code",
50+
Range: f.Ranges()[0].LSRange,
51+
},
52+
},
4753
},
4854
},
4955
},

internal/fourslash/tests/gen/completionAutoInsertQuestionDot_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,23 @@ user.address[|./**/|]`
3535
Label: "city",
3636
InsertText: PtrTo("?.city"),
3737
Detail: PtrTo("(property) city: string"),
38+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
39+
TextEdit: &lsproto.TextEdit{
40+
NewText: "city",
41+
Range: f.Ranges()[0].LSRange,
42+
},
43+
},
3844
},
3945
&lsproto.CompletionItem{
4046
Label: "postal code",
4147
InsertText: PtrTo("?.[\"postal code\"]"),
4248
Detail: PtrTo("(property) \"postal code\": string"),
49+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
50+
TextEdit: &lsproto.TextEdit{
51+
NewText: "postal code",
52+
Range: f.Ranges()[0].LSRange,
53+
},
54+
},
4355
},
4456
},
4557
},

internal/fourslash/tests/gen/completionForComputedStringProperties_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ a[|./**/|]`
3535
&lsproto.CompletionItem{
3636
Label: "p2",
3737
InsertText: PtrTo("[p2]"),
38+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
39+
TextEdit: &lsproto.TextEdit{
40+
NewText: "p2",
41+
Range: f.Ranges()[0].LSRange,
42+
},
43+
},
3844
},
3945
},
4046
},
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
8+
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
9+
"github.com/microsoft/typescript-go/internal/testutil"
10+
)
11+
12+
func TestCompletionForQuotedPropertyInPropertyAssignment1(t *testing.T) {
13+
t.Parallel()
14+
15+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
16+
const content = `export interface Configfiles {
17+
jspm: string;
18+
'jspm:browser': string;
19+
}
20+
let files: Configfiles;
21+
files = {
22+
/*0*/: '',
23+
'[|/*1*/|]': ''
24+
}`
25+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
26+
f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{
27+
IsIncomplete: false,
28+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
29+
CommitCharacters: &DefaultCommitCharacters,
30+
EditRange: Ignored,
31+
},
32+
Items: &fourslash.CompletionsExpectedItems{
33+
Exact: []fourslash.CompletionsExpectedItem{
34+
"\"jspm:browser\"",
35+
"jspm",
36+
},
37+
},
38+
})
39+
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
40+
IsIncomplete: false,
41+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
42+
CommitCharacters: &DefaultCommitCharacters,
43+
EditRange: Ignored,
44+
},
45+
Items: &fourslash.CompletionsExpectedItems{
46+
Exact: []fourslash.CompletionsExpectedItem{
47+
&lsproto.CompletionItem{
48+
Label: "jspm",
49+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
50+
TextEdit: &lsproto.TextEdit{
51+
NewText: "jspm",
52+
Range: f.Ranges()[0].LSRange,
53+
},
54+
},
55+
},
56+
&lsproto.CompletionItem{
57+
Label: "jspm:browser",
58+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
59+
TextEdit: &lsproto.TextEdit{
60+
NewText: "jspm:browser",
61+
Range: f.Ranges()[0].LSRange,
62+
},
63+
},
64+
},
65+
},
66+
},
67+
})
68+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
8+
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
9+
"github.com/microsoft/typescript-go/internal/testutil"
10+
)
11+
12+
func TestCompletionForQuotedPropertyInPropertyAssignment2(t *testing.T) {
13+
t.Parallel()
14+
15+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
16+
const content = `export interface Config {
17+
files: ConfigFiles
18+
}
19+
export interface ConfigFiles {
20+
jspm: string;
21+
'jspm:browser': string;
22+
}
23+
let config: Config;
24+
config = {
25+
files: {
26+
/*0*/: '',
27+
'[|/*1*/|]': ''
28+
}
29+
}`
30+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
31+
f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{
32+
IsIncomplete: false,
33+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
34+
CommitCharacters: &DefaultCommitCharacters,
35+
EditRange: Ignored,
36+
},
37+
Items: &fourslash.CompletionsExpectedItems{
38+
Exact: []fourslash.CompletionsExpectedItem{
39+
"\"jspm:browser\"",
40+
"jspm",
41+
},
42+
},
43+
})
44+
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
45+
IsIncomplete: false,
46+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
47+
CommitCharacters: &DefaultCommitCharacters,
48+
EditRange: Ignored,
49+
},
50+
Items: &fourslash.CompletionsExpectedItems{
51+
Exact: []fourslash.CompletionsExpectedItem{
52+
&lsproto.CompletionItem{
53+
Label: "jspm",
54+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
55+
TextEdit: &lsproto.TextEdit{
56+
NewText: "jspm",
57+
Range: f.Ranges()[0].LSRange,
58+
},
59+
},
60+
},
61+
&lsproto.CompletionItem{
62+
Label: "jspm:browser",
63+
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
64+
TextEdit: &lsproto.TextEdit{
65+
NewText: "jspm:browser",
66+
Range: f.Ranges()[0].LSRange,
67+
},
68+
},
69+
},
70+
},
71+
},
72+
})
73+
}

0 commit comments

Comments
 (0)