3 ms·
Nice catch! Yeah, that makes sense. As you work on this, do you know if the refactoring tools would fully work with my code typed with Flow instead of TypeScri
by ggregoire 10y ago
Nice catch! Yeah, that makes sense.
As you work on this, do you know if the refactoring tools would fully work with my code typed with Flow instead of TypeScript?
(I use the official flow-for-vscode extenstion, idk if it's relevant)
Edit: Ok I just tried and it works, even with the extension disabled.
type Foo = {
a: boolean,
b: string,
}
var foo: Foo = {
a: true, // Find all references on "a" here...
b: "hello"
};
foo.a = false;
bar(foo);
function bar(obj: Foo) {
obj.a = false; // Found it.
}
- billti 10y agoI don't know, but generally call-site inference has a couple of notable issues: - If you don't have any calls to the function yet (i.e. "bar(foo)" wasn't there above), then there is nothing to infer from, so you have no idea what the type is at this point (other than by the use of the parameter inside the function). - Is your call-site wrong? If the parameter type is explicit, this is easily checked. If not, then again you can only go by what the function does with it. (Which may not be much help if it's something like "RestAPI.post(JSON.stringify(theParamInQuestion))" ).