microsoft / microsoft/TypeScript
symbolToName does handle exports of namespaces
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 3.2.2
Search Terms: symbolToName, exports, declaration, .d.ts
TypeScript cannot emit the name for a symbol that's declared in an inner namespace but re-exported in the outer namespace. That is, emitting the type name of a symbol does not take an alias created by an export {x as y} statement into account.
This comes up when trying to use the chrome.debugger declaration file. Because debugger is a reserved keyword, the .d.ts is defined using a fake, unexported inner namespace called _debugger, and re-exports it using export {_debugger as debugger};. TypeScript then cannot produce .d.ts files when trying to generate the name for a symbol.
Code
// decl.d.ts
declare module chrome {
namespace _debugger {
export class Foo {}
}
export function getFoo(): debugger.Foo;
export {_debugger as debugger};
}
// user.ts
export const x = chrome.getFoo();
Run tsc --declaration.
Expected behavior:
// user.d.ts
export declare const x: chrome.debugger.Foo;
Actual behavior:
test.ts:1:14 - error TS4025: Exported variable 'x' has or is using private name '_debugger.Foo'.
1 export const x = chrome.getFoo();
~
Playground Link: n/a
Related Issues:
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
Riproduci il problema con decl.d.ts e user.ts eseguendo tsc --declaration, quindi traccia la gestione di symbolToName da parte del compilatore per il namespace _debugger riesportato. Confronta la dichiarazione generata con il nome atteso chrome.debugger.Foo e usa, se disponibili, i test esistenti del compilatore relativi all’emissione delle dichiarazioni per verificare il fix.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100