mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/carbon-components-react] Fix UIShell Link props. Fix HeaderMenuLink prop optionality. (#38416)
* Fix Link type. * Fix Link type. * MenuLinkName is technically optional... impl is a bit strange. * UI Shell link change. * Improve tests. * Lint fix.
This commit is contained in:
parent
24a4aee497
commit
57da206834
@ -8,6 +8,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from 'carbon-components-react';
|
||||
import Link from 'carbon-components-react/lib/components/UIShell/Link';
|
||||
|
||||
interface Row1 extends DataTableRow {
|
||||
rowProp: string;
|
||||
@ -138,3 +139,29 @@ const t4 = (
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
// UIShell - Link
|
||||
interface TestCompProps {
|
||||
someProp: number,
|
||||
}
|
||||
|
||||
class TestComp1 extends React.Component<TestCompProps> {
|
||||
render() {
|
||||
return (<div/>);
|
||||
}
|
||||
}
|
||||
|
||||
const TestComp2 = (props: TestCompProps) => (<div/>);
|
||||
|
||||
const uisLinkT1 = (
|
||||
<Link href="#test">Test</Link>
|
||||
);
|
||||
const uisLinkT2 = (
|
||||
<Link<React.ImgHTMLAttributes<HTMLElement>> element="img" src="src"/>
|
||||
);
|
||||
const uisLinkT3 = (
|
||||
<Link<TestCompProps> element={TestComp1} someProp={2}>ASDF</Link>
|
||||
);
|
||||
const uisLinkT4 = (
|
||||
<Link<TestCompProps> element={TestComp2} someProp={2}>ASDF</Link>
|
||||
);
|
||||
|
||||
@ -10,7 +10,7 @@ interface InheritedProps {
|
||||
}
|
||||
|
||||
export interface HeaderMenuProps extends InheritedProps {
|
||||
menuLinkName: string,
|
||||
menuLinkName?: string,
|
||||
renderMenuContent?: React.FC,
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
import * as React from "react";
|
||||
import { ReactAnchorAttr, ShapeOf } from "../../../typings/shared";
|
||||
|
||||
export interface LinkPropsBase {
|
||||
element?: string, // required but has default value
|
||||
type InnerElementProps<P> = Omit<P, "element">;
|
||||
export interface LinkPropsBase<P = ReactAnchorAttr> {
|
||||
element?: string | React.JSXElementConstructor<InnerElementProps<P>>, // required but has default value
|
||||
}
|
||||
|
||||
export type LinkProps<E extends object = ReactAnchorAttr> = ShapeOf<LinkPropsBase, E>;
|
||||
export type LinkProps<P extends object = ReactAnchorAttr, IP = P> = ShapeOf<LinkPropsBase<IP>, P>;
|
||||
|
||||
declare function Link<E extends object = ReactAnchorAttr>(props: React.PropsWithChildren<LinkProps<E>>, ref: React.Ref<HTMLElement>): React.ReactElement;
|
||||
declare function Link<P extends object = ReactAnchorAttr>(
|
||||
props: React.PropsWithChildren<LinkProps<P>>,
|
||||
ref: React.Ref<HTMLElement>
|
||||
): React.ReactElement;
|
||||
|
||||
export default Link;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user