microsoft / microsoft/TypeScript

`@deprecated` nested namespace handling is buggy

Ouverte
#59,792 2 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Domain: JSDoc Help Wanted Possible Improvement
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

🔎 Search Terms

deprecated nested namespace

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

https://www.typescriptlang.org/play/?#code/FAegVGAEACAmCmAHATvAxgQwC71pMIwAdhgLbwDOiGa8kAYgPaMCMAdAEIbKQDewkSPAAeiRsiyQ0jIhUnDIAXkgsA3MAC+wYmUrVaDZuy4AvPgKGjxk6bPlKV6rcCatO3NsPWvjGE5-VtUBAQoJ1yKho6VwAmdzN+QRExCSkZOUgFZTVNbXAoOCRUTBw8AnC9KMNGOK4eRMsUm3T7bKcg2PdkAJdmWr8e7SA

💻 Code

/** @deprecated */
namespace Foo1.Bar {
  export const x = 1;
}

namespace Foo1.Baz {
  export const x = 1;
}

Foo1.Bar.x;
Foo1.Baz.x;
namespace Foo2.Baz {
  export const x = 1;
}

/** @deprecated */
namespace Foo2.Bar {
  export const x = 1;
}


Foo2.Bar.x;
Foo2.Baz.x;
🙁 Actual behavior

Usages of Foo1 are stricken through
image

But usages of Foo2 are not stricken through
image

Yet intellisense shows the tag in the hover for Foo2
image

🙂 Expected behavior

Either both Foo1 and Foo2 should be treated as deprecated, or neither should and instead the Bar in Foo1.Bar and Foo2.Bar should be treated as deprecated.

Additional information about the issue

@typescript-eslint recently released a new lint rule no-deprecated which reports a lint error whenever you use a thing marked with @deprecated.

A user mentioned to us that the rule reports incorrectly in certain cases (https://github.com/typescript-eslint/typescript-eslint/issues/9902).

Specifically in a case like this
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d1c172bdcfd4508405f4b233e11ccd7d8743f763/types/chrome/index.d.ts#L8553-L8556

We did some investigation and found that things can be pretty ambiguous when nested namespace declarations are marked @deprecated like this and TS itself struggles with it.


It's worth noting that the above behaviour is consistent between nested namespace shorthand (namespace Foo.Bar) and the non-shorthand style

Note you see similar behaviour for many declaration-merged things where TS's handling only makrs something as deprecated if the first definition is marked as deprecated, eg Enums.

But there are also cases where TS gets it right, eg Interfaces

Then there are weird cases like type/value shadowing where I'm not sure if TS is right or wrong -- depends on what you expect I guess.


I would love to see some clarification on what you guys think is the correct behaviour so that we can follow-suit!

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par les deux exemples de TypeScript Playground dans l’issue et comparez la manière dont la dépréciation est résolue pour Foo1 et Foo2. Examinez le rapport no-deprecated de @typescript-eslint associé et la déclaration chrome de DefinitelyTyped pour le comportement connexe. La tâche est terminée lorsqu’une décision claire et cohérente a été prise quant à savoir si le namespace externe ou le Bar imbriqué doit être deprecated.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Bug
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.