Flow passes the following cleanly, but it shouldn't:
type T = {||};
declare var k: T;
k[1] = 7;
I'd expect even a _non_-exact object type to fail with the "access of computed property/element . Indexable signature not found" error. The following should be a type error:
type Foo = { n: number };
const foo: Foo = {n: 0};
const name: string = 'n';
const prop: boolean = foo[name];
I want computed property access to be allowed only when there's an indexer property.
@jfirebaugh if you remove the string annotation from name it will give you your flow error.
type Foo = { n: number };
const foo: Foo = {n: 0};
const name = 'n';
const prop: boolean = foo[name];
Interesting -- I suppose in that case it gets typed as a literal, so essentially equivalent to foo['n'] which is also an error.
In the context where I encountered the issue, that's not an option however; name is not assigned from a string literal, and not explicitly annotated -- flow infers a string type.
Well, I believe this is the source of your problem. You can again work around this by changing your type definition:
type Foo = { n: number, [any]: mixed };
Bump.
Most helpful comment
I'd expect even a _non_-exact object type to fail with the "access of computed property/element . Indexable signature not found" error. The following should be a type error:
I want computed property access to be allowed only when there's an indexer property.