Skip to content

[codex] Add generated permissive MTA input types#4

Merged
gtokman merged 2 commits into
mainfrom
codex/generated-known-types
May 27, 2026
Merged

[codex] Add generated permissive MTA input types#4
gtokman merged 2 commits into
mainfrom
codex/generated-known-types

Conversation

@gtokman
Copy link
Copy Markdown
Contributor

@gtokman gtokman commented May 26, 2026

Summary

  • generate known route and stop literal unions from the hosted stops snapshot
  • expose permissive autocomplete types with Known | (string & {}) so new MTA values still work
  • narrow SDK query inputs for subway, bus, alerts, and nearby stops while keeping runtime behavior unchanged
  • add bun run generate:types to refresh generated types

Verification

  • bun run typecheck
  • bun test

@gtokman gtokman requested a review from Copilot May 26, 2026 22:53
@gtokman gtokman marked this pull request as ready for review May 26, 2026 22:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds generated permissive TypeScript types for known MTA routes and stops, then applies them to SDK query inputs while preserving arbitrary string support for newer values.

Changes:

  • Adds generated Known* route/stop literal unions and AutocompleteString wrapper aliases.
  • Narrows public query input types for subway, bus, alerts, and nearby stops.
  • Adds a Bun generation script, package script, README note, and root type re-export.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Introduces permissive autocomplete aliases and applies them to query interfaces.
src/generated.ts Adds generated literal unions for known routes and stops.
scripts/generate-known-types.ts Adds hosted snapshot-based type generation.
README.md Documents generated autocomplete and refresh command.
package.json Adds generation script and includes scripts in package files.
index.ts Uses the named subway query type and re-exports generated types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/generate-known-types.ts Outdated
return /^[A-Z0-9]{1,2}$/.test(routeId)
}

const routeIds = routeEntries.flatMap(([routeId]) => aliasesForRoute(routeId))
Comment thread README.md Outdated
Comment on lines +80 to +82
Route and stop inputs include generated autocomplete for known MTA values while
remaining permissive for future route and stop additions. Refresh the generated
types from the hosted stops snapshot with `bun run generate:types`.
Comment thread scripts/generate-known-types.ts Outdated
@@ -0,0 +1,105 @@
import { writeFileSync } from "node:fs"
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3a9e0680a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/generate-known-types.ts Outdated
}

const routeIds = routeEntries.flatMap(([routeId]) => aliasesForRoute(routeId))
const subwayRoutes = routeIds.filter((routeId) => routeType(routeId) === 1 || looksLikeSubwayRoute(routeId))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include SIR in generated subway route union

Treating subway routes as routeType === 1 or a 1–2 character fallback excludes the Staten Island Railway route IDs (SI/SIR) from KnownSubwayRoute, even though this SDK’s subway client supports SIR in defaultEndpoints.subwayFeeds and SubwayArrivalQuery accepts subway feed routes. As generated, KnownRoute includes SI/SIR but KnownSubwayRoute does not, so typed consumers lose autocomplete for a valid subway route and may incorrectly assume it is unsupported.

Useful? React with 👍 / 👎.

fix: require snapshot URL for type generation
@gtokman gtokman force-pushed the codex/generated-known-types branch from e847f3a to 3debc79 Compare May 27, 2026 00:32
@gtokman gtokman merged commit 3ca55fb into main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants