File tree Expand file tree Collapse file tree 6 files changed +52
-2
lines changed
tests/specs/references/thisParameterType Expand file tree Collapse file tree 6 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,7 @@ type GlueUtilityType =
271
271
| Partial of GlueInterface
272
272
| Record of GlueRecord
273
273
| ReturnType of GlueType
274
+ | ThisParameterType of GlueType
274
275
275
276
type GlueMappedType =
276
277
{
@@ -374,4 +375,5 @@ type GlueType =
374
375
| GlueUtilityType.Partial _
375
376
| GlueUtilityType.Record _ -> " obj"
376
377
| GlueUtilityType.ReturnType returnType -> returnType.Name
378
+ | GlueUtilityType.ThisParameterType thisType -> thisType.Name
377
379
| MappedType _ -> " obj"
Original file line number Diff line number Diff line change @@ -166,6 +166,22 @@ module UtilityType =
166
166
|> GlueUtilityType.ReturnType
167
167
|> GlueType.UtilityType
168
168
169
+ let thisParameterType
170
+ ( reader : ITypeScriptReader )
171
+ ( typeReferenceNode : Ts.TypeReferenceNode )
172
+ =
173
+ let typ = reader.checker.getTypeFromTypeNode typeReferenceNode
174
+
175
+ match reader.checker.typeToTypeNode ( typ, None, None) with
176
+ | Some typeNode ->
177
+ reader.ReadTypeNode typeNode
178
+ |> GlueUtilityType.ThisParameterType
179
+ |> GlueType.UtilityType
180
+ | None ->
181
+ readTypeUsingFlags reader typ
182
+ |> GlueUtilityType.ThisParameterType
183
+ |> GlueType.UtilityType
184
+
169
185
let readTypeNode
170
186
( reader : ITypeScriptReader )
171
187
( typeNode : Ts.TypeNode )
@@ -213,6 +229,8 @@ let readTypeNode
213
229
| " Record" -> UtilityType.readRecord reader typeReferenceNode
214
230
| " ReturnType" ->
215
231
UtilityType.readReturnType reader typeReferenceNode
232
+ | " ThisParameterType" ->
233
+ UtilityType.thisParameterType reader typeReferenceNode
216
234
| _ -> readTypeReference true
217
235
else
218
236
readTypeReference false
Original file line number Diff line number Diff line change @@ -728,8 +728,9 @@ let rec private transformType
728
728
: FSharpMapped)
729
729
|> FSharpType.Mapped
730
730
731
- | GlueUtilityType.ReturnType returnType ->
732
- transformType context returnType
731
+ | GlueUtilityType.ReturnType innerType
732
+ | GlueUtilityType.ThisParameterType innerType ->
733
+ transformType context innerType
733
734
734
735
| GlueType.TypeAliasDeclaration typeAliasDeclaration ->
735
736
({
@@ -2136,6 +2137,9 @@ let private transformTypeAliasDeclaration
2136
2137
2137
2138
transformType context returnType |> makeTypeAlias
2138
2139
2140
+ | GlueUtilityType.ThisParameterType innerType ->
2141
+ transformType context innerType |> makeTypeAlias
2142
+
2139
2143
| GlueType.FunctionType functionType ->
2140
2144
{
2141
2145
Attributes =
Original file line number Diff line number Diff line change @@ -491,6 +491,12 @@ type GlueASTViewer =
491
491
[ GlueASTViewer.Type returnType ]
492
492
context
493
493
494
+ | GlueUtilityType.ThisParameterType thisParameterType ->
495
+ ASTViewer.renderNode
496
+ " ThisParameterType"
497
+ [ GlueASTViewer.Type thisParameterType ]
498
+ context
499
+
494
500
| GlueType.ThisType thisTypeInfo ->
495
501
ASTViewer.renderNode
496
502
" ThisType"
Original file line number Diff line number Diff line change
1
+ declare function toHex ( this : number ) : string ;
2
+ declare function numberToString ( n : ThisParameterType < typeof toHex > ) : string ;
Original file line number Diff line number Diff line change
1
+ module rec Glutinum
2
+
3
+ open Fable.Core
4
+ open Fable.Core .JsInterop
5
+ open System
6
+
7
+ [<AbstractClass>]
8
+ [<Erase>]
9
+ type Exports =
10
+ [<Import( " toHex" , " REPLACE_ME_WITH_MODULE_NAME" ) >]
11
+ static member toHex ( this : float ) : string = nativeOnly
12
+ [<Import( " numberToString" , " REPLACE_ME_WITH_MODULE_NAME" ) >]
13
+ static member numberToString ( n : float ) : string = nativeOnly
14
+
15
+ (***)
16
+ #r " nuget: Fable.Core"
17
+ #r " nuget: Glutinum.Types"
18
+ (***)
You can’t perform that action at this time.
0 commit comments