Spurious TS4094 "exported anonymous class type may not be private" error after upgrading from TS6 to TS7
@weswigham arbeitet bereits daran.
Seit 14.9.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
🔎 Search Terms
TS4094, exported anonymous class, private, declaration
🕗 Version & Regression Information
- This changed between versions 6.0.3 and 7.0.2
⏯ Playground Link
https://github.com/jedwards1211/ts-4094-regression
💻 Code
import ZodRoute from "zod-route-schemas";
import z from "zod";
export const organization = new ZodRoute(
"/org/:organizationId",
z.object({ organizationId: z.number() }),
);
🙁 Actual behavior
> tsc
src/index.ts:4:14 - error TS4094: Property 'parts' of exported anonymous class type may not be private or protected.
4 export const organization = new ZodRoute(
~~~~~~~~~~~~
src/index.ts:4:14 - Add a type annotation to the variable organization.
4 export const organization = new ZodRoute(
~~~~~~~~~~~~
src/index.ts:4:14 - error TS4094: Property 'typeHints' of exported anonymous class type may not be private or protected.
4 export const organization = new ZodRoute(
~~~~~~~~~~~~
src/index.ts:4:14 - Add a type annotation to the variable organization.
4 export const organization = new ZodRoute(
~~~~~~~~~~~~
I don't see what the problem is here, because as you can see below, the generated .d.ts would have the private field types from the class declaration in zod-route-schemas.
🙂 Expected behavior
Outputs the following .d.ts like TS5/6:
import ZodRoute from "zod-route-schemas";
import z from "zod";
export declare const organization: ZodRoute<"/org/:organizationId", z.ZodObject<{
organizationId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
organizationId: number;
}, {
organizationId: number;
}>, z.ZodType<{
organizationId: number;
}, any, {
organizationId: number;
}>, z.ZodType<{
organizationId: number;
}, any, {
organizationId: number;
}>>;
//# sourceMappingURL=index.d.ts.map
Additional information about the issue
Doesn't happen with "module": "preserve", but happens with "commonjs", "nodenext", maybe others
ZodRoute declaration in zod-route-schemas/index.d.ts:
declare class ZodRoute<Pattern extends string, Schema extends SchemaForPattern<Pattern>, FormatSchema extends InvertSchema<Schema> = InvertSchema<Schema>, PartialFormatSchema extends PartialSchema<FormatSchema> = PartialSchema<FormatSchema>> {
readonly pattern: Pattern;
readonly schema: Schema;
private parts;
readonly formatSchema: FormatSchema;
readonly partialFormatSchema: PartialFormatSchema;
readonly exact: boolean;
private typeHints?;
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64322 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Possible Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64278 · 1 Kommentar · 1 Reaktion ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/TypeScript#64118 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64094 ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#63959 · 5 Kommentare ·
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
kubernetes-sigs/prow#953 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
caddyserver/caddy#8046 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
-
L1 recommended for recruits
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
optimization optimization:agents-md-curator
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
githubnext/gh-aw-cao#13143 ·