Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsc: don't rely on implicit index signature for objects #5873

Closed
8 tasks done
brendankenny opened this issue Aug 20, 2018 · 1 comment
Closed
8 tasks done

tsc: don't rely on implicit index signature for objects #5873

brendankenny opened this issue Aug 20, 2018 · 1 comment
Assignees
Labels

Comments

@brendankenny
Copy link
Member

brendankenny commented Aug 20, 2018

tracking issue for updates needed for the upcoming TypeScript 3.1, which will no longer automatically add [x: string]: any; to any type inferred from an object declaration. This is only a change for js; this was never done in ts.

It was helpful in cases where we were mapping specific small objects to a general grab-bag type (e.g. {type: 'code', snippet: str} and then saying it was of a more general details item type), and we'll have to explicitly declare a few more types to fix those places.

But it means certain errors will now be caught. e.g. in TS≤3.0 in lighthouse-ext-background.js, if you refer to background.getDefaultCategories() the return value will be type checked, but if you do background.getCategoriez() the compiler will think the call is valid and returns an any, because the compiler was automatically adding a [x: string]: any; to the lighthouse-background.js export.

Before I started we had almost 100 errors from this, and fixing them only makes things more correct (even in 3.0), so I thought I'd start early. In many places a single line fix and multiple errors are resolved, so it shouldn't be too bad.

@brendankenny
Copy link
Member Author

This is complete with #5942 (though detailsItem still needs work independent of this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants