[英]Getting: error TS1128: Declaration or statement expected. In ReactJS & TypeScript app
Here is my current code for the new component I created which is causing this error to be throw.这是我创建的新组件的当前代码,它导致抛出此错误。
Failed to compile.
编译失败。
./src/components/Hello.tsx (5,1): error TS1128: Declaration or statement expected.
./src/components/Hello.tsx (5,1): 错误 TS1128: 需要声明或语句。
I've checked other answers and haven't found the actual issue yet.我已经检查了其他答案,但还没有找到实际问题。
// src/components/Hello.tsx
import * as React from 'react';
export Interface Props {
name: string;
enthusiasmLevel?: number;
}
function Hello({ name, enthusiasmLevel = 1 }: Props) {
if (enthusiasmLevel <= 0) {
throw new Error('You could be a little more enthusiastic. :D');
}
return (
<div className="hello">
<div className="greeting">
Hello {name + getExclamationMarks(enthusiasmLevel)}
</div>
</div>
);
}
export default Hello;
// helpers
function getExclamationMarks(numChars: number) {
return Array(numChars + 1).join('!');
}
Change改变
export Interface Props {
to到
export interface Props {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.