Skip to content

Commit dd86e28

Browse files
committed
fix: do not include this argument when generating signature of a FunctionType
[converter][web] Fix #118
1 parent 98d1bd2 commit dd86e28

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Glutinum.Converter/Transform.fs

+3
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ let rec private transformType
437437
({
438438
Parameters =
439439
functionTypeInfo.Parameters
440+
// TypeScript allows to annotate the `this` parameter but it is not actually part
441+
// of the function signature that the user will call.
442+
|> List.filter (fun parameter -> parameter.Name <> "this")
440443
|> List.map (transformParameter context)
441444
ReturnType = transformType context functionTypeInfo.Type
442445
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface Database {
2+
run(sql: string, callback?: (this: string, err: Error | null) => void): this;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module rec Glutinum
2+
3+
open Fable.Core
4+
open Fable.Core.JsInterop
5+
open System
6+
7+
[<AllowNullLiteral>]
8+
[<Interface>]
9+
type Database =
10+
abstract member run: sql: string * ?callback: (Error option -> unit) -> Database
11+
12+
(***)
13+
#r "nuget: Fable.Core"
14+
(***)

0 commit comments

Comments
 (0)