microsoft / microsoft/TypeScript

Support `export { x as default }` in namespace declarations

Offen
#24,164 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Search Terms

Suggestion

options for allow use import { xxx } from 'yyy'; when TS2497 resolves to a non-module entity

without warn or use // @ts-ignore

Error:(11, 19) TS2305: Module has no exported member 'isGitRoot'.
Error:(11, 36) TS2497: Module resolves to a non-module entity and cannot be imported using this construct.

Use Cases

Examples

demo.ts

import gitRoot, { isGitRoot } from 'git-root2';

git-root2

declare function gitRoot(cwd?: string): string;
declare namespace gitRoot {
    function isGitRoot(target: string): boolean;
    function async(cwd?: string): Promise<string>;
}
declare const _default: typeof gitRoot & {
    gitRoot(cwd?: string): string;
    default(cwd?: string): string;
    async(cwd?: string): Promise<string>;
};
export = _default;

Checklist

My suggestion meets these guidelines:
[x] This wouldn't be a breaking change in existing TypeScript / JavaScript code
[x] This wouldn't change the runtime behavior of existing JavaScript code
[ ] This could be implemented without emitting different JS based on the types of the expressions
[ ] This isn't a runtime feature (e.g. new expression-level syntax)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem demo.ts-Import und declare namespace/export = example im Issue und untersuche anschließend das durch TS2497 und TS2305 dargestellte Compilerverhalten. Die Aufgabe ist abgeschlossen, wenn die vorgeschlagene Namespace-Exportform den gezeigten Import ohne Warnung oder ts-ignore unterstützt und die erwarteten Diagnosen durch Tests abgedeckt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.