Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module 'react-split-grid'. #233

Open
gavinr opened this issue Mar 24, 2020 · 2 comments
Open

Could not find a declaration file for module 'react-split-grid'. #233

gavinr opened this issue Mar 24, 2020 · 2 comments

Comments

@gavinr
Copy link

gavinr commented Mar 24, 2020

I'm using create-react-app with the typescript template, and after installing npm install --save react-split-grid, and using the render style import, I am getting an error:

Could not find a declaration file for module 'react-split-grid'. 'C:/.../app/node_modules/react-split-grid/dist/react-split-grid.js' implicitly has an 'any' type.
  Try `npm install @types/react-split-grid` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-split-grid';`  TS7016

    3 | import "./App.css";
    4 |
  > 5 | import Split from "react-split-grid";
      |                   ^

Any ideas? I do see https://github.com/nathancahill/split/blob/master/packages/splitjs/index.d.ts - any way to install that in parallel?

@nathancahill
Copy link
Owner

react-split-grid does not have a definition file yet. This is a priority for sure.

@willium
Copy link

willium commented Jun 18, 2020

I started one

declare module "react-split-grid" {
	import React from "react"

	export interface TrackSize {
		[track: number]: number
	}

	export interface GridStyles {
		gridTemplateColumns?: string
		gridTemplateRows?: string
	}

	export interface RenderProps {
		getGridProps: () => {
			styles: GridStyles
		}
		getGutterProps: (
			direction: "row" | "column",
			track: number,
		) => {
			onMouseDown: (e: unknown) => void
			onTouchStart: (e: unknown) => void
		}
	}

	export type Render = (props: RenderProps) => React.Element | null

	export interface SplitGridProps extends GridStyles {
		minSize?: number
		columnMinSize?: number
		rowMinSize?: number
		columnMinSizes?: TrackSize
		rowMinSizes?: TrackSize
		snapOffset?: number
		columnSnapOffset?: number
		rowSnapOffset?: number
		dragInterval?: number
		columnDragInterval?: number
		rowDragInterval?: number
		cursor?: string
		columnCursor?: string
		rowCursor?: string
		onDrag?: (
			direction: "row" | "column",
			track: number,
			gridTemplateStyle: string,
		) => void
		onDragStart?: (direction: "row" | "column", track: number) => void
		onDragEnd?: (direction: "row" | "column", track: number) => void
		gridTemplateColumns?: string
		gridTemplateRows?: string
	}

	export interface ChildrenPattern {
		children: Render
	}

	export interface RenderPattern {
		render: Render
	}

	export interface ComponentPattern {
		component: React.Node
	}

	declare const Split: React.FunctionComponent<SplitGridProps &
		(ChildrenPattern | RenderPattern | ComponentPattern)>

	export default Split
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants