Skip to content

Track expanded support for more multi-location diagnostic messages #22789

Open
@mhegazy

Description

We now support related information for diagnostic messages. This issue now tracks, in aggregate, which diagnostics we have extra information for. The following errors are candidates:

MVP

  • _____ used before its declaration.
  • Property '{0}' is used before being assigned.
  • Cannot redeclare block-scoped variable '{0}'.
  • Type '{0}' is not assignable to type '{1}'.
  • Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated.
  • Expected {0} arguments, ___________

Others

  • Cannot find name '{0}'. Did you mean ______

  • Duplicate declaration '{0}'.

  • _____ has or is using private name '{1}'

  • Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.

  • '{0}' are specified twice. The attribute named '{0}' will be overwritten.

  • 'get' and 'set' accessor must have the same type.

  • Accessors must both be abstract or non-abstract.

  • Overload signatures must all be ______

  • Overload signature is not compatible with function implementation.

  • Individual declarations in merged declaration '{0}' must be all exported or all local.

  • Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.

  • Subtyping

    • Class '{0}' incorrectly extends base class '{1}'.
    • Class static side '{0}' incorrectly extends base class static side '{1}'.
    • Class '{0}' incorrectly implements interface '{1}'.
    • Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.
    • Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.
    • Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.
    • Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.
    • Interface '{0}' incorrectly extends interface '{1}'.
    • Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.
    • Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.
  • All declarations of '{0}' must have identical type parameters.

  • In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.

  • Namespace merging

    • A namespace declaration cannot be in a different file from a class or function with which it is merged.
    • A namespace declaration cannot be located prior to a class or function with which it is merged.
  • Module '{0}' is hidden by a local declaration with the same name.

    • should probably be changed to "namespace"
  • Types have separate declarations of a private property '{0}'.

  • Property '{0}' is protected but type '{1}' is not a class derived from '{2}'.

  • Property '{0}' is protected in type '{1}' but public in type '{2}'.

  • An AMD module cannot have multiple name assignments.

  • Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'

  • Export declaration conflicts with exported declaration of '{0}'.

  • Cannot redeclare identifier '{0}' in catch clause.

  • Module '{0}' uses 'export =' and cannot be used with 'export *'.

  • Base constructors must all have the same return type.

  • Overload signatures must all be abstract or non-abstract.

  • A module cannot have multiple default exports.

  • Type '{0}' has no properties in common with type '{1}'.

  • Base class expressions cannot reference class type parameters.

  • A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.

  • '{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead.

  • All declarations of '{0}' must have identical modifiers.
    Bonus?

  • A computed property name cannot reference a type parameter from its containing type.

  • Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'.

Original Post:

Often a diagnostic message can have additional location information. it is specially helpful in IDE's where clicking on the location can take you there. For instance

  • duplicate declaration errors, can have the other locations where the name was re-declared
  • type x not assignable to type y, a reference to where the target symbol's type is defined
  • implicit any errors, have a reference to the declaration of the container type
  • parameter type/number mismatch, have a reference tot he function declaration

VSCode is adding support for exposing a list of related diagnostics in microsoft/vscode#1927.

We can also expose this in --pretty.

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingDomain: Related Error SpansSpecifying regions for error messages/diagnostics on multiple locations.Meta-IssueAn issue about the team, or the direction of TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions