There is this tutorial on the main page: https://ant.design/docs/react/use-in-typescript it shows some example code that does not compile. In particular, <Button type="primary">Button</Button> does not compile because it should be htmlType and not type. Can somebody please confirm that this is true? Or is it just a problem with my installation?
Another problem I have noticed is that props for Button have bad type declaration. At least on my computer. I just installed antd, and I have this NativeButtonProps, which has htmlType?: ButtonHTMLType, and that is declared as: export declare type ButtonHTMLType = 'submit' | 'button' | 'reset';
This is very confusing because the documentation says that there are types called "primary" "dashed" and "danger". Is this also a problem with the declaration?
Is it possible that I have a broken installation but I doubt. I have tried to install everything from scratch on a computer that had no node.js installed. But the result is the same. What am I doing wrong?
UPDATE more details on the problem. If I use this code:
<Button type="primary">Buttonka</Button>
Then I get this compilation error and it won't generate js code:
C:/TypeScript/antd-demo-ts/src/App.tsx
(10,10): Type '{ children: string; type: "primary"; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes & Pick & Readonly & Pick, "htmlType">, "color" | ... 258 more ... | "htmlType"> & Partial<...> & Partial<...>) | ...'.
Type '{ children: string; type: "primary"; }' is not assignable to type 'Pick & Readonly & Pick, "htmlType">, "color" | ... 262 more ... | "value">'.
Property 'htmlType' is missing in type '{ children: string; type: "primary"; }'.
If I use htmlType="primary" instead, then I get the following warning:
{
"resource": "/c:/TypeScript/antd-demo-ts/src/App.tsx",
"owner": "typescript",
"code": "2322",
"severity": 8,
"message": "Type '{ children: string; htmlType: \"primary\"; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & R...'.\n Type '{ children: string; htmlType: \"primary\"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Re...'.\n Type '{ children: string; htmlType: \"primary\"; }' is not assignable to type 'Readonly'.\n Types of property 'htmlType' are incompatible.\n Type '\"primary\"' is not assignable to type '\"submit\" | \"button\" | \"reset\" | undefined'.",
"source": "ts",
"startLineNumber": 10,
"startColumn": 10,
"endLineNumber": 10,
"endColumn": 16
}
and in this case the TypeScript code is compiled, but the button is shown as opaque/white, and it is not primary/blue.
It is a fact that the css has been imported into App.tsx:
import './App.css';
and also the ant design css has been imported in App.css:
#import '~antd/dist/antd.css';
But either way, I can't set the primary (blue) style on the button.
Related
`TS2322: Type '{ children: Element; key: any; as: ForwardRefExoticComponent<NavLinkProps & RefAttributes>; to: any; activeClassName: string; className: string; }' is not assignable to type 'IntrinsicAttributes & Omit<NavLinkProps & RefAttributes, BsPrefixProps<ForwardRefExoticComponent<NavLinkProps & RefAttributes<...>>> & NavLinkProps> & BsPrefixProps<...> & NavLinkProps & { ...; }'.
Property 'activeClassName' does not exist on type 'IntrinsicAttributes & Omit<NavLinkProps & RefAttributes, BsPrefixProps<ForwardRefExoticComponent<NavLinkProps & RefAttributes<...>>> & NavLinkProps> & BsPrefixProps<...> & NavLinkProps & { ...; }'.
59 | as={NavLink}
60 | to={subitems.path}
61 | activeClassName="text-white rna-analytictab-item-active"
| ^^^^^^^^^^^^^^^
62 | className="rna-analytictab-item"
63 | >
64 |
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`
This is the error I'm getting on Jenkins but on running it on /tmp location its working. Locally also its working file. The problem comes only when its in /var/lib/jenkins/workspace/ Yarn version is 1.22.17 and node is 14.19
I have been trying to deploy my typescript based node server to heroku but getting the following error while deployment
-----> Build
Running build
> autoscan-back-end#1.0.0 build
> rimraf dist && tsc
src/services/notification/notification.service.ts(46,37): error TS2322: Type 'string | ObjectId' is not assignable to type 'Condition<string>'.
Type 'ObjectId' is not assignable to type 'Condition<string>'.
src/services/report/report.service.ts(53,35): error TS2769: No overload matches this call.
Overload 1 of 3, '(callback?: Callback<ReportType[]>): Query<ReportType[], ReportType, {}, ReportType>', gave the following error.
Argument of type '{ _id?: string; admin: string | Types.ObjectId; status?: string; containsDublicates?: boolean; stickers?: [Types.ObjectId]; }' is not assignable to parameter of type 'Callback<ReportType[]>'.
Type '{ _id?: string; admin: string | ObjectId; status?: string; containsDublicates?: boolean; stickers?: [ObjectId]; }' provides no match for the signature '(error: NativeError, result: ReportType[]): void'.
Overload 2 of 3, '(filter: FilterQuery<ReportType>, callback?: Callback<ReportType[]>): Query<ReportType[], ReportType, {}, ReportType>', gave the following error.
Argument of type '{ _id?: string; admin: string | Types.ObjectId; status?: string; containsDublicates?: boolean; stickers?: [Types.ObjectId]; }' is not assignable to parameter of type 'FilterQuery<ReportType>'.
Type '{ _id?: string; admin: string | Types.ObjectId; status?: string; containsDublicates?: boolean; stickers?: [Types.ObjectId]; }' is not assignable to type '{ _id?: any; admin?: Condition<string>; status?: Condition<string>; containsDublicates?: Condition<boolean>; stickers?: Condition<[ObjectId]>; ... 55 more ...; validateSync?: Condition<...>; }'.
Types of property 'admin' are incompatible.
Type 'string | ObjectId' is not assignable to type 'Condition<string>'.
Type 'ObjectId' is not assignable to type 'Condition<string>'.
Overload 3 of 3, '(filter: FilterQuery<ReportType>, projection?: any, options?: QueryOptions, callback?: Callback<ReportType[]>): Query<...>', gave the following error.
Argument of type '{ _id?: string; admin: string | Types.ObjectId; status?: string; containsDublicates?: boolean; stickers?: [Types.ObjectId]; }' is not assignable to parameter of type 'FilterQuery<ReportType>'.
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
the project is running smoothly without any error locally, getting this on heroku only
Actually ts was checking the query response from mongodb, which was ignored in other functions but not these.
So I just added //#ts-ignore before the line 53 and 46 to ingore just like other query functions
I`m try to do this https://github.com/mbrn/material-table but I get error. I think there is a problem because I use TSX not JSX? do you know how to fix?
No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } & { children?: ReactNode; color?: "primary" | "secondary" | "disabled" | "error" | "inherit" | "action" | undefined; fontSize?: "inherit" | ... 3 more ... | undefined; htmlColor?: string | undefined; shapeRendering?: string | undefined; titleAccess?: string | undefined; viewBox?: string | undefined; } & CommonProps<...> & Pick<...>): Element', gave the following error.
Property 'component' is missing in type '{ ref: ((instance: unknown) => void) | MutableRefObject<unknown> | null; children?: ReactNode; }' but required in type '{ component: ElementType<any>; }'.
Overload 2 of 2, '(props: DefaultComponentProps<SvgIconTypeMap<{}, "svg">>): Element', gave the following error.
Type '((instance: unknown) => void) | MutableRefObject<unknown> | null' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
Type 'MutableRefObject<unknown>' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
Type 'MutableRefObject<unknown>' is not assignable to type 'RefObject<SVGSVGElement>'.ts(2769)
OverridableComponent.d.ts(17, 7): 'component' is declared here.
and here
No overload matches this call.
Overload 1 of 2, '(props: Readonly<MaterialTableProps<{ name: string; surname: string; birthYear: number; birthCity: number; }>>): MaterialTable<{ name: string; surname: string; birthYear: number; birthCity: number; }>', gave the following error.
Type '{ Add: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; Check: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; Clear: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; ... 13 more ...; ViewColumn: React.ForwardRefExoticComponent<...>; }' is not assignable to type 'Icons'.
The types of 'Add.defaultProps' are incompatible between these types.
Type 'Partial<RefAttributes<unknown>> | undefined' is not assignable to type 'Partial<RefAttributes<SVGSVGElement>> | undefined'.
Type 'Partial<RefAttributes<unknown>>' is not assignable to type 'Partial<RefAttributes<SVGSVGElement>>'.
Types of property 'ref' are incompatible.
Type '((instance: unknown) => void) | RefObject<unknown> | null | undefined' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
try this
forwardRef<SVGSVGElement>
in the icons
or
import Icons like this:
import MaterialTable, { Icons } from 'material-table'
const tableIcons: Icons = {...}
I want to ensure a list of exclusively <li/> will be passed to a component such that they will be displayed inside a <ul> element as rendered by the said component.
Here is my code:
const menuItems: HTMLLIElement[] = [
<li>Item 1</li>,
<li>Item 2</li>,
<li>Item 3</li>,
];
For each line of <li> inside the array, I get this error:
error TS2322: Type 'Element' is not assignable to type 'HTMLLIElement'.
I have tried an alternative way to create an array of li element
const menuItems = [
React.createElement(HTMLLIElement, {value: 'Item 1' }),
React.createElement(HTMLLIElement, {value: 'Item 2' }),
React.createElement(HTMLLIElement, {value: 'Item 3' }),
]
but it just gave a different error:
error TS2345: Argument of type '{ new (): HTMLLIElement; prototype: HTMLLIElement; }' is not assignable to parameter of type 'string | FunctionComponent<{ value: string; }> | ComponentClass<{ value: string; }, any>'.
Type '{ new (): HTMLLIElement; prototype: HTMLLIElement; }' is not assignable to type 'ComponentClass<{ value: string; }, any>'.
Type 'HTMLLIElement' is missing the following properties from type 'Component<{ value: string; }, any, any>': context, setState, forceUpdate, render, and 3 more.
How can I resolve this isse?
I'm trying to use consumerGroup instead of HighLevelConsumer in a typescript project, but I'm not able to configure consumerOptions for consumerGroup.
I am getting the following error when I assign
1) fromOffset: 'earliest'
Argument of type '{ autoCommit: boolean; fetchMaxBytes: number;
fetchMaxWaitMs: number; fromOffset: string; groupId...' is not
assignable to parameter of type 'ConsumerGroupOptions'. Types of
property 'fromOffset' are incompatible. Type 'string' is not
assignable to type '"earliest" | "latest" | "none"'.
2) protocol: ['roundrobin']
Argument of type '{ autoCommit: boolean; fetchMaxBytes: number;
fetchMaxWaitMs: number; protocol: string[]; groupId...' is not
assignable to parameter of type 'ConsumerGroupOptions'. Types of
property 'protocol' are incompatible. Type 'string[]' is not
assignable to type '("roundrobin" | "range" |
CustomPartitionAssignmentProtocol)[]'. Type 'string' is not assignable
to type '"roundrobin" | "range" | CustomPartitionAssignmentProtocol'.
3) outOfRangeOffset: 'earliest'
Argument of type '{ autoCommit: boolean; fetchMaxBytes: number;
fetchMaxWaitMs: number; outOfRangeOffset: string; g...' is not
assignable to parameter of type 'ConsumerGroupOptions'. Types of
property 'outOfRangeOffset' are incompatible. Type 'string' is not
assignable to type '"earliest" | "latest" | "none"'.
Environment details:
Node version: v8.11.1
Kafka-node version: v2.6.1
types/kafka-node: v2.0.6
Can anyone help me understand where I am going wrong? Thanks in advance.