我在 mu 应用程序 react-intl
中使用。我有下一个代码:
const intl = useIntl();
const test = makeTest(error, intl.formatMessage);
// call test in another file:
const run = (error: ApolloError, formatMessage): string => {
...
};
你如何看到我在我的 React 应用程序中使用了 typescript,但是当我想从 formatMessage
输入 const run = (error: ApolloError, formatMessage): string
时遇到问题。
我在不同的来源中进行了搜索,但我可以不输入该参数,如何输入 formatMessage
?
答案 0 :(得分:0)
useIntl
的返回类型可以在 IDE 中或从源代码中查找https://github.com/awoodworth/react-intl/blob/master/src/components/useIntl.ts
类型最终是
import { MessageDescriptor } from 'react-intl';
const run = (error: ApolloError, formatMessage: (descriptor: MessageDescriptor) => string): string => {
...
};