Related error span for "did you mean ...?" error messages · Issue #25031 · 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 an error when accessing declarations that have been misspelled.
Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?
Cannot find name '{0}'. Did you mean '{1}'?
Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?
Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?
Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?
Module '{0}' has no exported member '{1}'. Did you mean '{2}'?
We can add a related span on the declaration of the suggestion if one exists:
It's likely that you meant to reference '{0}'.
This can help users quickly glance at the original declaration.