- Forums
- Typescript
- Different Example Of Assigning Typescript Types Arrays Objects Variables Etc.
This page contains example on how to use Typescript Types for Arrays Objects Variables and other examples. [5211], Last Updated: Mon Jun 24, 2024
cathy
Sat Sep 16, 2023
0 Comments
344 Visits
IONIC EXAMPLES:
export const ContextProvider = ({ children }:any) => {
array
const botNums: any = [1, 2, 3, 4, 5, 6, 7, 8, 9];
map
{Object.entries(operators).map<any>(([property, value]: any, index: any) => {
return (
<IonRow
color="primary"
key={index}
className={`operator${property}`}
>
<IonCol>
<Link to={`/NumberBonds/${property}/1`}>
{value} {property}
</Link>
</IonCol>
</IonRow>
);
}
)}
Interface
interface AppPage {
url: string;
iosIcon: string;
mdIcon: string;
title: string;
}
const appPages: AppPage[] = [
{
title: "Inbox",
url: "/page/Inbox",
iosIcon: mailOutline,
mdIcon: mailSharp,
},
Interface with props
interface ContainerProps {
name: string;
}
const ExploreContainer: React.FC<ContainerProps> = ({ name }) => {
return (
<div>
...{name}
</div>
);
};
for (let [fieldName, field] of Object.entries<any>(form)) {
const canvasRef = useRef<any>();
const operators: {
Addition: any;
Subtraction: any;
Multiplication: any;
Division: any;
} = {
Addition: { operator: "+", icon: addCircleOutline },
Subtraction: { operator: "-", icon: removeCircleOutline },
Multiplication: { operator: "*", icon: closeCircleOutline },
Division: { operator: "/", icon: codeSlashOutline },
};