11import postfixesAtPosition from '../completions/postfixesAtPosition'
2- import { NodeAtPositionResponse , TriggerCharacterCommand , triggerCharacterCommands } from '../ipcTypes'
2+ import { NodeAtPositionResponse , RequestOptionsTypes , TriggerCharacterCommand , triggerCharacterCommands } from '../ipcTypes'
33import { findChildContainingPosition , getNodePath } from '../utils'
44import getEmmetCompletions from './emmet'
55
@@ -14,6 +14,9 @@ export default (
1414 entries : [ ]
1515 typescriptEssentialsResponse : any
1616} => {
17+ const _specialCommandsParts = specialCommand . split ( '?' )
18+ specialCommand = _specialCommandsParts [ 0 ] ! as TriggerCharacterCommand
19+ const specialCommandArg = _specialCommandsParts [ 1 ] && JSON . parse ( _specialCommandsParts [ 1 ] )
1720 if ( triggerCharacterCommands . includes ( specialCommand ) && ! configuration ) {
1821 throw new Error ( 'no-ts-essential-plugin-configuration' )
1922 }
@@ -54,8 +57,31 @@ export default (
5457 typescriptEssentialsResponse : postfixesAtPosition ( position , fileName , scriptSnapshot , info . languageService ) ,
5558 } as any
5659 }
60+ if ( specialCommand === 'removeFunctionArgumentsTypesInSelection' ) {
61+ changeType < RequestOptionsTypes [ 'removeFunctionArgumentsTypesInSelection' ] > ( specialCommandArg )
62+
63+ const node = findChildContainingPosition ( ts , sourceFile , position )
64+ if ( ! node ) return
65+ if ( ! ts . isIdentifier ( node ) || ! node . parent || ! ts . isParameter ( node . parent ) || ! node . parent . parent ?. parameters ) {
66+ return
67+ }
68+ const allParams = node . parent . parent . parameters
69+ return {
70+ entries : [ ] ,
71+ typescriptEssentialsResponse : {
72+ ranges : allParams
73+ . map ( param => {
74+ if ( ! param . type || param . name . pos > specialCommandArg . endSelection ) return
75+ return [ param . name . end , param . type . end ]
76+ } )
77+ . filter ( Boolean ) ,
78+ } ,
79+ }
80+ }
5781}
5882
83+ function changeType < T > ( arg ) : asserts arg is T { }
84+
5985function nodeToApiResponse ( node : ts . Node ) : NodeAtPositionResponse {
6086 return {
6187 kindName : ts . SyntaxKind [ node . kind ] ! ,
0 commit comments