Skip to content

Commit 5758cb0

Browse files
Add type union for Link target prop (#1643)
1 parent 165e5e9 commit 5758cb0

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,9 +1398,9 @@ export interface LinkOwnProps extends TextOwnProps {
13981398
*/
13991399
href?: string
14001400
/**
1401-
* Target atrribute, common use case is target="_blank."
1401+
* Target attribute, common use case is target="_blank."
14021402
*/
1403-
target?: string
1403+
target?: '_self' | '_blank' | '_parent' | '_top'
14041404
/**
14051405
* The color (and styling) of the Link. Can be default, blue, green or neutral.
14061406
*/

index.test-d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
import { expectAssignable, expectType, expectError } from 'tsd'
2-
import { defaultTheme, mergeTheme, StyleProps, Intent, Theme, Fill, Partial, Pick, Color, ComboboxProps } from '.'
2+
import {
3+
defaultTheme,
4+
mergeTheme,
5+
StyleProps,
6+
Intent,
7+
Theme,
8+
Fill,
9+
Partial,
10+
Pick,
11+
Color,
12+
ComboboxProps,
13+
LinkProps
14+
} from '.'
315

416
interface ThemeOverrides extends Partial<Pick<Theme, 'colors' | 'fills' | 'components'>> {
517
colors: {
@@ -131,3 +143,5 @@ expectError(mergeTheme(defaultTheme, themeWithTopLevelColorsArray))
131143
expectError<ComboboxProps>({ autocompleteProps: { children: 'error' } })
132144
expectError<ComboboxProps>({ autocompleteProps: { onChange: () => {} } })
133145
expectError<ComboboxProps>({ autocompleteProps: { items: [] } })
146+
147+
expectError<LinkProps>({ target: 'blank' })

src/typography/src/Link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Link.propTypes = {
3737
href: PropTypes.string,
3838

3939
/**
40-
* Target atrribute, common use case is target="_blank."
40+
* Target attribute, common use case is target="_blank."
4141
*/
42-
target: PropTypes.string,
42+
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
4343

4444
/**
4545
* The color (and styling) of the Link. Can be default, blue, green or neutral.

0 commit comments

Comments
 (0)