Skip to content

Commit ff14375

Browse files
author
Daniel Jung
committed
Add type definition file for typescript
1 parent 228a893 commit ff14375

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/ParsedText.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
declare module 'react-native-parsed-text' {
2+
import { Component } from 'react';
3+
import { TextProps } from 'react-native';
4+
5+
interface BaseParseShape extends Pick<TextProps, Exclude<keyof TextProps, 'onPress'>> {
6+
renderText?: (matchingString: string) => string;
7+
onPress?: (text: string, index: number) => void;
8+
}
9+
10+
interface DefaultParseShape extends BaseParseShape {
11+
type: 'url' | 'phone' | 'email';
12+
}
13+
14+
interface CustomParseShape extends BaseParseShape {
15+
pattern: string | RegExp;
16+
}
17+
18+
type ParseShape = DefaultParseShape | CustomParseShape;
19+
20+
export interface ParsedTextProps extends TextProps {
21+
parse?: ParseShape[];
22+
childrenProps?: TextProps;
23+
}
24+
25+
export default class ParsedText extends Component<ParsedTextProps> {}
26+
}

0 commit comments

Comments
 (0)