流式铸造

dkn*_*ack 1 javascript typescript flowtype

我现在来自Typescript并尝试Flow Type.

在TypeScript中,我可以这样做.

interface x {
    name: string;
}

let y = <x> {
    name: "John Doe"
};
Run Code Online (Sandbox Code Playgroud)

我怎样才能使用流式?

流程 - 宣布Typecasts我看到流的铸造语法是例如

(myVar: myType)
Run Code Online (Sandbox Code Playgroud)

let y = {
    name: "John Doe"
}: x;
Run Code Online (Sandbox Code Playgroud)

不起作用.

Rya*_*ugh 7

括号是强制性的.使用

let y = ({
    name: "John Doe"
}: x);
Run Code Online (Sandbox Code Playgroud)