|
|
|
|
|
by orif
3305 days ago
|
|
TypeScript would complain about that snippet too. function getOptions() {
return { num: 42, str: "val" };
} var __options__ = getOptions(); type Options = typeof __options__; var options: Options = { ^^^^ Type is not assignable
num: "hi",
str: 42
}; |
|
But in your TS example, the code would execute. Not in the Flow example, where it's just an annotation.
There are hacks and other approaches, documented here:
https://github.com/Microsoft/TypeScript/issues/6606