Skip to content

Commit 0124919

Browse files
authored
chore: Add deprecation warning to as property (#1453)
1 parent 8c041c6 commit 0124919

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/react/src/components/Link/Link.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createRef } from 'react';
2-
import type { RefObject } from 'react';
2+
import type { ComponentProps, RefObject } from 'react';
33
import { render as renderRtl, screen } from '@testing-library/react';
44

55
import { Link } from './Link';
@@ -53,7 +53,7 @@ describe('Link', () => {
5353
});
5454

5555
const render = (
56-
props: Partial<LinkProps> = {},
56+
props: Partial<ComponentProps<typeof Link>> = {},
5757
ref?: RefObject<HTMLAnchorElement>,
5858
) => {
5959
const allProps = { ...defaultProps, ...props };

packages/react/src/components/Link/Link.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AnchorHTMLAttributes, ElementType, ReactNode } from 'react';
1+
import type { AnchorHTMLAttributes, ReactNode } from 'react';
22
import React, { forwardRef } from 'react';
33
import cl from 'clsx';
44

@@ -7,9 +7,6 @@ import type { OverridableComponent } from '../../types/OverridableComponent';
77
import classes from './Link.module.css';
88

99
export type LinkProps = {
10-
/** The component to render the link as. */
11-
as?: ElementType;
12-
1310
/** The content to display inside the link. */
1411
children: ReactNode;
1512

packages/react/src/types/OverridableComponent.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export type OverridableComponent<
1313

1414
<As extends ElementType>(
1515
props: {
16-
/** Override html element */
16+
/** Override html element
17+
* @deprecated Will be removed in favor of `asChild`
18+
* @see [Github Issue](https://github.com/digdir/designsystemet/issues/1124)
19+
*/
1720
as?: As;
1821
} & ComponentProps &
1922
Omit<ComponentPropsWithRef<As>, keyof ComponentProps>,

0 commit comments

Comments
 (0)