Skip to content

Commit

Permalink
Update module type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
forinda committed Nov 8, 2022
1 parent 396925a commit 943dcc8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions 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,
Expand Down
31 changes: 1 addition & 30 deletions 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
Expand All @@ -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

0 comments on commit 943dcc8

Please sign in to comment.