Javascript 获取:错误TS1128:需要声明或语句。在中国,;打字脚本应用程序
下面是我创建的新组件的当前代码,它导致抛出此错误 未能编译 ./src/components/Hello.tsx (5,1):错误TS1128:应为声明或语句 我已经检查了其他答案,还没有找到真正的问题Javascript 获取:错误TS1128:需要声明或语句。在中国,;打字脚本应用程序,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,下面是我创建的新组件的当前代码,它导致抛出此错误 未能编译 ./src/components/Hello.tsx (5,1):错误TS1128:应为声明或语句 我已经检查了其他答案,还没有找到真正的问题 // src/components/Hello.tsx import * as React from 'react'; export Interface Props { name: string; enthusiasmLevel?: number; } function Hello
// 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('!');
}
//src/components/Hello.tsx
从“React”导入*作为React;
导出接口道具{
名称:字符串;
热情水平?:数字;
}
函数Hello({name,entusiasmlevel=1}:Props){
if(热情水平变化
export Interface Props {
到
接口
-->接口
(应该是小写的)我实际上有一个错误,要求我将其改为大写,但我刚刚意识到了错误。在我更改了tslint文件后,我忘记了重新启动纱线。我将很快关闭它,因为这不是基于逻辑的问题。
export interface Props {