Add related error spans for use-before-declaration · Issue #25003 · microsoft/TypeScript (original) (raw)

Now that we support multiple related spans for errors (#10489, #22789, #24548), we'd like to improve an existing error message.

Currently, we provide certain errors for using certain declarations before they're actually declared:

Block-scoped variable '{0}' used before its declaration. Class '{0}' used before its declaration. Enum '{0}' used before its declaration.

We can actually provide the definition location as a related span for some extra context.

'{0}' was accessed prior to being declared here.