fable-compiler/ts2fable

`<t extends string>` being emitted as `'T` instead of `string`

baronfel opened this issue · 0 comments

Here's a chunk out of a recent vscode typescript definition that describes a series of overloads to the showInformationMessage method. The API can take either strings or MessageItem-derived types, but the way it surfaces the T for strings doesn't translate well currently in ts2fable. T extends string Is used to forward along anonymous unions of specific string values, I believe, but for F# purposes we probably just care about raw string here. Emitting T extends string as 'T causes errors for these overloads, since there's already a set of overloads defined that clobber here.

Input

        /**
         * Show an information message to users. Optionally provide an array of items which will be presented as
         * clickable buttons.
         *
         * @param message The message to show.
         * @param items A set of items that will be rendered as actions in the message.
         * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
         */
        export function showInformationMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;

        /**
         * Show an information message to users. Optionally provide an array of items which will be presented as
         * clickable buttons.
         *
         * @param message The message to show.
         * @param options Configures the behaviour of the message.
         * @param items A set of items that will be rendered as actions in the message.
         * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
         */
        export function showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;

        /**
         * Show an information message.
         *
         * @see {@link window.showInformationMessage showInformationMessage}
         *
         * @param message The message to show.
         * @param items A set of items that will be rendered as actions in the message.
         * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
         */
        export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;

        /**
         * Show an information message.
         *
         * @see {@link window.showInformationMessage showInformationMessage}
         *
         * @param message The message to show.
         * @param options Configures the behaviour of the message.
         * @param items A set of items that will be rendered as actions in the message.
         * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
         */
        export function showInformationMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;

output

 /// <summary>
            /// Show an information message to users. Optionally provide an array of items which will be presented as
            /// clickable buttons.
            /// </summary>
            /// <param name="message">The message to show.</param>
            /// <param name="items">A set of items that will be rendered as actions in the message.</param>
            /// <returns>A thenable that resolves to the selected item or <c>undefined</c> when being dismissed.</returns>
            abstract showInformationMessage: message: string * [<ParamArray>] items: 'T[] -> Thenable<'T option>
            /// <summary>
            /// Show an information message to users. Optionally provide an array of items which will be presented as
            /// clickable buttons.
            /// </summary>
            /// <param name="message">The message to show.</param>
            /// <param name="options">Configures the behaviour of the message.</param>
            /// <param name="items">A set of items that will be rendered as actions in the message.</param>
            /// <returns>A thenable that resolves to the selected item or <c>undefined</c> when being dismissed.</returns>
            abstract showInformationMessage: message: string * options: MessageOptions * [<ParamArray>] items: 'T[] -> Thenable<'t option>
            /// <summary>Show an information message.</summary>
            /// <seealso cref="window.showInformationMessage">showInformationMessage</seealso>
            /// <param name="message">The message to show.</param>
            /// <param name="items">A set of items that will be rendered as actions in the message.</param>
            /// <returns>A thenable that resolves to the selected item or <c>undefined</c> when being dismissed.</returns>
            abstract showInformationMessage: message: string * [<ParamArray>] items: 'T[] -> Thenable<'T option> when 'T :> MessageItem
            /// <summary>Show an information message.</summary>
            /// <seealso cref="window.showInformationMessage">showInformationMessage</seealso>
            /// <param name="message">The message to show.</param>
            /// <param name="options">Configures the behaviour of the message.</param>
            /// <param name="items">A set of items that will be rendered as actions in the message.</param>
            /// <returns>A thenable that resolves to the selected item or <c>undefined</c> when being dismissed.</returns>
            abstract showInformationMessage: message: string * options: MessageOptions * [<ParamArray>] items: 'T[] -> Thenable<'T option> when 'T :> MessageItem