@@ -7,12 +7,12 @@ import * as vscode from './vscode-shim'
77 * @param quickPickOptions
88 * @returns Thenable<string | undefined>
99 */
10- export function createSelect < T extends quickPickOptions > (
10+ export function createSelect < T extends boolean = false > (
1111 options : ( string | vscode . QuickPickItem ) [ ] ,
12- quickPickOptions ?: T ,
13- ) : Promise < string | string [ ] | undefined > {
12+ quickPickOptions ?: quickPickOptions & { canSelectMany ?: T } ,
13+ ) : Promise < T extends true ? string [ ] : string | undefined > {
1414 return new Promise ( ( resolve ) => {
15- const noop = ( ) => { }
15+ const noop = ( ) => { }
1616 const quickPick = vscode . window . createQuickPick ( )
1717 const fixedOptions = options . map ( ( item : any ) =>
1818 typeof item === 'string' ? { label : item } : item ,
@@ -49,14 +49,14 @@ export function createSelect<T extends quickPickOptions>(
4949 let selection : readonly vscode . QuickPickItem [ ] = [ ]
5050 quickPick . onDidChangeSelection ( ( _selection ) => {
5151 selection = _selection
52- ; ( quickPickOptions ?. onDidChange || noop ) ( _selection )
52+ ; ( quickPickOptions ?. onDidChange || noop ) ( _selection )
5353 } )
5454 quickPick . onDidAccept ( ( ) => {
5555 if ( quickPickOptions ?. canSelectMany )
56- resolve ( selection . map ( item => item . label ) )
56+ resolve ( selection . map ( item => item . label ) as any )
5757 else
58- resolve ( selection [ 0 ] ?. label )
59- ; ( quickPickOptions ?. onDidAccept || noop ) ( )
58+ resolve ( selection [ 0 ] ?. label as any )
59+ ; ( quickPickOptions ?. onDidAccept || noop ) ( )
6060 quickPick . hide ( )
6161 } )
6262 quickPick . onDidTriggerButton ( quickPickOptions ?. onDidTriggerButton || noop )
0 commit comments