different result for indexed type when inlined in interface field
joprice opened this issue · comments
Joseph Price commented
When a type with an indexer is nested, a class type gets generated instead:
interface Options {
[key: string]: string
}
correctly generates
[<AllowNullLiteral>]
[<Interface>]
type Options =
[<EmitIndexer>]
abstract member Item: key: string -> string with get, set
However, with the definition inlined into a key:
interface OptionsInline {
users: { [key: string]: string }
}
It generates
[<AllowNullLiteral>]
[<Interface>]
type OptionsInline =
abstract member users: OptionsInline.users with get, set
module OptionsInline =
[<Global>]
[<AllowNullLiteral>]
type users
[<ParamObject; Emit("$0")>]
(
Item: string
) =
member val Item : string = nativeOnly with get, set
Aliasing the type works as expected:
interface OptionsAliased {
users: Options
}
[<AllowNullLiteral>]
[<Interface>]
type Options =
[<EmitIndexer>]
abstract member Item: key: string -> string with get, set
[<AllowNullLiteral>]
[<Interface>]
type OptionsAliased =
abstract member users: Options with get, set
Maxime Mangel commented