File tree Expand file tree Collapse file tree 5 files changed +92
-0
lines changed Expand file tree Collapse file tree 5 files changed +92
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,8 @@ namespace ts.refactor {
229
229
function doTypedefChange ( changes : textChanges . ChangeTracker , file : SourceFile , name : string , info : ExtractInfo ) {
230
230
const { firstStatement, selection, typeParameters } = info ;
231
231
232
+ setEmitFlags ( selection , EmitFlags . NoComments | EmitFlags . NoNestedComments ) ;
233
+
232
234
const node = factory . createJSDocTypedefTag (
233
235
factory . createIdentifier ( "typedef" ) ,
234
236
factory . createJSDocTypeExpression ( selection ) ,
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @allowJs : true
4
+ // @Filename : a.js
5
+ ////type Foo = /*a*/[|{
6
+ //// oops: string;
7
+ //// /**
8
+ //// *
9
+ //// */
10
+ //// }|]/*b*/;
11
+
12
+ goTo . file ( 'a.js' )
13
+ goTo . select ( "a" , "b" ) ;
14
+ edit . applyRefactor ( {
15
+ refactorName : "Extract type" ,
16
+ actionName : "Extract to typedef" ,
17
+ actionDescription : "Extract to typedef" ,
18
+ newContent :
19
+ `/**
20
+ * @typedef {{
21
+ oops: string;
22
+ }} /*RENAME*/NewType
23
+ */
24
+
25
+ type Foo = NewType;` ,
26
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @allowJs : true
4
+ // @Filename : a.js
5
+ ////type Foo = /*a*/[|{
6
+ //// /**
7
+ //// *
8
+ //// */
9
+ //// oops: string;
10
+ //// }|]/*b*/;
11
+
12
+ goTo . file ( 'a.js' )
13
+ goTo . select ( "a" , "b" ) ;
14
+ edit . applyRefactor ( {
15
+ refactorName : "Extract type" ,
16
+ actionName : "Extract to typedef" ,
17
+ actionDescription : "Extract to typedef" ,
18
+ newContent :
19
+ `/**
20
+ * @typedef {{
21
+ oops: string;
22
+ }} /*RENAME*/NewType
23
+ */
24
+
25
+ type Foo = NewType;` ,
26
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @allowJs : true
4
+ // @Filename : a.js
5
+ ////type Bar = /*a*/[|string | boolean /* oops */ |]/*b*/;
6
+
7
+ goTo . file ( 'a.js' )
8
+ goTo . select ( "a" , "b" ) ;
9
+ edit . applyRefactor ( {
10
+ refactorName : "Extract type" ,
11
+ actionName : "Extract to typedef" ,
12
+ actionDescription : "Extract to typedef" ,
13
+ newContent :
14
+ `/**
15
+ * @typedef {string | boolean} /*RENAME*/NewType
16
+ */
17
+
18
+ type Bar = NewType /* oops */ ;` ,
19
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @allowJs : true
4
+ // @Filename : a.js
5
+ ////type Bar = /*a*/[|string | /* oops */ boolean|]/*b*/;
6
+
7
+ goTo . file ( 'a.js' )
8
+ goTo . select ( "a" , "b" ) ;
9
+ edit . applyRefactor ( {
10
+ refactorName : "Extract type" ,
11
+ actionName : "Extract to typedef" ,
12
+ actionDescription : "Extract to typedef" ,
13
+ newContent :
14
+ `/**
15
+ * @typedef {string | boolean} /*RENAME*/NewType
16
+ */
17
+
18
+ type Bar = NewType;` ,
19
+ } ) ;
You can’t perform that action at this time.
0 commit comments