From 943dcc8026d9c46eb73881a38c6c65d34e5ce1ca Mon Sep 17 00:00:00 2001 From: Felix Orinda Date: Tue, 8 Nov 2022 12:40:54 +0300 Subject: [PATCH] Update module type definitions --- package.json | 2 +- src/components/MapRouter.tsx | 4 ++-- src/types/index.ts | 31 +------------------------------ 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 53e55ef..38f720f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A declarative routing library that maps your routes and uses the react-router-dom library so that you focus on the logic rather than route configuration. It supports nested routing and react-router-dom v6+", "main": "./dist/index.js", "module": "./dist/index.js", - "types": "./dist/types/", + "types": "./dist/types/index.d.ts", "scripts": { "test": "jest --config jest.config.js", "lint": "eslint src --ext .js,.jsx,.ts,.tsx", diff --git a/src/components/MapRouter.tsx b/src/components/MapRouter.tsx index 036f8aa..7779421 100644 --- a/src/components/MapRouter.tsx +++ b/src/components/MapRouter.tsx @@ -1,10 +1,10 @@ import React from 'react' import { HashRouter, BrowserRouter, Routes } from 'react-router-dom' -import { IRouteProps, IRouterFunction, MapRouterProps } from 'src/types' +import { IRouteProps, MapRouterFunction, MapRouterProps } from 'src/types' import RouteFunction from './RouteFunction' import { TopScroll } from './TopScroll' -export const MapRouter: IRouterFunction = function ({ +export const MapRouter: MapRouterFunction = function ({ routes, browserRouter = false, enableTopScroll = true, diff --git a/src/types/index.ts b/src/types/index.ts index 8cac7e7..037a0cd 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,25 +1,5 @@ /* eslint-disable @typescript-eslint/no-namespace */ import React from 'react' - -declare module 'react-router-dom' { - export interface IRouteProps { - pathName: string - urlPath: string - Component: React.ReactElement - hasChildren: boolean - nestedComponents?: IRouteProps[] - } - - export type IRouteFunction = (props: IRouteProps) => JSX.Element - - export type IRouterFunction = ( - routes: IRouteProps[], - browserRouter: boolean, - enableTopScroll?: boolean, - layout?: React.ReactElement | React.FC | React.ComponentClass, - ) => any -} - export interface IRouteProps { pathName: string urlPath: string @@ -34,13 +14,4 @@ export type MapRouterProps = { enableTopScroll?: boolean browserRouter?: boolean } -export type IRouterFunction = (props: MapRouterProps) => JSX.Element - -// Create a namespace for the module -declare global { - namespace MapRouter { - interface IntrinsicElements { - 'react-router-map': any - } - } -} +export type MapRouterFunction = (props: MapRouterProps) => JSX.Element