Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created May 12, 2026 08:05
Show Gist options
  • Select an option

  • Save karthiks/2349b1d2908426a28cc0b6023dc23739 to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/2349b1d2908426a28cc0b6023dc23739 to your computer and use it in GitHub Desktop.
Reference Typescript config.ts
/**
* Helper to convert semantic version (e.g., 1.2.3) into a numeric code (10203)
* This ensures Android versionCode is always incrementing correctly.
*/
const getVersionCode = (version: string): number => {
const [major, minor, patch] = version.split('.').map(Number);
return major * 10000 + minor * 100 + patch;
};
const APP_VERSION = "1.2.3";
export const AppConfig = {
// Environment-based switching
apiEndpoint: __DEV__
? "http://localhost:3000"
: "https://api.production.com",
theme: "dark" as const,
// Version Management
version: APP_VERSION,
versionCode: getVersionCode(APP_VERSION),
// Feature flags
enableAnalytics: !__DEV__,
// Documentation for fellow devs
/** @deprecated Use apiEndpoint instead */
oldUrl: "https://old-api.com"
};
export type Config = typeof AppConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment