/** * Globber interface. */ interface IGlobber { /** * Globs for directory names. * * @param root */ globDirs(this: void, root: string, patterns: Array, ignore?: Array): Promise>; } /** * Service for fetching monorepo workspaces in a standardized format agnostic of the package manager used. * It is used to allow syncing all types in a workspace when run from the root of a monorepo. */ interface IWorkspaceResolverService { /** * Reads, parses, and normalizes a workspaces configuration from the following files, in this order: * - `package.json` `workspaces` field, as an array of globs. * - `package.json` `workspaces` field, as an object with a `packages` field, which is an array of globs. * - `pnpm-workspace.yaml` `packages` field, as an array of globs. * * Path is relative to the current working directory. * Note that this returns a list of directories, not paths to the manifests themselves. */ getWorkspaces(this: void, packageJson: IPackageFile, root: string, globber: IGlobber, ignored: IWorkspacesArray): Promise; } /** * @example * ```json * "workspaces": [ * "packages/*", * ] * ``` */ type IWorkspacesArray = Array; /** * @example * ```yaml * packages: * - 'packages/*' * ``` */ interface IWorkspacesObject { packages?: IWorkspacesArray; } /** * @see {@link IWorkspacesArray} */ type NpmWorkspacesConfig = IWorkspacesArray; /** * Yarn is a special snowflake. * * @example * ```json * "workspaces": { * "packages": [ * "packages/*", * ], * "nohoist": [] * } * ``` */ type YarnWorkspacesConfig = IWorkspacesArray | (IWorkspacesObject & { nohoist?: Array; }); /** * @see {@link IWorkspacesArray} */ type BunWorkspacesConfig = IWorkspacesArray; /** * Section in `package.json` representing workspaces. */ type IWorkspacesSection = NpmWorkspacesConfig | YarnWorkspacesConfig | BunWorkspacesConfig; /** * The guts of the program. */ export interface ITypeSyncer { sync(this: void, filePath: string, flags: ICLIArguments["flags"]): Promise; } /** * Sync options. */ export interface ISyncOptions { /** * Ignore certain deps. */ ignoreDeps?: Array; /** * Ignore packages whose names match any of these glob patterns. */ ignorePackages?: Array; /** * Skip resolution of certain projects in the workspace. */ ignoreProjects?: IWorkspacesArray; } /** * Package.json file. */ export interface IPackageFile { name?: string; dependencies?: IDependenciesSection; devDependencies?: IDependenciesSection; peerDependencies?: IDependenciesSection; optionalDependencies?: IDependenciesSection; workspaces?: IWorkspacesSection; [key: string]: unknown; } /** * Section in package.json representing dependencies. */ export type IDependenciesSection = Record; /** * Package + version record, collected from the {"package": "^1.2.3"} sections. */ export interface IPackageVersion { name: string; version: string; } /** * Describes how a package may be typed. */ export interface IPackageTypingDescriptor { typingsName: string; codePackageName: string; typesPackageName: string; } /** * A type definition with the corresponding code package name. */ export interface ISyncedTypeDefinition extends IPackageTypingDescriptor { codePackageName: string; } /** * Sync result. */ export interface ISyncResult { /** * The files that were synced. */ syncedFiles: Array; } /** * A file that was synced. */ export interface ISyncedFile { /** * The cwd-relative path to the synced file. */ filePath: string; /** * The package file that was synced. */ package: IPackageFile; /** * The new typings that were added. */ newTypings: Array; } /** * Dependency sections. */ export declare enum IDependencySection { dev = "dev", deps = "deps", optional = "optional", peer = "peer" } /** * CLI arguments. */ export interface ICLIArguments { flags: Record; args: Array; } /** * Config Service. */ export interface IConfigService { /** * Get typesync config. */ readConfig(this: void, filePath: string, flags: ICLIArguments["flags"]): Promise; } export declare function createConfigService(): IConfigService; /** * Version descriptor for versions returned in remote package info. */ interface IPackageVersionInfo { version: string; deprecated: boolean; containsInternalTypings: boolean; } /** * Fetches info about a package. */ export interface IPackageSource { /** * Fetches package info from an external source. * * @param packageName */ fetch(this: void, packageName: string): Promise; } /** * Interface for the Package Info structure. */ export interface IPackageInfo { name: string; latestVersion: string; versions: Array; } /** * Creates a package source. */ export declare function createPackageSource(): IPackageSource; /** * File service. */ interface IPackageJSONService { /** * Reads and parses JSON from the specified file. Path is relative to the current working directory. */ readPackageFile(this: void, filePath: string): Promise; /** * Writes the JSON to the specified file. */ writePackageFile(this: void, filePath: string, fileContents: IPackageFile): Promise; } /** * Creates a type syncer. * * @param packageJSONservice * @param typeDefinitionSource */ export declare function createTypeSyncer(packageJSONService: IPackageJSONService, workspaceResolverService: IWorkspaceResolverService, packageSource: IPackageSource, configService: IConfigService, globber: IGlobber): ITypeSyncer; export {};