Error: src/app/app.component.html:7:57 - error TS2345: Argument of type ‘Event‘ is not assignable to

部署运行你感兴趣的模型镜像

Error: src/app/app.component.html:7:57 - error TS2345: Argument of type ‘Event’ is not assignable to parameter of type ‘KeyboardEvent’.
Type ‘Event’ is missing the following properties from type ‘KeyboardEvent’: altKey, char, charCode, code, and 16 more.

7 <input type=“text” [value]=“inputValue” (input)=“inPut($event)” >
~~~~~~

src/app/app.component.ts:5:16
5 templateUrl: ‘./app.component.html’,
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
在这里插入图片描述
在这里插入图片描述
有朋友学angular吗???这是怎么回事啊???
我是按照编译器推荐的方式解决的
在这里插入图片描述
Change Appcomponent.inPut() signature然后就成功了,但是并不知道什么原理,也不知道解决的对不对。
在这里插入图片描述
有大神可以解答嘛!!

您可能感兴趣的与本文相关的镜像

Linly-Talker

Linly-Talker

AI应用

Linly-Talker是一款创新的数字人对话系统,它融合了最新的人工智能技术,包括大型语言模型(LLM)、自动语音识别(ASR)、文本到语音转换(TTS)和语音克隆技术

ERROR Failed to compile with 10 errors 9:13:36 AM error in /data/cloud-android-fronend/src/packages/multiplexer/CloseEventClass.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/CloseEventClass.ts(3,14) TS2420: Class 'CloseEvent2' incorrectly implements interface 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/ErrorEventClass.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/ErrorEventClass.ts(3,14) TS2420: Class 'ErrorEvent2' incorrectly implements interface 'ErrorEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Message.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Message.ts(54,9) TS2322: Type 'CloseEvent | CloseEvent2' is not assignable to type 'CloseEvent'. Type 'CloseEvent2' is not assignable to type 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/MessageEventClass.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/MessageEventClass.ts(3,14) TS2420: Class 'MessageEvent2' incorrectly implements interface 'MessageEvent<any>'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(105,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<string>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(121,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<ArrayBuffer>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(137,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<ArrayBuffer>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(160,40) TS2345: Argument of type 'ErrorEvent | ErrorEvent2' is not assignable to parameter of type 'Event'. Type 'ErrorEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(245,36) TS2345: Argument of type 'CloseEvent | CloseEvent2' is not assignable to parameter of type 'CloseEvent'. Type 'CloseEvent2' is not assignable to type 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. error in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(334,43) TS2345: Argument of type 'Event | Event2' is not assignable to parameter of type 'Event'. Type 'Event2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. ERROR in /data/cloud-android-fronend/src/packages/multiplexer/CloseEventClass.ts ./src/packages/multiplexer/CloseEventClass.ts 3:13-24 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/CloseEventClass.ts(3,14) TS2420: Class 'CloseEvent2' incorrectly implements interface 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/packages/multiplexer/Multiplexer.ts 9:24-52 @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/ErrorEventClass.ts ./src/packages/multiplexer/ErrorEventClass.ts 3:13-24 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/ErrorEventClass.ts(3,14) TS2420: Class 'ErrorEvent2' incorrectly implements interface 'ErrorEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/packages/multiplexer/Multiplexer.ts 10:24-52 @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Message.ts ./src/packages/multiplexer/Message.ts 54:8-14 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Message.ts(54,9) TS2322: Type 'CloseEvent | CloseEvent2' is not assignable to type 'CloseEvent'. Type 'CloseEvent2' is not assignable to type 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/packages/multiplexer/Multiplexer.ts 6:16-36 @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/MessageEventClass.ts ./src/packages/multiplexer/MessageEventClass.ts 3:13-26 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/MessageEventClass.ts(3,14) TS2420: Class 'MessageEvent2' incorrectly implements interface 'MessageEvent<any>'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/packages/multiplexer/Multiplexer.ts 11:26-56 @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 105:46-49 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(105,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<string>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 121:46-49 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(121,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<ArrayBuffer>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 137:46-49 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(137,47) TS2345: Argument of type 'MessageEvent2 | MessageEvent<ArrayBuffer>' is not assignable to parameter of type 'Event'. Type 'MessageEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 160:39-78 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(160,40) TS2345: Argument of type 'ErrorEvent | ErrorEvent2' is not assignable to parameter of type 'Event'. Type 'ErrorEvent2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 245:35-81 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(245,36) TS2345: Argument of type 'CloseEvent | CloseEvent2' is not assignable to parameter of type 'CloseEvent'. Type 'CloseEvent2' is not assignable to type 'CloseEvent'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts ./src/packages/multiplexer/Multiplexer.ts 334:42-64 [tsl] ERROR in /data/cloud-android-fronend/src/packages/multiplexer/Multiplexer.ts(334,43) TS2345: Argument of type 'Event | Event2' is not assignable to parameter of type 'Event'. Type 'Event2' is not assignable to type 'Event'. Types of property 'NONE' are incompatible. Type 'number' is not assignable to type '0'. @ ./src/app/client/ManagerClient.ts 8:20-69 @ ./src/app/client/HostTracker.ts 5:22-48 @ ./src/app/googDevice/client/StreamClientScrcpy.ts 22:20-55 @ ./node_modules/ts-loader/index.js??clonedRuleSet-40!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/Room.vue?vue&type=script&lang=ts 6:27-80 @ ./src/views/Room.vue?vue&type=script&lang=ts 1:0-182 1:0-182 1:183-354 1:183-354 @ ./src/views/Room.vue 2:0-55 3:0-50 3:0-50 6:49-55 @ ./src/router/index.ts 11:41-68 @ ./src/main.ts 10:39-58 webpack compiled with 10 errors
最新发布
07-25
### TypeScript 类型错误 TS2420 和 TS2345 解析与解决方案 #### TS2420: Class incorrectly implements interface 此错误通常发生在类试图实现一个接口时,但类的成员与接口定义不匹配。这可能包括缺少接口中定义的属性或方法、方法签名不一致、或者访问修饰符不匹配等情况。 **示例:** ```typescript interface Animal { name: string; makeSound(): void; } class Dog implements Animal { // 缺少 name 属性 makeSound() { console.log("Woof!"); } } ``` **错误信息:** ``` Class 'Dog' incorrectly implements interface 'Animal'. Property 'name' is missing in type 'Dog' but is required in type 'Animal'. ``` **解决方案:** - 确保类实现了接口中定义的所有属性和方法。 - 如果类中使用了访问修饰符(如 `private` 或 `protected`),确保它们与接口定义的成员访问级别一致。 ```typescript class Dog implements Animal { name: string = "Buddy"; // 添加 name 属性 makeSound() { console.log("Woof!"); } } ``` #### TS2345: Argument not assignable to parameter 此错误通常发生在函数调用时,传递的参数类型与函数定义中的参数类型不匹配。这可能是由于类型不兼容、类型推断错误或泛型使用不当导致的。 **示例:** ```typescript function printLength(arg: { length: number }) { console.log(arg.length); } printLength("hello"); // 正确,字符串有 length 属性 printLength(5); // 错误,数字没有 length 属性 ``` **错误信息:** ``` Argument of type 'number' is not assignable to parameter of type '{ length: number; }'. ``` **解决方案:** - 确保传递的参数具有函数定义中所需的属性。 - 如果使用泛型,确保类型参数符合预期的约束。 ```typescript function printLength<T extends { length: number }>(arg: T) { console.log(arg.length); } printLength("hello"); // 正确 printLength([1, 2, 3]); // 正确,数组也有 length 属性 ``` ### 接口扩展与交集类型 在 TypeScript 中,可以通过交集类型扩展接口的功能。例如,定义一个基础接口 `Animal`,然后通过交集类型创建一个扩展接口 `Bear`。 ```typescript type Animal = { name: string; }; type Bear = Animal & { honey: boolean; }; const bear: Bear = { name: "Baloo", honey: true }; ``` ### 泛型与类型约束 在使用泛型时,可以通过类型约束确保类型变量具有特定的属性或方法。例如,定义一个泛型函数,确保类型变量 `T` 具有 `length` 属性。 ```typescript interface Length { length: number; } function identity<T extends Length>(arg: T): T { console.log(arg.length); return arg; } identity("hello"); // 正确 identity([1, 2, 3]); // 正确 identity(5); // 错误,数字没有 length 属性 ``` ### 总结 - **TS2420** 错误是由于类未能正确实现接口而导致的,解决方法是确保类实现接口的所有成员。 - **TS2345** 错误是由于参数类型不匹配而导致的,解决方法是确保传递的参数符合函数定义的类型要求。 - 使用交集类型可以轻松扩展接口功能。 - 使用泛型与类型约束可以确保类型变量具有所需的属性或方法。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值