Currently, I've incorporated semantic-ui-react into my React project, which provides Typescript typings.
Let's take a look at an illustrative type file they offer: Flag.d.ts.
import * as React from 'react';
export interface FlagProps {
[key: string]: any;
/** A designated element type for rendering (string or function). */
as?: any;
/** Extra classes to apply. */
className?: string;
/** Desired country flag name, using either the two-digit code, full name, or common alias. */
name: 'ad' | 'andorra' | 'ae' | 'united arab emirates' | ...
}
declare const Flag: React.StatelessComponent<FlagProps>;
export default Flag;
In my particular project structure, there exists a user model with a country attribute. I am keen on adopting the name property of FlagProps as the type for my country entry. Initially, I attempted the following approach...
let UserProps: {
name: string,
age: number,
country: FlagProps.name
}
Similarly, I endeavored to construct an array of country codes...
const countryCodes: Array<Flagprops.name> = [...]
Unfortunately, in both instances, an error arises displaying error TS2702: FlagProps' only refers to a type, but is being used as a namespace here.
Is it viable to exclusively utilize a segment of the FlagProps interface without causing conflicts?