From c22c6309b83a52f207762c0fd46d2f5329108e4a Mon Sep 17 00:00:00 2001 From: Kylesoda <249518290+kylesoda@users.noreply.github.com> Date: Sun, 22 Feb 2026 17:47:55 -0500 Subject: [PATCH] feat: enhance type definitions and import structure across modules --- lib/core/config-defaults.ts | 7 ++++++- lib/core/fluent-url.ts | 7 ++++++- lib/core/serializer/query-serializer.ts | 2 ++ lib/core/serializer/url-serializer.ts | 2 ++ lib/shared/types/index.d.ts | 12 +++++------- package.json | 3 ++- pnpm-lock.yaml | 23 ++++++++++++++++++++++- tsconfig.build.json | 2 +- tsconfig.json | 3 ++- 9 files changed, 48 insertions(+), 13 deletions(-) diff --git a/lib/core/config-defaults.ts b/lib/core/config-defaults.ts index 7ac6624..d78620a 100644 --- a/lib/core/config-defaults.ts +++ b/lib/core/config-defaults.ts @@ -1,6 +1,11 @@ import { parseQuery, stringifyQuery } from '@/core/serializer/query-serializer' +import { parseUrl } from '@/core/serializer/url-serializer' import { deepClone } from '@/shared/helpers/deep-clone' -import { parseUrl } from './serializer/url-serializer' +import type { + FLuentUrlPlainObject, + FluentUrlConfig, + QuerySerializer, +} from '@/shared/types' export function normalizeConfig( config?: Partial, diff --git a/lib/core/fluent-url.ts b/lib/core/fluent-url.ts index 65b3faa..3529074 100644 --- a/lib/core/fluent-url.ts +++ b/lib/core/fluent-url.ts @@ -4,8 +4,13 @@ import { normalizeConfig, normalizeOptions, } from '@/core/config-defaults' +import { stringifyUrl } from '@/core/serializer/url-serializer' import { deepClone } from '@/shared/helpers/deep-clone' -import { stringifyUrl } from './serializer/url-serializer' +import type { + FLuentUrlPlainObject, + FluentUrlConfig, + QueriesPlainObject, +} from '@/shared/types' export class FluentUrl { private config: FluentUrlConfig diff --git a/lib/core/serializer/query-serializer.ts b/lib/core/serializer/query-serializer.ts index 8386f03..bc8cbf8 100644 --- a/lib/core/serializer/query-serializer.ts +++ b/lib/core/serializer/query-serializer.ts @@ -1,3 +1,5 @@ +import type { QuerySerializer } from '@/shared/types' + export const parseQuery: QuerySerializer['parseQuery'] = () => { throw new Error('Not implemented') } diff --git a/lib/core/serializer/url-serializer.ts b/lib/core/serializer/url-serializer.ts index ea0976c..1b93273 100644 --- a/lib/core/serializer/url-serializer.ts +++ b/lib/core/serializer/url-serializer.ts @@ -1,3 +1,5 @@ +import type { UrlSerializer } from '@/shared/types' + export const parseUrl: UrlSerializer['parseUrl'] = () => { throw new Error('Not implemented') } diff --git a/lib/shared/types/index.d.ts b/lib/shared/types/index.d.ts index 874dc5f..8eda3ad 100644 --- a/lib/shared/types/index.d.ts +++ b/lib/shared/types/index.d.ts @@ -1,8 +1,6 @@ -/** biome-ignore-all lint/correctness/noUnusedVariables: <> */ +export type QueriesPlainObject = Record -type QueriesPlainObject = Record - -interface FLuentUrlPlainObject { +export interface FLuentUrlPlainObject { protocol?: string hostname?: string paths: string[] @@ -11,12 +9,12 @@ interface FLuentUrlPlainObject { queries: QueriesPlainObject } -interface QuerySerializer { +export interface QuerySerializer { parseQuery: (str: string) => QueriesPlainObject stringifyQuery: (obj: QueriesPlainObject) => string } -interface UrlSerializer { +export interface UrlSerializer { parseUrl: (args: { str: string parseQuery?: QuerySerializer['parseQuery'] @@ -27,7 +25,7 @@ interface UrlSerializer { }) => string } -interface FluentUrlConfig { +export interface FluentUrlConfig { parseQuery: Serializer['parseQuery'] stringifyQuery: Serializer['stringifyQuery'] } diff --git a/package.json b/package.json index 4ef869a..075fe1f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "rimraf": "6.1.3", "tsc-alias": "1.8.16", "tsx": "4.21.0", - "typescript": "^5.9.3", + "typescript": "5.9.3", + "typescript-transform-paths": "3.5.6", "vitest": "4.0.18" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e39a8b9..22db5eb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,8 +24,11 @@ importers: specifier: 4.21.0 version: 4.21.0 typescript: - specifier: ^5.9.3 + specifier: 5.9.3 version: 5.9.3 + typescript-transform-paths: + specifier: ^3.5.6 + version: 3.5.6(typescript@5.9.3) vitest: specifier: 4.0.18 version: 4.0.18(@types/node@25.3.0)(tsx@4.21.0) @@ -580,6 +583,10 @@ packages: resolution: {integrity: sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==} engines: {node: 18 || 20 || >=22} + minimatch@9.0.6: + resolution: {integrity: sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==} + engines: {node: '>=16 || 14 >=14.17'} + minipass@7.1.3: resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} engines: {node: '>=16 || 14 >=14.17'} @@ -710,6 +717,11 @@ packages: engines: {node: '>=18.0.0'} hasBin: true + typescript-transform-paths@3.5.6: + resolution: {integrity: sha512-3eQTG6Ogt+pgPEh45uX2s9OwcfAVjWnyNO+osjYcOqYaWDVMIFUkqW8e0O1cOaVwdMqQFQf6alDT+76xmeS2Ag==} + peerDependencies: + typescript: '>=3.6.5' + typescript@5.9.3: resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} @@ -1210,6 +1222,10 @@ snapshots: dependencies: brace-expansion: 5.0.2 + minimatch@9.0.6: + dependencies: + brace-expansion: 5.0.2 + minipass@7.1.3: {} mylas@2.1.14: {} @@ -1341,6 +1357,11 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + typescript-transform-paths@3.5.6(typescript@5.9.3): + dependencies: + minimatch: 9.0.6 + typescript: 5.9.3 + typescript@5.9.3: {} undici-types@7.18.2: {} diff --git a/tsconfig.build.json b/tsconfig.build.json index da7a683..b739eb0 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -4,7 +4,7 @@ "rootDir": "./lib", }, "exclude": [ - "*.test.ts", + "**/*.test.ts", "vitest.config.ts", "sandbox/**/*", ] diff --git a/tsconfig.json b/tsconfig.json index 2a42008..538bb56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -33,7 +33,8 @@ } ], "typeRoots": [ - "lib/shared/types" + "lib/shared/types", + "node_modules/@types" ] }, "include": [