Autocomplete suggestions for static table data not appearing when giving the type of the table

As the title says, autocomplete suggestions are not appearing when a table with known entries is typed.


This video demo shows my problem, where I initially get autocomplete suggestions but do not after adding the type of the table.

This post has a similar issue which was never quite resolved.

I would like to know if what I am looking for is impossible, or if I am missing something. Thank you for the help.

1 Like

I’ve ran into this issue before and also never found a solution.

It’s because you’re typing (not typing) it as the generic type of string keys against a Book.

Before you add the type annotation, the type solver infers it as:

local Books: {
    WarAndPeace: {
        Name: "War And Peace",
        Length: number
    },
    --etc. with "TheGruffalo"
}

but when you add [string]: Book, you’re overriding that implicit type definition and saying that any string can be the key - not just the names of the books. This causes the type solver to expect absolutely any valid string as the key - not just the book names, hence why autocomplete doesn’t show after you add this annotation.

1 Like

I thought that would be the case, thank you for the clarity.

1 Like