glutinum-org / cli

https://glutinum.net/
59 stars 6 forks source link

unescaped fsharp reserved keyword #138

Closed joprice closed 1 month ago

joprice commented 1 month ago

Issue created from Glutinum Tool

Glutinum version - 0.11.0-preview

TypeScript

export interface Transaction {
    updateHook: (callback?: ((params: {
        table: string;
        operation: UpdateHookOperation;
        row?: any;
        rowId: number;
    }) => void) | null) => void;
}

FSharp

module rec Glutinum

open Fable.Core
open Fable.Core.JsInterop
open System

[<AllowNullLiteral>]
[<Interface>]
type Transaction =
    abstract member updateHook: ((Transaction.updateHook.callback.params -> unit) option -> unit) with get, set

module Transaction =

    module updateHook =

        module callback =

            [<Global>]
            [<AllowNullLiteral>]
            type params
                [<ParamObject; Emit("$0")>]
                (
                    table: string,
                    operation: UpdateHookOperation,
                    rowId: float,
                    ?row: obj
                ) =

                member val table : string = nativeOnly with get, set
                member val operation : UpdateHookOperation = nativeOnly with get, set
                member val rowId : float = nativeOnly with get, set
                member val row : obj option = nativeOnly with get, set

Problem description

In the above type definition, taken from https://github.com/OP-Engineering/op-sqlite, the reserved keyword params is not escaped in backticks. The referenced type below has the same issue.

MangelMaxime commented 1 month ago

params is in the list of keywords known by Glutinum

https://github.com/glutinum-org/cli/blob/1020801f40bfcfd2e44daf3e5f596b32f4093eb0/src/Glutinum.Converter/Utils/Keywords.fs#L88

So it means, I am probably forgetting to apply the escape function when generation the type names.