From ba77154e34c2fe2020da02e68ab39561f6af0f50 Mon Sep 17 00:00:00 2001 From: Vlad Rindevich Date: Mon, 4 Nov 2024 10:57:16 +0200 Subject: [PATCH] chore: rename `d.ts` files to `t.ts` to resolve `skipLibCheck` issue (#892) * chore: move to t.ts files to address skipLibCheck issue * chore: rename global file as well * refactor: update latest code --- scripts/build.ts | 2 +- src/index.ts | 4 ++-- src/{mod.d.ts => mod.t.ts} | 0 src/resolver/generateUrls.ts | 2 +- src/resolver/matchPath.ts | 2 +- src/resolver/matchRoute.ts | 2 +- src/resolver/resolveRoute.ts | 2 +- src/resolver/resolver.ts | 2 +- src/resolver/{types.d.ts => types.t.ts} | 0 src/resolver/utils.ts | 2 +- src/router.ts | 2 +- src/triggers/click.ts | 2 +- src/triggers/navigation.ts | 2 +- src/triggers/popstate.ts | 2 +- src/{types.d.ts => types.t.ts} | 2 +- src/utils.ts | 2 +- src/{v1-compat.d.ts => v1-compat.t.ts} | 11 +++++++++-- test/resolver/generateUrls.spec.ts | 2 +- test/resolver/matchRoute.spec.ts | 2 +- test/resolver/resolver.spec.ts | 2 +- test/router/lifecycle-events.spec.ts | 4 ++-- test/router/parent-layout.spec.ts | 2 +- test/router/router.spec.ts | 2 +- 23 files changed, 31 insertions(+), 24 deletions(-) rename src/{mod.d.ts => mod.t.ts} (100%) rename src/resolver/{types.d.ts => types.t.ts} (100%) rename src/{types.d.ts => types.t.ts} (99%) rename src/{v1-compat.d.ts => v1-compat.t.ts} (91%) diff --git a/scripts/build.ts b/scripts/build.ts index eb2cbd9c..d8a54c98 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -9,7 +9,7 @@ const root = new URL('../', import.meta.url); const [packageJson, entryPoints] = await Promise.all([ readFile(new URL('package.json', root), 'utf8').then(JSON.parse) as Promise, - glob('src/**/*.{ts,tsx}', { ignore: ['**/*.d.ts'] }), + glob('src/**/*.{ts,tsx}', { ignore: ['**/*.t.ts'] }), ]); await build({ diff --git a/src/index.ts b/src/index.ts index 395c77ec..e228bdd3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ export * from './router.js'; -export type * from './types.js'; -export type * from './v1-compat.js'; +export type * from './types.t.js'; +export type * from './v1-compat.t.js'; export { processNewChildren, amend, diff --git a/src/mod.d.ts b/src/mod.t.ts similarity index 100% rename from src/mod.d.ts rename to src/mod.t.ts diff --git a/src/resolver/generateUrls.ts b/src/resolver/generateUrls.ts index 31fe7578..e492cd50 100644 --- a/src/resolver/generateUrls.ts +++ b/src/resolver/generateUrls.ts @@ -10,7 +10,7 @@ import { parse, type ParseOptions, type Token, tokensToFunction, type TokensToFunctionOptions } from 'path-to-regexp'; import type { EmptyObject, Writable } from 'type-fest'; import Resolver from './resolver.js'; -import type { ChildrenCallback, IndexedParams, Params, Route } from './types.js'; +import type { ChildrenCallback, IndexedParams, Params, Route } from './types.t.js'; import { getRoutePath, isString } from './utils.js'; export type UrlParams = Readonly | number | string>>; diff --git a/src/resolver/matchPath.ts b/src/resolver/matchPath.ts index 049a5eab..1783fabb 100644 --- a/src/resolver/matchPath.ts +++ b/src/resolver/matchPath.ts @@ -9,7 +9,7 @@ import { type Key, pathToRegexp } from 'path-to-regexp'; import type { Writable } from 'type-fest'; -import type { IndexedParams } from '../types.js'; +import type { IndexedParams } from '../types.t.js'; import { resolvePath } from './utils.js'; export interface RegExpExecOptArray extends ReadonlyArray { diff --git a/src/resolver/matchRoute.ts b/src/resolver/matchRoute.ts index 5c0092d8..2d62e155 100644 --- a/src/resolver/matchRoute.ts +++ b/src/resolver/matchRoute.ts @@ -9,7 +9,7 @@ import type { Key } from 'path-to-regexp'; import matchPath, { type Match } from './matchPath.js'; -import type { IndexedParams, Route } from './types.js'; +import type { IndexedParams, Route } from './types.t.js'; import { getRoutePath, unwrapChildren } from './utils.js'; export type MatchWithRoute = Match & diff --git a/src/resolver/resolveRoute.ts b/src/resolver/resolveRoute.ts index 9e8b43a2..4aa4e457 100644 --- a/src/resolver/resolveRoute.ts +++ b/src/resolver/resolveRoute.ts @@ -6,7 +6,7 @@ * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ -import type { ActionResult, MaybePromise, RouteContext } from './types.js'; +import type { ActionResult, MaybePromise, RouteContext } from './types.t.js'; import { isFunction } from './utils.js'; /** @internal */ diff --git a/src/resolver/resolver.ts b/src/resolver/resolver.ts index a9b73a15..2ca4fdb3 100644 --- a/src/resolver/resolver.ts +++ b/src/resolver/resolver.ts @@ -9,7 +9,7 @@ import type { EmptyObject } from 'type-fest'; import matchRoute, { type MatchWithRoute } from './matchRoute.js'; import defaultResolveRoute from './resolveRoute.js'; -import type { ActionResult, Route, Match, MaybePromise, ResolveContext, RouteContext } from './types.js'; +import type { ActionResult, Route, Match, MaybePromise, ResolveContext, RouteContext } from './types.t.js'; import { getNotFoundError, getRoutePath, isString, NotFoundError, notFoundResult, toArray } from './utils.js'; function isDescendantRoute( diff --git a/src/resolver/types.d.ts b/src/resolver/types.t.ts similarity index 100% rename from src/resolver/types.d.ts rename to src/resolver/types.t.ts diff --git a/src/resolver/utils.ts b/src/resolver/utils.ts index d8ba33aa..88ef7dd5 100644 --- a/src/resolver/utils.ts +++ b/src/resolver/utils.ts @@ -1,4 +1,4 @@ -import type { ChildrenCallback, Route, RouteContext } from './types.js'; +import type { ChildrenCallback, Route, RouteContext } from './types.t.js'; /** * {@inheritDoc "".NotFoundError} diff --git a/src/router.ts b/src/router.ts index 600f24bb..b6f1399f 100644 --- a/src/router.ts +++ b/src/router.ts @@ -29,7 +29,7 @@ import type { RouterOptions, ActionValue, NextResult, -} from './types.js'; +} from './types.t.js'; import { amend, copyContextWithoutNext, diff --git a/src/triggers/click.ts b/src/triggers/click.ts index 4ecff46d..2d099ab4 100644 --- a/src/triggers/click.ts +++ b/src/triggers/click.ts @@ -1,4 +1,4 @@ -import type { NavigationTrigger } from '../types.js'; +import type { NavigationTrigger } from '../types.t.js'; import { fireRouterEvent } from '../utils.js'; /* istanbul ignore next: coverage is calculated in Chrome, this code is for IE */ diff --git a/src/triggers/navigation.ts b/src/triggers/navigation.ts index a5cec24d..0e98522c 100644 --- a/src/triggers/navigation.ts +++ b/src/triggers/navigation.ts @@ -1,4 +1,4 @@ -import type { NavigationTrigger } from '../types.js'; +import type { NavigationTrigger } from '../types.t.js'; import CLICK from './click.js'; import POPSTATE from './popstate.js'; diff --git a/src/triggers/popstate.ts b/src/triggers/popstate.ts index 08caf15c..32643266 100644 --- a/src/triggers/popstate.ts +++ b/src/triggers/popstate.ts @@ -1,4 +1,4 @@ -import type { NavigationTrigger } from '../types.js'; +import type { NavigationTrigger } from '../types.t.js'; import { fireRouterEvent } from '../utils.js'; function vaadinRouterGlobalPopstateHandler(event: PopStateEvent) { diff --git a/src/types.d.ts b/src/types.t.ts similarity index 99% rename from src/types.d.ts rename to src/types.t.ts index 2ce30a08..b8a6c25c 100644 --- a/src/types.d.ts +++ b/src/types.t.ts @@ -12,7 +12,7 @@ import type { PrimitiveParamValue, Route as _Route, RouteContext as _RouteContext, -} from './resolver/types.js'; +} from './resolver/types.t.js'; import type { Router } from './router.js'; export type { ResolutionError, IndexedParams, Params, ParamValue, PrimitiveParamValue }; diff --git a/src/utils.ts b/src/utils.ts index cf52ca27..3b7b6af5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,7 +11,7 @@ import type { RouteContext, RouterLocation, WebComponentInterface, -} from './types.js'; +} from './types.t.js'; /** @internal */ export function ensureRoute(route?: Route): void { diff --git a/src/v1-compat.d.ts b/src/v1-compat.t.ts similarity index 91% rename from src/v1-compat.d.ts rename to src/v1-compat.t.ts index 496d95c3..aa04528e 100644 --- a/src/v1-compat.d.ts +++ b/src/v1-compat.t.ts @@ -1,7 +1,14 @@ /* eslint-disable max-classes-per-file */ -import type { MaybePromise } from './resolver/types'; -import type { RouteContext, Route, ActionResult, ChildrenCallback, WebComponentInterface } from './types'; +import type { MaybePromise } from './resolver/types.t.js'; +import type { + Commands, + RouteContext, + Route, + ActionResult, + ChildrenCallback, + WebComponentInterface, +} from './types.t.js'; /** * Action result describing an HTML element to render. diff --git a/test/resolver/generateUrls.spec.ts b/test/resolver/generateUrls.spec.ts index b7cb3b94..f093bd4a 100644 --- a/test/resolver/generateUrls.spec.ts +++ b/test/resolver/generateUrls.spec.ts @@ -14,7 +14,7 @@ import sinonChai from 'sinon-chai'; import generateUrls, { type StringifyQueryParams } from '../../src/resolver/generateUrls.js'; import Resolver from '../../src/resolver/resolver.js'; import '../setup.js'; -import type { Route } from '../../src/resolver/types.js'; +import type { Route } from '../../src/resolver/types.t.js'; use(chaiDom); use(sinonChai); diff --git a/test/resolver/matchRoute.spec.ts b/test/resolver/matchRoute.spec.ts index 1f24bd4b..cb712687 100644 --- a/test/resolver/matchRoute.spec.ts +++ b/test/resolver/matchRoute.spec.ts @@ -11,7 +11,7 @@ import chaiDom from 'chai-dom'; import sinonChai from 'sinon-chai'; import matchRoute from '../../src/resolver/matchRoute.js'; import '../setup.js'; -import type { Route } from '../../src/resolver/types.js'; +import type { Route } from '../../src/resolver/types.t.js'; use(chaiDom); use(sinonChai); diff --git a/test/resolver/resolver.spec.ts b/test/resolver/resolver.spec.ts index ee2e7455..a62f9250 100644 --- a/test/resolver/resolver.spec.ts +++ b/test/resolver/resolver.spec.ts @@ -15,7 +15,7 @@ import sinonChai from 'sinon-chai'; import type { EmptyObject } from 'type-fest'; import Resolver, { ResolutionError } from '../../src/resolver/resolver.js'; import '../setup.js'; -import type { Route, RouteContext } from '../../src/resolver/types.js'; +import type { Route, RouteContext } from '../../src/resolver/types.t.js'; use(chaiDom); use(sinonChai); diff --git a/test/router/lifecycle-events.spec.ts b/test/router/lifecycle-events.spec.ts index 5ca222e9..407e9cc7 100644 --- a/test/router/lifecycle-events.spec.ts +++ b/test/router/lifecycle-events.spec.ts @@ -3,7 +3,7 @@ import sinon from 'sinon'; import { Router, type RouterLocation } from '../../src/index.js'; import Resolver from '../../src/resolver/resolver.js'; import '../setup.js'; -import type { MaybePromise } from '../../src/resolver/types.js'; +import type { MaybePromise } from '../../src/resolver/types.t.js'; import type { Commands, Route, @@ -11,7 +11,7 @@ import type { VaadinRouterErrorEvent, VaadinRouterLocationChangedEvent, WebComponentInterface, -} from '../../src/types.js'; +} from '../../src/types.t.js'; import { checkOutletContents, cleanup, diff --git a/test/router/parent-layout.spec.ts b/test/router/parent-layout.spec.ts index 09f13c36..148b2306 100644 --- a/test/router/parent-layout.spec.ts +++ b/test/router/parent-layout.spec.ts @@ -1,7 +1,7 @@ import { expect } from '@esm-bundle/chai'; import sinon from 'sinon'; import { Router } from '../../src/router.js'; -import type { ResolutionError, RouterLocation, WebComponentInterface } from '../../src/types.js'; +import type { ResolutionError, RouterLocation, WebComponentInterface } from '../../src/types.t.js'; import '../setup.js'; import { checkOutletContents, diff --git a/test/router/router.spec.ts b/test/router/router.spec.ts index f7ebfae3..ad46440f 100644 --- a/test/router/router.spec.ts +++ b/test/router/router.spec.ts @@ -11,7 +11,7 @@ import type { RouteChildrenContext, RouteContext, WebComponentInterface, -} from '../../src/types.js'; +} from '../../src/types.t.js'; import '../setup.js'; import { checkOutletContents, cleanup, onBeforeEnterAction } from './test-utils.js';