Type-cast to type-alias in inline comment type (Flow)

13 Views Asked by At

I have a vanilla JavaScript file using Flow, like so:

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

but I get error

Invalid type cast syntax. Use the form (<expr>: <type>) instead of the form <expr> as <type>.

However, trying that syntax also gives me an error:

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

Is type-casting with type-alias not working with comment types in Flow?

1

There are 1 best solutions below

0
Olle Härstedt On

Correct syntax seem to be

let op /*: orderType*/ = 0;

assuming you use number and not Number.