microsoft / microsoft/TypeScript
`@deprecated` nested namespace handling is buggy
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
deprecated nested namespace
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 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
But usages of Foo2 are not stricken through
Yet intellisense shows the tag in the hover for Foo2
🙂 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!
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con i due esempi di TypeScript Playground nell’issue e confronta il modo in cui viene risolta la deprecation per Foo1 e Foo2. Esamina il report no-deprecated di @typescript-eslint collegato e la dichiarazione chrome di DefinitelyTyped per il comportamento correlato. Il lavoro è completato quando è stata presa una decisione chiara e coerente sul fatto che debba essere deprecated il namespace esterno o il Bar annidato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100