Flowtype - making a sealed empty object

前端 未结 1 1715
一生所求
一生所求 2021-01-13 22:47

Flow\'s docs say: When you create an object without any properties, you create an unsealed object type in Flow. Is it possible to create a sealed object without

相关标签:
1条回答
  • 2021-01-13 23:00

    This is certainly one of Flow's warts. However, it has a fairly simple workaround. Just pass your object through Object.freeze:

    Object.freeze({})

    Of course this only works if you weren't going to mutate it, but I find that in cases like this I rarely want to anyway.

    0 讨论(0)
提交回复
热议问题