Skip to content

Commit 6842944

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
[flow] Add LSP test for deprecated colon type parameter autofix
Summary: Add an IDE/LSP test for the new code action that converts `:` to `extends` in type parameter bounds. Changelog:[internal] Reviewed By: SamChou19815 Differential Revision: D95452831 fbshipit-source-id: 73e84b295a35820e661a3cb7d462fb84cb520626
1 parent 6a5ebe6 commit 6842944

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"method": "textDocument/codeAction",
3+
"result": [
4+
{
5+
"title": "Convert to `extends T`",
6+
"kind": "quickfix",
7+
"diagnostics": [],
8+
"edit": {
9+
"changes": {
10+
"<PLACEHOLDER_PROJECT_URL>/fix-type-param-colon.js": [
11+
{
12+
"range": {
13+
"start": {
14+
"line": 2,
15+
"character": 7
16+
},
17+
"end": {
18+
"line": 2,
19+
"character": 16
20+
}
21+
},
22+
"newText": "A extends string"
23+
}
24+
]
25+
}
26+
},
27+
"command": {
28+
"title": "",
29+
"command": "log:org.flow:<PLACEHOLDER_PROJECT_URL>",
30+
"arguments": [
31+
"textDocument/codeAction",
32+
"convert_type_param_colon",
33+
"Convert to `extends T`"
34+
]
35+
}
36+
}
37+
]
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[options]
2+
experimental.deprecated_colon_extends=<PROJECT_ROOT>/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @flow
2+
3+
type T<A: string> = A;

newtests/lsp/code-action/quickfix/ts_and_legacy_syntax/test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,36 @@ module.exports = (suite(
208208
['textDocument/publishDiagnostics', ...lspIgnoreStatusAndCancellation],
209209
),
210210
]),
211+
test('provide quickfix for deprecated `:` in type param', [
212+
addFile('fix-type-param-colon.js.ignored', 'fix-type-param-colon.js'),
213+
lspStartAndConnect(),
214+
lspRequestAndWaitUntilResponse('textDocument/codeAction', {
215+
textDocument: {
216+
uri: '<PLACEHOLDER_PROJECT_URL>/fix-type-param-colon.js',
217+
},
218+
range: {
219+
start: {
220+
line: 2,
221+
character: 7,
222+
},
223+
end: {
224+
line: 2,
225+
character: 21,
226+
},
227+
},
228+
context: {
229+
only: ['quickfix'],
230+
diagnostics: [],
231+
},
232+
}).verifyLSPMessageSnapshot(
233+
path.join(
234+
__dirname,
235+
'__snapshots__',
236+
'quickfix-deprecated-colon-in-type-param.json',
237+
),
238+
['textDocument/publishDiagnostics', ...lspIgnoreStatusAndCancellation],
239+
),
240+
]).flowConfig('_flowconfig_deprecated_colon_extends'),
211241
test('provide quickfix for `readonly` variance', [
212242
addFile('fix-readonly-variance.js.ignored', 'fix-readonly-variance.js'),
213243
lspStartAndConnect(),

0 commit comments

Comments
 (0)