Skip to content

Commit 3559652

Browse files
committed
feat: add typescript definitions
1 parent 5c3aaf2 commit 3559652

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

index.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
declare module 'react-simple-code-editor' {
2+
import * as React from 'react';
3+
4+
export default class extends React.Component<
5+
React.DetailedHTMLProps<
6+
React.HTMLAttributes<HTMLDivElement>,
7+
HTMLDivElement
8+
> & {
9+
// Props for the component
10+
value: string;
11+
onValueChange: (value: string) => unknown;
12+
highlight: (value: string) => string | React.ReactNode;
13+
tabSize?: number;
14+
insertSpaces?: boolean;
15+
ignoreTabKey?: boolean;
16+
padding?: number | string;
17+
style?: object;
18+
19+
// Props for the textarea
20+
autoFocus?: boolean;
21+
disabled?: boolean;
22+
form?: string;
23+
maxLength?: number;
24+
minLength?: number;
25+
name?: string;
26+
placeholder?: string;
27+
readOnly?: boolean;
28+
required?: boolean;
29+
onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => unknown;
30+
onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => unknown;
31+
}
32+
> {
33+
session: {
34+
history: {
35+
stack: Array<{
36+
value: string;
37+
selectionStart: number;
38+
selectionEnd: number;
39+
timestamp: number;
40+
}>;
41+
offset: number;
42+
};
43+
};
44+
}
45+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
"registry": "https://registry.npmjs.org/"
2727
},
2828
"main": "lib/index.js",
29+
"types": "index.d.ts",
2930
"files": [
30-
"lib/"
31+
"lib/",
32+
"index.d.ts"
3133
],
3234
"repository": {
3335
"type": "git",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as React from 'react';
55

6-
type Props = {
6+
type Props = React.ElementConfig<'div'> & {
77
// Props for the component
88
value: string,
99
onValueChange: (value: string) => mixed,

0 commit comments

Comments
 (0)