File tree 6 files changed +36
-1
lines changed
tests/specs/references/typeLiteral/indexSignature
6 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ type GlueIndexSignature =
101
101
{
102
102
Parameters: GlueParameter list
103
103
Type: GlueType
104
+ IsReadOnly: bool
104
105
}
105
106
106
107
type GlueMethodSignature =
Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ let readDeclaration
66
66
({
67
67
Parameters = reader.ReadParameters indexSignature.parameters
68
68
Type = reader.ReadTypeNode( Some indexSignature.`` type `` )
69
+ IsReadOnly =
70
+ match indexSignature.modifiers with
71
+ | Some modifiers ->
72
+ modifiers
73
+ |> Seq.exists ( fun modifier ->
74
+ modifier?kind = Ts.SyntaxKind.ReadonlyKeyword
75
+ )
76
+ | None -> false
69
77
}
70
78
: GlueIndexSignature)
71
79
|> GlueMember.IndexSignature
Original file line number Diff line number Diff line change @@ -1157,7 +1157,11 @@ module private TransformMembers =
1157
1157
TypeParameters = []
1158
1158
IsOptional = false
1159
1159
IsStatic = false
1160
- Accessor = Some FSharpAccessor.ReadWrite
1160
+ Accessor =
1161
+ if indexSignature.IsReadOnly then
1162
+ Some FSharpAccessor.ReadOnly
1163
+ else
1164
+ Some FSharpAccessor.ReadWrite
1161
1165
Accessibility = FSharpAccessibility.Public
1162
1166
XmlDoc = []
1163
1167
Body = FSharpMemberInfoBody.NativeOnly
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ type GlueASTViewer =
24
24
static member private IsOptional ( isOptional : bool ) =
25
25
ASTViewer.renderKeyValue " IsOptional" ( string isOptional)
26
26
27
+ static member private IsReadOnly ( isReadOnly : bool ) =
28
+ ASTViewer.renderKeyValue " IsReadOnly" ( string isReadOnly)
29
+
27
30
static member private IsStatic ( isStatic : bool ) =
28
31
ASTViewer.renderKeyValue " IsStatic" ( string isStatic)
29
32
@@ -165,6 +168,7 @@ type GlueASTViewer =
165
168
ASTViewer.renderNode " IndexSignature" [
166
169
GlueASTViewer.Parameters indexSignature.Parameters
167
170
GlueASTViewer.Type indexSignature.Type
171
+ GlueASTViewer.IsReadOnly indexSignature.IsReadOnly
168
172
]
169
173
170
174
| GlueMember.Property propertyInfo ->
Original file line number Diff line number Diff line change
1
+ export interface MyType {
2
+ readonly [ n : number ] : string ;
3
+ }
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
+ [<AllowNullLiteral>]
8
+ [<Interface>]
9
+ type MyType =
10
+ [<EmitIndexer>]
11
+ abstract member Item: n : float -> string with get
12
+
13
+ (***)
14
+ #r " nuget: Fable.Core"
15
+ (***)
You can’t perform that action at this time.
0 commit comments