可以成功编译TypeScript代码
编译错误
main/window.ts:14:5 - error TS2339: Property 'removeAllListeners' does not exist on type 'BrowserWindow'.
14 win.removeAllListeners();
~~~~~~~~~~~~~~~~~~
node_modules/electron/electron.d.ts:1655:31 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
1655 class BrowserWindow extends NodeJS.EventEmitter {
~~~~~~
编辑:感谢https://github.com/electron/electron/issues/21612#issuecomment -568691944添加了整个编译错误消息
尝试使用最新的TypeScript编译器和最新的@types/node
软件包编译以下代码。
import { BrowserWindow } from 'electron';
const win = new BrowserWindow();
win.removeAllListeners();
套件版本:
typescript
:3.7.4@types/node
:13.1.0 没有
我已经调查了这个问题并找到了原因。
@types/node
v13的重大更改影响NodeJS.EventEmitter
v12中的class
更改interface
。 现在,只能通过接口扩展EventEmitter
。 我确认electron.d.ts
与@types/node
v12可以正常工作。 更改在这里:
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/c47a34ead1637f6f34e7d630dc88ea3f6e5562cb#diff -a2f9a5377787f7084c7f52b20c0108cfR540
但是,诸如electron.d.ts
BrowserWindow
类的类尝试扩展EventEmitter
因此导致了此问题。
可能与#21475有关
我相信我们不能再使用NodeJS.EventEmitter
,而需要使用import { EventEmitter } from 'events';
。 但是, import
语句不可用,因为使用了<reference/>
,并且我们当前依赖于Electron
命名空间。 它可能需要重写使用import
/ export
语句,而不是<reference/>
/ namespace
的electron.d.ts
。
节点13的@types/node
也导致以下类型错误:
Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
是的,该消息是由上述编译错误引起的。 implements
(当然)对我们不可用。 我在此问题的描述中包括了错误消息。 谢谢!
遇到同样的问题
预计随着Electron v7随节点v12一起提供,因此请使用最新的@ types / node v12。
没有@vladimiry 。 那不是它的工作原理- @types/node
和nodejs的版本之间没有直接的联系。 许多软件包(不仅仅是电子软件包)使用版本范围(例如“ ^ 8.0.0”或更糟糕的“ *”)来引用@types/node
,因此,当其中一个软件包进行升级时,每个人实际上都必须能够使用。
电子与最新的@types/node
不兼容,这使得升级我的解决方案中的任何包装变得困难
@ types / node和nodejs的版本之间没有直接的联系
你能提供资料吗?
即使我做不到(我确定可以花些时间也可以),但问题是大多数解决方案都引用了许多通过版本范围引用@ types / node的软件包。
问题是电子类型声明了一个类extends NodeJS.Emitter
但是它现在是一个接口,因此正确的语法是implements NodeJS.Emitter
或更正确地是extends events.EventEmitter
,它可以与旧节点和新节点一起使用
由于Electron v7随节点v12一起提供,因此请使用最新的@ types / node v12。
每晚至少Electron v8 beta和v9都有相同的问题。 是否有计划在升级Electron的节点版本之前解决electron.d.ts
和@types/node
v13之间的不兼容问题? 我担心electron.d.ts
未被固定,但Electron的节点版本升级到v13的情况。
每晚至少Electron v8 beta和v9都有相同的问题。
Electron 8.0.0-beta.5带有Node 12.13.0,没有尝试9夜构建。
我要指出的是,不兼容问题是否会被团队识别并跟踪到任何地方进行修复,直到升级节点v13。
有临时解决方法吗? 由于OP中列出的错误,我无法编译打字稿项目。
强制package.json和yarn.lock中的所有引用使用@ types / node
12.21.12。 这是不可接受的,但希望是暂时的情况
有些人试图表现出问题是电子7所使用的
节点12而不是13。它们只是错误的。 问题是使用
扩展vs在类/接口上实现关键字。 同样,你有
版本范围(例如,redux表示@ types / node:^ 8)
在2019年12月25日星期三上午8:33 Cyrus Frost [email protected]写道:
有临时解决方法吗? 我无法编译
打字稿项目,因为在OP中列出的错误。-
您收到此消息是因为您已订阅此线程。
直接回复此电子邮件,在GitHub上查看
https://github.com/electron/electron/issues/21612?email_source=notifications&email_token=AAQGPCWYY4R2NEQ6OW23OYLQ2NOJLA5CNFSM4J63DZ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKHTTCOM5MENT
或退订
https://github.com/notifications/unsubscribe-auth/AAQGPCTIGMVJ4QSYKYF7TKTQ2NOJLANCNFSM4J63DZ5Q
。
强制package.json和yarn.lock中的所有引用使用@ types / node 12.21.12。 这是不可接受的,但希望是暂时的情况。有人试图采取行动,似乎问题出在电子7使用节点12而不是13。他们完全是错误的。 问题是在类/接口上使用extended vs Implements关键字。 同样,您有版本范围(例如,redux说@ types / node:^ 8)
…
星期二,十二月25,2019,8:33 AM Cyrus Frost @ 。 * >写道:有临时解决方法吗? 由于OP中列出的错误,我无法编译打字稿项目。 —您收到此消息是因为您已订阅此线程。 回复此电子邮件直接,查看它在GitHub <#21612?email_source =通知&email_token = AAQGPCWYY4R2NEQ6OW23OYLQ2NOJLA5CNFSM4J63DZ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHULURI#issuecomment-568900165>,或取消订阅https://github.com/notifications/unsubscribe-auth/AAQGPCTIGMVJ4QSYKYF7TKTQ2NOJLANCNFSM4J63DZ5Q 。
此解决方法有效! 谢谢! 较小的更正: package.json
的@types/node
版本应该是12.12.21
而不是12.21.12
。
看起来我们在这里得到了周到的TypeSript和semver版本控制专家==> @amirburbea
问题是使用
扩展vs在类/接口上实现关键字。
Electron npm模块目前随@ types / node @ ^ 12.0.12一起提供,因此完全可以执行extends NodeJS.EventEmitter
因为NodeJS.EventEmitter
是v13之前的@ types / node中的类。
由于Electron v7随节点v12一起提供,因此请使用最新的@ types / node v12。
没有@vladimiry 。 不是这样的
Electron甚至添加了自动测试来验证捆绑节点和@ types / node的主要版本是否匹配,请参见https://github.com/electron/electron/blob/f426ad1b5914295f9684036fb55f918c1b074900/spec-main/types-spec.ts
@ types / node和nodejs的版本之间没有直接的联系
有些人试图表现出问题是电子7所使用的
节点12而不是13。
对于好奇的人,请检查@ types / node和nodejs版本相关性:
您可以克隆https://github.com/DefinitelyTyped/DefinitelyTyped并执行git log -L 1,1:types/node/index.d.ts --pretty=oneline
以查看提交消息与types/node/index.d.ts
文件更改的第一行/标题相对应。 因此,这几乎表明@ types / node的版本对应于nodejs版本。
c47a34ead1637f6f34e7d630dc88ea3f6e5562cb feat(node): v13 (#40927)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 12.12
+// Type definitions for non-npm package Node.js 13.1
a91a9a49ded5dd536a4bb0d2098eb1b0de1eadcd feat(node): v12.12 (#39914)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 12.11
+// Type definitions for non-npm package Node.js 12.12
cbe21d594a3b24fd1b93719958bc90ab6007ac51 feat(node): v12.11 (#39116)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 12.7
+// Type definitions for non-npm package Node.js 12.11
3f6627ea70b804317b90c0212b2055eff0a67a6f feat(node): v12.7 (#37217)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 12.6
+// Type definitions for non-npm package Node.js 12.7
4db4c26549c7edd452c46492f3421d5dce3200b0 feat: node v12.5 (#36562)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 12.0
+// Type definitions for non-npm package Node.js 12.6
18b13d1f4a6830861bf4f693a706dcde4aa8b21f feat(node): v12 (#34952)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 11.13
+// Type definitions for non-npm package Node.js 12.0
e6625ba155c7529e8bfb751a23b0d12bb8fe1ec5 feat(node): v11.13
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 11.12
+// Type definitions for non-npm package Node.js 11.13
923fe86451333613c015358a7447ed914945427f feat(node): v11.12 (#33967)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 11.11
+// Type definitions for non-npm package Node.js 11.12
bac137341280d31ee0f8159ddad66b0fa144e5fa feat(node): v11.11
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 11.10
+// Type definitions for non-npm package Node.js 11.11
80fb3119f40c6b70e4a9632887980036e36f6b2b feat(node): v11.10
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for non-npm package Node.js 11.9
+// Type definitions for non-npm package Node.js 11.10
608c146d8982a2ff7307f0a3bdddd6d55cb1a63e Mark non-npm packages
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 11.9
+// Type definitions for non-npm package Node.js 11.9
c8dadc971b8524704c4b39243780e294d7a15f12 feat(node): enable strict null checks and add SharedArrayBuffer
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 11.6
+// Type definitions for Node.js 11.9
e69abd8af13b4dd17259e72898b118102993915d feat(node): v11.6
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.12
+// Type definitions for Node.js 11.6
df80e09009547e5556c09a16f3c715ecf9aff325 feat(node): 10.12 (#29689)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.11
+// Type definitions for Node.js 10.12
352f2a6a39758bead6182a0d04bcf0b8d7c7a381 chore(node): apply lint
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.11.x
+// Type definitions for Node.js 10.11
e17d39e6b09a1e44d7dd69fa22b3da42c7156948 feat(node): 10.11
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.10.x
+// Type definitions for Node.js 10.11.x
9061b19a3c7d676fc4aeacc825ab7790edad13c6 types(node): add changes from 10.10 (#28918)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.9.x
+// Type definitions for Node.js 10.10.x
374598de675780b1312912d43dff88f9fbfcf0d8 [node] Add http[s] request/get variants for 10.9.0 (#28193)
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -1,1 +1,1 @@
-// Type definitions for Node.js 10.7.x
+// Type definitions for Node.js 10.9.x
3c8f15080c5728847c627ba07a623276ef1869ab add timeout to http.AgentOptions (#21346
...
关于@ types / node v13。 您会看到它们在那里执行的操作,例如使用不同库的160 d.ts文件来使它们与@ types / node @ ^ 13兼容
declare class SomeClass extends NodeJS.EventEmitter
与
import { EventEmitter } from 'events';
declare class SomeClass extends EventEmitter {
因此, @ electron移动到@ types / node @ ^ 13的一天可能会遵循相同的方式。
CC @MarshallOfSound
我相信用<reference/>
import
/ export
替换<reference/>
可以开始,而无需等待Electron的Node.js v13升级,因为替换对于@types/node
v12也有效。
我对此很担心,因为它需要对electron.d.ts
很多更改。 由于<reference>
和命名空间的使用,目前import
语句在electron.d.ts
不可用。 因此,我们不能简单地将NodeJS.EventEmitter
替换import { EventEmitter } from 'events'
。 正如我在此问题的第一句话中所说,首先需要删除<reference>
并将export
到所有公共API中,以使用import
语句。 这些将破坏electron.d.ts
更改,因此我们必须在electron
软件包的主要版本中添加它们。
从DefinitelyTyped方面,我已经确认这是正确的更改。 以前的输入允许这样做:
new NodeJS.EventEmitter();
当然哪个在运行时不存在。
由于
<reference>
和命名空间的使用,目前import
语句在electron.d.ts
不可用。
某种意义上来说,当文件中有任何import
或export
声明时,该文件将成为模块,因此声明不再是全局的。 如果需要在同一文件中使用全局声明和导入的内容,则可以通过两种方式解决此问题:
declare global { ... }
块中。type EventEmitter = import('events').EventEmitter
代替import { EventEmitter } from 'events'
type EventEmitter = import('events').EventEmitter
。 但是,此语法仅在TypeScript 2.9和更高版本中可用。我认为可以确定是否有人在使用@types/node
的最新版本,而他们可能正在使用typescript
的半新版本(2.9年前发布了)
这不是真正的问题-电子制造的决定是他们是否需要支持TS 2.8或更早版本的任何人,因为他们大概只会向每个人运送相同的电子。 他们不能根据用户是否有最近的@types/node
有条件地发送新语法。
我认为将3.0用作电子使用打字稿的基准是安全的。 那将是18个月大。 (TS3.0于2018年7月发布,TS 2.8于2018年3月发布-它们之间甚至没有很大的滞后时间)
对于如何处理此问题,我没有真正的见解,但是作为合并导致此问题的PR的人,我只是想
@types/node
的有意更改,可能不会消失哦,我完全错过了这样一个事实:存在一个全局 events
。很抱歉错过that
我不知道动态导入语法在环境上下文中可用。 谢谢你让我知道!
是的, global { ... }
@types/node
v12中已经实际使用了global { ... }
块。 因此,在electron.d.ts
使用它应该是安全的。 我认为我们可以选择更简单的方式type EventEmitter = import('events').EventEmitter
。
我有一个实验,在namespace Electron { ... }
块中添加type EventEmitter = import('events').EventEmitter;
并从class BrowserWindow extends NodeJS.EventEmitter
删除NodeJS.
class BrowserWindow extends NodeJS.EventEmitter
。 但是,我得到以下错误。 我认为type EventEmitter = ...
只导入类型,但是extends
需要一个值,因此在这里不可用。
node_modules/electron/electron.d.ts:1657:31 - error TS2693: 'EventEmitter' only refers to a type, but is being used as a value here.
1657 class BrowserWindow extends EventEmitter {
~~~~~~~~~~~~
那么class BrowserWindow extends import('events').EventEmitter
2019年12月31日星期二,上午8:41 Linda_pp [email protected]写道:
我进行了一个实验,添加了EventEmitter =
import('events')。EventEmitter; 在命名空间Electron {...}块中,
删除NodeJS。 从类BrowserWindow扩展NodeJS.EventEmitter。
但是,我得到以下错误。 我认为类型EventEmitter = ...仅
导入类型,但扩展需要值,因此此处不可用。node_modules / electron / electron.d.ts:1657:31-错误TS2693:“ EventEmitter”仅引用一种类型,但在此处用作值。
1657类BrowserWindow扩展了EventEmitter {
~~~-
您收到此邮件是因为有人提到您。
直接回复此电子邮件,在GitHub上查看
https://github.com/electron/electron/issues/21612?email_source=notifications&email_token=AAQGPCWQTNSCLNGH77BAGJ3Q3NDYZA5CNFSM4J63DZ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHZKKTT4ment4
或退订
https://github.com/notifications/unsubscribe-auth/AAQGPCQEYHIK4RAH7C5PBBTQ3NDYZANCNFSM4J63DZ5Q
。
它不起作用,因为import(...)
语法返回Promise
值。
是的,用events.EventEmitter替换NodeJS.EventEmitter更加简单, @ amirburbea已经提到过。
events
全局值在哪里定义? 我只是将NodeJS.EventEmitter
替换events.EventEmitter
但出现以下错误:
node_modules/electron/electron.d.ts:1655:31 - error TS2552: Cannot find name 'events'. Did you mean 'Event'?
1655 class BrowserWindow extends events.EventEmitter {
~~~~~~
您需要先导入事件(从“事件”或const中导入事件
事件= require('事件'))
在2019年12月31日星期二,上午9:00 Linda_pp [email protected]写道:
是的,用events.EventEmitter替换NodeJS.EventEmitter甚至
更简单, @amirburbea https://github.com/amirburbea已经
提到。事件的全局值在哪里定义? 我只是更换了
具有events.EventEmitter的NodeJS.EventEmitter但出现以下错误:node_modules / electron / electron.d.ts:1655:31-错误TS2552:找不到名称'事件'。 您是说“事件”吗?
1655类BrowserWindow扩展events.EventEmitter {
~~-
您收到此邮件是因为有人提到您。
直接回复此电子邮件,在GitHub上查看
https://github.com/electron/electron/issues/21612?email_source=notifications&email_token=AAQGPCQI7Z7KPIVJG6ZN2UDQ3NF7JA5CNFSM4J63DZ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNWWXHZJCT4E4
或退订
https://github.com/notifications/unsubscribe-auth/AAQGPCWE4SZAMOWGPYMO7J3Q3NF7JANCNFSM4J63DZ5Q
。
是的,所以我认为我们需要选择@andrewbranch显示的第一个选项。 如上所述, import
语句在当前electron.d.ts
中不可用,因为它不是模块。 要使用它,我们需要删除<reference>
和名称空间,而需要使用export
。 这是electron.d.ts
的重大更改,因此时间安排很重要。
抱歉,我应该先说过我说过的代码。 这就是我的意思@rhysd :
但是,请注意,这会使EventEmitter
显示为全局,这可能不是所希望的。 我认为declare global
是一个更好的选择。
events
全局值在哪里定义?
我弄错了—我意识到events
和其他内置模块一样,在运行时在节点上全局可用,并假定它具有类型声明,但没有。
感谢您对@andrewbranch的支持! 我终于可以按如下方式修复electron.d.ts
而不破坏更改。 我确认tsc
成功编译。
https://gist.github.com/rhysd/c8d68f0399a84a5383aee67857642852
我将尝试修复自动生成逻辑。
仅供参考,我认为@sandersn也在为此工作。
他已经在尝试修复electron.d.ts
吗? 还是修复其他软件包?
我相信他正在从事电子自动生成的工作,但我不知道他走了多远。
好的,在开始进行此工作之前,我将尝试检查问题并提出请求。
我在https://github.com/electron/typescript-definitions/pull/163上提出了关于此问题的请求请求。
我在electronic / typescript-definitions#164上有另一个2.9之前兼容的版本,但是只有在旧的Typescript兼容性非常重要的情况下,我才使用它。 当我评论了electronic / typescript-definitions#163时,我们从VS和VS Code中看到的数字表明可能不是。
我在LTS版本(v12.14.0)上也遇到了同样的问题。 在合并PR之前是否有其他解决方法,而不是降级node js版本?
@jodo如果您使用的是yarn,请在package.json
以下内容:
"resolutions": {
"@types/node": "12.12.6"
},
否则,它可能会因某些部门而隐式解析版本13
使用以下网址的说明时,对我来说也是同样的问题: //www.electronforge.io/templates/typescript-template
我现在可以通过在初始化目录中执行以下操作来解决此问题:
npm install @types/node --save
然后编辑package.json更改
"dependencies": { "@types/node": "^13.1.4", "electron-squirrel-startup": "^1.0.0" }
至
"dependencies": { "@types/node": "12.12.6", "electron-squirrel-startup": "^1.0.0" }
最后运行
npm install && npm start
降级到12.12.6
帮助。
如果要使用节点13,该怎么办?
解决此问题的PR已创建。 等待修复程序发布
FWIW在12.12.24看到了这一点。 安装12.12.21后将其修复。
FWIW在12.12.24看到了这一点。 安装12.12.21后将其修复。
否。我确认v12.12.24不会导致此问题。
我还检查了node/v12
目录,但NodeJS.EventEmitter
仍然是一个类,如下所示:
因此,当前的@types/node@12
不会导致这种情况。
知道何时将其在电子7.x中释放吗?
2020年1月29日星期三,晚上10:33塞缪尔·阿塔德[email protected]
写道:
通过以下方式关闭#21612 https://github.com/electron/electron/issues/21612
电子/打字稿定义#163
https://github.com/electron/typescript-definitions/pull/163 。-
您收到此邮件是因为有人提到您。
直接回复此电子邮件,在GitHub上查看
https://github.com/electron/electron/issues/21612?email_source=notifications&email_token=AAQGPCVGBYHYTYWCIIN4G4LRAJKDJA5CNFSM4J63DZ52YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWJKXOZI#event-2991945573 ,
或退订
https://github.com/notifications/unsubscribe-auth/AAQGPCQGYV42DTDJPPZKGUTRAJKDJANCNFSM4J63DZ5Q
。
目前建议的修复方法是什么? 现在完全解决了吗?
目前建议的修复方法是什么? 现在完全解决了吗?
这对我有用
https://github.com/electron/electron/issues/21612#issuecomment -570892464
我可以确认已经使用最新版本v8.0.0解决了此问题。 谢谢!
@remusao无法解决!
我可以确认已经使用最新版本v8.0.0解决了此问题。 谢谢!
我仍然看到打开[email protected]的electronic.d.ts
class BrowserWindow extends NodeJS.EventEmitter
,再次需要是implements
我以为PR已合并,这不再是问题,但我们来了。 现在,由于您的错误评论,他们继续解决了问题!!!
@remusao无法解决!
我可以确认已经使用最新版本v8.0.0解决了此问题。 谢谢!
我仍然看到打开[email protected]的electronic.d.ts
class BrowserWindow extends NodeJS.EventEmitter
,再次需要是implements
我以为PR已合并,这不再是问题,但我们来了。 现在,由于您的错误评论,他们继续解决了问题!!!
@amirburbea首先,此问题已在5天前关闭,而我的评论是从今天开始的(因此,我对这个问题的状态一无所知)。
其次,在我的特定情况下,最新版本修复了类型错误。 可能是我们遇到了两个不同的问题。 我所知道的是,今天早上我能够将磁带库更新到最新的电子版8,并进行了类型检查,而以前却遇到类型错误。 我没有进一步挖掘:)
如果问题没有解决,请再次轻轻地指出细节,我相信团队会看一下。
很好,我是罪魁祸首-这不是你的错。 然而,电子团队解决这个问题的尝试是严重不足的。
似乎发生的情况是electron
@ 8.0现在在其package json
特别指定了@types/node
12-否则不尝试使用implements
extends
(本来可以为@types/node
12或13工作),因此yarn
在node_modules/@types/node
目录下建立了node_modules/electron
目录。 问题是,如果某个其他库调用了@types/node
13或*(它带来^ 13),则打字稿仅使用两个文件夹之一(而不是两个)。
我最终得到了以下文件夹结构,并且在编译时,打字稿仅访问了一个@types/node
(根目录为13.x)。
node_modules
> <strong i="19">@types</strong>
> > ...
> > node (13.x)
> electron (8.0.0)
> > node_modules
> > > <strong i="20">@types</strong>
> > > > node (12.x)
> ...
我对Electron的发布过程不是很熟悉,但是由于该项目已解决了该问题: https :
它已合并到typescript-definitions项目https://github.com/electron/typescript-definitions/pull/163中,但Electron项目尚未获得更新。
打字稿仅使用两个文件夹之一(而不是两个)。
实际上,可以将Typescript配置为使用您喜欢的类型。
npm install @electron/typescript-definitions --save
复制类型/节点=> node_modules / types
任何CLI命令对其进行更新?
目前是否有解决此问题的方法? 这在某些版本中修复了吗? 我们尝试了最新的每晚构建,但均未解决问题。
@marcschroeder如果不需要node @ 12添加到依赖项中。
例如npm i --save-dev @types/node@12
或yarn add -D @types/node@12
我应该使用哪种电子版本? 使用8.0.2时,出现以下问题:找不到模块:错误:无法解析'fs'
有任何想法吗?
Electron的维护者(或其他知道的人)能否澄清类型定义的发布周期是什么样子? 在过去的几周中,Eletron 8.x发行了多个版本,但没有一个随更新的定义一起提供。 这是否意味着他们将随Electron 9一起发货(这被认为是一项重大突破)? 还是此更新依赖其他内容?
关于此问题有任何更新吗?
我认为有关人员应该考虑提出一个新问题,因为这个问题由于被关闭而被忽略了(错误或未错误关闭是另一回事)。
对于电子类型,它已在PR中固定。 但是那些不在电子中
然而。 我的猜测是它将在电子9中
2020年3月12日星期四,弗拉基米尔·雅科夫列夫(vladimir Yakovlev) [email protected]
写道:
我认为有关人士应考虑在此问题上提出新的问题
似乎因为被关闭而被忽略(错误关闭或不正确关闭是另一个
物)。-
您收到此邮件是因为有人提到您。
直接回复此电子邮件,在GitHub上查看
https://github.com/electron/electron/issues/21612#issuecomment-598312507 ,
或退订
https://github.com/notifications/unsubscribe-auth/AAQGPCWQNFSU3CKHDMOU6GTRHEK63ANCNFSM4J63DZ5Q
。
电子9已经有beta版本了吗?
ami
对于电子类型,它已在PR中固定。 但是那些不在电子中
它已合并到typescript-definitions项目electronic / typescript-definitions#163中,但Electron项目尚未获得更新。
我的猜测是它将在电子9中
自从不应该是8.6.6 https://github.com/electron/electron/blob/4b9f2bc72599f99f0ac95bb8b3d63e1c2d146c72/yarn.lock#L43 -L44
电子9已经有beta版本了吗?
是。
因此,我现在切换到Electron 9并使用以下技巧绕过使用electronic的任何类型:
const electronic =窗口“ require” ;
electronic.remote.app.setLoginItemSettings({
openAtLogin:是的,
});
解决方法:
npm install
"@types/node":
"requires": {
"@types/node": "^10.12.18",
"electron-download": "^4.1.0",
"extract-zip": "^1.0.3"
},
"dependencies": {
"@types/node": {
"version": "10.17.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.17.tgz",
"integrity": "sha512-gpNnRnZP3VWzzj5k3qrpRC6Rk3H/uclhAVo1aIvwzK5p5cOrs9yEyQ8H/HBsBY0u5rrWxXEiVPQ0dEB6pkjE8Q==",
"dev": true
}
}
"requires": {
"@types/node": "*",
"electron-download": "^4.1.0",
"extract-zip": "^1.0.3"
}
@electron/typescript-definitions
版本刚被锁定文件https://github.com/electron/electron/commit/0d2e9679600bc757eeb34356dc9c3779d0edccee#diff -8ee2343978836a779dc9f8d6b794c3b2锁定文件,因此我想我们预期下一个版本将附带更新的d.ts。
为什么关闭? 这仍然行不通
我仍然有这个问题。 我不能长时间将@ types / node保持为12.12.21。
您能否重新打开该问题并进行修复?
我建议先打开一个新期刊,因为根据我的经验,已关闭的期刊不会在此处重新发表。
无论如何如何使其工作? 将“ @ types / jest”降级为“ 25.1.4”并不是长期的解决方法:(。谢谢。
现在,只有电子版v10附带了更新的定义(它使用@ electron / typescript-definitions @ ^ 8.7.2)。
运行npm install --save --save-exact @types/node@^12.12.6
。 此后,它仍然可以工作(甚至适用于Electron v8.2.5)。
此后,它仍然可以工作(甚至适用于Electron v8.2.5)。
当然,它是这样工作的。 这个问题的重点是项目中使用的其他部门需要node @ ^ 13。
谢谢@vladimiry ,我已经跟踪此线程达4个月左右,
即使是电子版v9.0.0也有同样的问题
正如在此问题线程中反复提到的那样,Node v13的电子版修复程序已经存在。 我做了一个公关,它被合并。 但是,即使在Electron v9中,集成到Electron的Node.js仍然是v12。 因此,使用@types/node@12
是正确的,此修复程序不包含在Electron v9中。 您应该使用@types/node@12
。
所以我在尝试在Angular9 / Electron9桌面应用程序中使用fs时遇到了同样的问题,在我看来,最好的解决方法是在preload.js中要求所有必需的类(在我的情况下为electronic.remote),而不是降级节点版本仅用于单个模块(电子)?
升级到电子版10,问题解决了!
最有用的评论
为什么关闭? 这仍然行不通