Comments (4)
Here's a starting point
declare module 'react-flag-icon-css' {
import {PureComponent} from 'react';
export interface Options {
useCssModules: boolean;
}
export interface FlagIconProps {
code: string;
size?: 'lg' | '2x' | '3x' | '4x' | '5x';
flip?: 'horizontal' | 'vertical';
rotate?: 30 | 60 | 90 | 180 | 270;
squared?: boolean;
className?: string;
styleName?: string;
}
export class FlagIcon extends PureComponent<FlagIconProps> {
}
export default function FlagIconFactory(react: any, opts?: Options): () => FlagIcon
}
Although as per the various issues around string literal types (e.g. microsoft/TypeScript#20271) you end up needing to write something like this
<FlagIcon code='eu' size={'lg' as 'lg'}/>
from react-flag-icon-css.
Types are now @ https://www.npmjs.com/package/@types/react-flag-icon-css
Please feel free to merge them back into the lib if appropriate
from react-flag-icon-css.
Hi @jonfreedman thanks for that! It is unfortunate that TypeScript
has some issues around string literal types (Flow
too), I don't know if we could make it typecheck computed props too, that would be pretty nice (size={someSize}
). If you could make a PR please feel free to do so, personally I was looking into typescript-definition-tester to run a test suite, but there may be better or more standard ways. Then, after the tests worked (even without custom flags initially), the enum types could be generated like we do with generate:types
for Flow.
from react-flag-icon-css.
Thanks again @jonfreedman, that is great! 👍
from react-flag-icon-css.
Related Issues (20)
- An in-range update of prettier is breaking the build 🚨 HOT 5
- An in-range update of react is breaking the build 🚨 HOT 17
- Remove Dependancy of prop-types HOT 1
- Upgrade `flow-bin` to the latest version and fix errors
- An in-range update of ava is breaking the build 🚨 HOT 6
- An in-range update of flag-icon-css is breaking the build 🚨 HOT 5
- An in-range update of esm is breaking the build 🚨 HOT 7
- An in-range update of eslint-plugin-import is breaking the build 🚨 HOT 10
- An in-range update of eslint-plugin-flowtype is breaking the build 🚨 HOT 13
- An in-range update of eslint-plugin-react is breaking the build 🚨 HOT 10
- An in-range update of babel7 is breaking the build 🚨 HOT 43
- An in-range update of prettier is breaking the build 🚨 HOT 1
- An in-range update of babel-eslint is breaking the build 🚨 HOT 1
- Error when using with next
- Could not resolve the styleName flag-icon HOT 1
- Add support for "Netherlands Antilles" country
- Peer Dependencies - react 17?
- Peer dependency React V18
- Version 10 of node.js has been released
- Compatibility with create-react-app 2.0 built-in CSS modules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-flag-icon-css.