Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Where do I get the typescript types of the variable from library

I have been working on a react-typescript project in which I am using a lot of external libraries and I frequently find myself using any type for those libraries. Please look at the code below for the demonstration

This is for the Fontawesome library

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
  faSquare,
} from '@fortawesome/free-regular-svg-icons';

interface IProps {
  title: string;
  icon: any;
  onClick?: () => void;
  sx?: { [index: string]: string };
}

const icons ={
 title :_,
icon : faSquare
}

For the above code, what would be the type of icon. The value of which is faSquare. When I hovered over it the type is IconDefinition. But, I am not sure where to import it or if that is the way to do it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The @fortawesome packages embed their own types, thus the type of icons.icon is inferred automatically.

In VSCode, you can right-click and "Go to type definition" to check type. In your case, the type of faSquare is IconDefinition

export interface IconDefinition extends IconLookup {
  icon: [
    number, // width
    number, // height
    string[], // ligatures
    string, // unicode
    IconPathData // svgPathData
  ];
}

You can just add it to your import from @fortawesome/free-regular-svg-icons'

import {faSquare, IconDefinition} from '@fortawesome/free-regular-svg-icons';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!