在内联注释类型中类型转换为类型别名(流程)

问题描述 投票:0回答:1

我有一个使用 Flow 的普通 JavaScript 文件,如下所示:

// @flow
/*:: type orderType = number; */
let ot = 0 /*:: as orderType */;

但我收到错误

无效的类型转换语法。使用形式

(<expr>: <type>)
而不是形式
<expr> as <type>

但是,尝试该语法也会给我一个错误:

let ot = 0 /*:: : orderType */;    // ■■■■ Unexpected token `:`, expected the token `;`

使用类型别名进行类型转换不适用于 Flow 中的注释类型吗?

flowtype
1个回答
0
投票

正确的语法似乎是

let op /*: orderType*/ = 0;

假设您使用

number
而不是
Number

© www.soinside.com 2019 - 2024. All rights reserved.