Skip to content

Give better error messages when properties are accessed on global empty DOM interfaces #33907

@DanielRosenwasser

Description

@DanielRosenwasser

https://twitter.com/rauschma/status/1181852019264503808

We should give a more helpful message when missing "lib": ["dom"].

If accessing a property on a type that was

  • empty and
  • declared in the global scope and
  • named after a pattern that matches /^HTML\w+Element$/

it is likely a forward declaration for DOM environments, and we should provide an error message like:

Property '{0}' does not exist on type '{1}'. Did you forget to include "dom" in your "lib" setting?

Bonus: would be awesome if we could provide related spans in a tsconfig.json/jsconfig.json to say

The 'lib' option was specified here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Experience EnhancementNoncontroversial enhancementsHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions