microsoft / microsoft/TypeScript

`@deprecated` nested namespace handling is buggy

Abierto
#59,792 2 comentarios 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Domain: JSDoc Help Wanted Possible Improvement
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

🔎 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!

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con los dos ejemplos de TypeScript Playground del issue y compara cómo se resuelve la deprecación para Foo1 y Foo2. Revisa el informe no-deprecated de @typescript-eslint enlazado y la declaración de chrome de DefinitelyTyped para comprobar el comportamiento relacionado. La tarea se considera terminada cuando haya una decisión clara y coherente sobre si se debe marcar como deprecated el namespace externo o el Bar anidado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.