October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Keep 69 Pages in One TypeScript Array—Without Duplicating the Inventory

Keep the site’s page inventory in one canonical TypeScript array, derive consumer views from it, and distinguish that policy from file-based or data-generated framework routing.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For this site, keep its 69-page inventory in one canonical TypeScript array and have other code derive the views it needs. That is a project rule, not a requirement of TypeScript or every web framework. The number 69 is part of the assignment; it has not been independently verified as a live site count.

What “one array” should mean

The rule is most useful when it applies to the project’s page inventory: the authoritative record of which pages exist and their relevant metadata. Put that inventory in one module, then let navigation, page lookup, tests, or other consumers derive their own results from it. Avoid separately hand-maintaining another complete list of the same pages.

As an Amazon Associate I earn from qualifying purchases.

Do not read “nothing else may hold a list” as a ban on every array in the codebase. A navigation group, breadcrumb trail, content collection, query result, or generated route output can be a derived collection rather than a competing inventory. The policy needs to define that boundary; framework documentation does not establish what this site intends by “a list.”

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to implement the canonical registry

Keep the source in one module

Represent each page as an entry in one exported, typed array. Include only the fields consumers actually need, such as a path and a display label. A consumer should filter, map, or look up entries from this source instead of copying the inventory into a second handwritten array.

React Router’s framework convention shows route configuration as an array of route objects and uses satisfies RouteConfig to check that the configuration conforms to its route type. Its documentation also describes a file-based route convention, so an explicit array is an available design choice rather than a framework-wide mandate: React Router routes.ts documentation.

Expose a read-only type when consumers should not mutate it

TypeScript’s ReadonlyArray<T> removes mutating methods from the reference’s type and disallows indexed writes at compile time. The TypeScript Handbook describes it as “the same as Array<T> with all mutating methods removed,” allowing you to prevent changes through that reference: TypeScript Handbook: Interfaces.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

This is a compile-time restriction, not a runtime freeze. A type assertion can override it, and the type alone does not guarantee that no other reference can mutate the underlying array. Use it to make accidental mutation harder, not as a security or runtime immutability guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Derive views instead of maintaining copies

If a header needs only pages marked for navigation, filter the canonical array for that view. If a test needs all paths, map the same array to paths. These resulting arrays are fine when they are computed from the registry; the risk is a second manually curated inventory that can drift when pages change.

When one explicit array is—and is not—the right fit

Frameworks locate routes in different places. An explicit registry makes the inventory easy to inspect in one place, but file-based and data-generated routing can be more natural when the framework’s conventions or content model already define pages. The choice concerns where route definitions live and how they are produced; it is not a difference in whether TypeScript permits arrays.

Approach Where routes come from Dynamic pages and timing Consideration for a single inventory
Explicit typed configuration (React Router) A route-object array in the route configuration, with type conformance expressible using satisfies RouteConfig. Defined by the project’s route configuration; the cited documentation does not establish one universal timing model for all setups. Centralizes route declarations when the project chooses this convention. React Router also supports file-based routes, so this is not the only documented model. Source.
File-based routing (Next.js) Folders and special page files map to route segments. Dynamic segments are supported; route structure follows the filesystem convention. Route definitions are distributed across files rather than held in one project-owned array. Source.
File- and data-driven generation (Gatsby) Page files, data models, and APIs can create routes. Pages can be created from data; Gatsby documents a duplicate-path warning where the build may still finish and the last-created page is accessible. Multiple route producers make collisions worth checking. A central inventory may help expose conflicts, but it does not automatically prevent them without implementation details. Source.
File-based and generated routes (Astro) Routes can come from files, with dynamic routes generated from static path data. Static path data can supply dynamic routes at build time; consult the framework’s routing documentation for the relevant setup. A single registry is a project-level choice if the filesystem or content data already supplies the route set. Astro v6 routing documentation.

These approaches are not interchangeable in every application. If the site’s requirement is specifically that all 69 page records live in one TypeScript array, treat that as an architecture constraint and make any framework-generated routes consume or validate against it where practical. If the framework convention itself is the source of routes, calling a separate array canonical can instead create the duplication the policy is meant to avoid.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Checks that make the policy enforceable

  • Identify the one module that owns the page inventory and make additions or removals there.
  • Search for independent page inventories, not every array. Distinguish hand-maintained copies from computed views and transient results.
  • Have navigation and lookup code derive from the canonical entries, rather than maintaining separate lists of page paths.
  • Check that every declared path is unique. Gatsby documents that duplicate paths can warn while still building, with the last-created page accessible; a warning is not the same as a guaranteed build failure.
  • Use a read-only array type if consumers should not mutate the registry through their typed references, while remembering that TypeScript’s restriction is not a runtime freeze.

What the rule does not prove

No cited framework or TypeScript documentation establishes a measured time saving, performance gain, or error reduction from this exact one-array policy. Centralization can make the intended inventory easier to find and can reduce opportunities for handwritten copies to drift, but it does not by itself guarantee correct routes or prevent conflicts. Those outcomes depend on how the site validates and consumes its entries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.