However, UpToDateCheckRequest is used in the type alias before the constant is declared. This is allowed in TypeScript because type aliases are not evaluated at runtime — they are erased during compilation — so the forward reference is fine.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Just be aware that if you ever try to use the value of UpToDateCheckRequest before it's declared (e.g., in runtime code), that would be a problem.
User
This is giving me errors when compiling export type GetServersAtAddressResponse_properties_response_properties_success =
z.infer<
typeof GetServersAtAddressResponse_properties_response_properties_success
the value that ends up in the runtime variable is a plain ZodBoolean instance.
At the same time you try to create a type alias that depends on that variable:
ts
export type GetServersAtDateCheckResponse_properties_response_properties_success =
z.infer<typeof GetServersAtAddressResponse_properties_response_properties_success>
Because the variable is declared with const, TypeScript’s type checker has to evaluate the type of the variable before it can resolve the typeof in the type alias.
With primitive schemas (z.boolean(), z.string(), etc.) the compiler sometimes gets confused and reports an error like:
code
'GetServersAtAddressResponse_properties_response_properties_success' is referenced directly or indirectly in its own type annotation.
With object schemas (z.object(...)) the compiler is able to defer the evaluation more gracefully, so the forward reference is accepted.
How to fix it
Split the declaration so the type alias comes after the variable:
Yes — the fact that one IDE shows zero errors while another complains is almost always down to which version of TypeScript the editor is using, not to the code itself.
What’s happening:
TypeScript ≤ 5.1 (and some early 5.2 builds) had a bug where forward references like export type Foo = z.infer<typeof Foo>
were incorrectly rejected when the runtime value was a primitive schema (z.boolean(), z.number(), etc.).
Object schemas (z.object(...)) were accepted.
TypeScript ≥ 5.3 fixed that bug. The compiler now allows the forward reference for both primitive and object schemas.
Editors bundle their own copy of TypeScript.
VS Code 1.85+ ships TS 5.3+ → no error.
An older WebStorm, or VS Code with an explicit "typescript.tsdk" pointing to an older tsc, will still show the error.
So:
The code you posted is valid in any recent TypeScript.
If an IDE flags it, check the TypeScript version it is using (bottom-right in VS Code, or Settings → Languages & Frameworks → TypeScript in JetBrains IDEs) and update or point it to a newer one.
User
How can I check the version?
Assistant
Pick the editor you’re using:
VS Code
Open any .ts file.
Look at the blue TypeScript version badge in the bottom-right status bar (it shows something like 5.3.2).
Click it → a menu pops up showing
• “Use VS Code’s Version” (the bundled one)
• “Use Workspace Version” (if you have a local node_modules/typescript)
• The exact path and version of each.
If you want to force a specific version, add to .vscode/settings.json:
@description Response containing a list of all public Steam applications. This endpoint requires no parameters.
*/
export interface GetAppListResponse {
applist: GetAppListResponse_properties_applist;
}
/*** Parameters for the ISteamApps/GetServersAtAddress/v1 endpoint.
Assistant
typebox-codegen (and most other “schema-from-TypeScript” tools) expect the file to contain only the interfaces you want to convert.
Anything that is not a plain interface – e.g. export type … = z.infer<…> or export const … = z.object(…) – will either be ignored or will make the tool bail out.
In the file you pasted there are only interfaces, so the generator should be happy.
If you previously fed it the file that also contained the Zod bits, that would explain why it complained.
So:
Keep the file you just showed (pure interfaces).
Run the generator against that file.
Keep the Zod/TypeBox/whatever runtime schemas in a separate file if you still need them.
That should eliminate any spurious errors from typebox-codegen.
User
the generator outputs this, which contains duplicates for some reason import { z } from 'zod'
export type GetServersAtAddressResponse_properties_response_properties_servers_items_properties_addr =
z.infer<
typeof GetServersAtAddressResponse_properties_response_properties_servers_items_properties_addr
Assistant
typebox-codegen (and the underlying typescript-json-schema) is walking the AST depth-first and emitting a schema for every type it encounters, including the anonymous “property types” that TypeScript creates for each member of an interface.
Because your interfaces are flattened (you already broke out every nested object into its own interface), the tool still sees those leaf interfaces and generates a schema for each one, then later re-uses the same schema when it reaches the parent interface → you get duplicates.
Nothing is technically wrong with the output, but it is noisy.
How to get a clean file
Don’t flatten the interfaces in the input.
Feed the generator a single interface per request/response and let it create the nested schemas itself; it will not emit duplicates.
Output will be one z.object for GetServersAtAddressResponse and anonymous inline objects for the nested parts.
If you must keep the flattened interfaces, post-process the file:
Run the generator.
Pipe the result through a small script that keeps only the schemas whose name matches the top-level interfaces you care about (or deduplicates identical variable initialisers).
Use a different generator that supports a --noExtraProps / --onlyTopLevel flag (e.g. zod-to-ts or ts-to-zod with the appropriate options).
In short: the duplicates are expected behaviour for the tool when the input is already fully exploded into tiny interfaces; either change the input shape or post-process the output.
@description Parameters for getting game server information by IP address.
/
export interface GetServersAtAddressRequest {
/*
@format ip
@description The IP address to query. Can also be a hostname.
*/
addr: string;
}
export interface GetServersAtAddressResponse_properties_response {
/** @description True if the request was successful and servers were found. /
success: boolean;
/* @description An array of server information objects. May be omitted on failure. /
servers?: ServerInfo[];
/* @description An error message, if success is false. */
message?: string;
}
/*** The response from the ISteamApps/GetServersAtAddress/v1 endpoint.
@description Response containing a list of game servers at a given address.
*/
export interface GetServersAtAddressResponse {
response: GetServersAtAddressResponse_properties_response;
}
/*** Parameters for the ISteamApps/UpToDateCheck/v1 endpoint.
@description Parameters for checking if a game version is the latest.
/
export interface UpToDateCheckRequest {
/*
@minimum 1
@description The AppID of the game to check.
/
appid: number;
/*
@minimum 1
@description The version number to check.
*/
version: number;
}
export interface UpToDateCheckResponse_properties_response {
/** @description True if the request was successful. /
success: boolean;
/* @description True if the provided version is the latest. /
up_to_date: boolean;
/* @description True if the provided version is a public, listable version. /
version_is_listable: boolean;
/*
* @minimum 1
* @description The latest version, if up_to_date is false.
/
required_version?: number;
/* @description A message describing the status. */
message?: string;
}
/*** The response from the ISteamApps/UpToDateCheck/v1 endpoint.
@description Response indicating if a game version is current.
*/
export interface UpToDateCheckResponse {
response: UpToDateCheckResponse_properties_response;
}