我已经反应了Create-React-App
创建的具有以下软件包(提及与我的问题相关的软件包)的项目:
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"typescript": "^3.9.2",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0"
我创建了一个简单的HOC(到目前为止,它什么都没做,但是我稍后会添加我的逻辑):
type Props = {
[key: string]: any;
};
const connect = function (Component: FunctionComponent): FunctionComponent {
const ComponentWrapper = function (props: Props): ReactElement {
return <Component {...props} />;
};
return ComponentWrapper;
};
并这样导出我的组件:
const Test: FunctionComponent<Props> = function ({ message }: Props) {
return (
<div>{message}</div>
);
};
export default connect(Test);
并像这样使用该组件:
<Test message="Testing message" />
但是在编译器中出现错误:
Type '{ message: string; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'.
Property 'message' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'. TS2322
我尝试了人们在Google上发现的其他类似Stack Overflow问题和文章中所提出的建议,但到目前为止没有任何效果。
答案 0 :(得分:4)
// Gets the current package name
val packageName = context.packageName
// Gets the current process name
val processName = getProcessName(Process.myPid())
,并在重新启动编译器后即可正常工作。