Comments (11)
@zeke Hm, this is one we didn't think of 🤔
I mean, technically the typings are accurate but the AMD definitions override the built in require
function, maybe this is something that can be fixed in the AMD typings (somehow overriding the nodejs require declaration)
from electron-prebuilt.
That's not actually the case: the Typescript compiler can't actually suppose you are using nodejs so there is actually no built in require
function. That's why you need typings if you want to use the require function which is defined in e.g. @types/nodes
or ˛@types/requirejs
, but obviously they are not compatible so installing both packages will result in build error.
from electron-prebuilt.
@tothdavid The thing is Electron has all Node.JS API's (including require
) built in, this is what I meant by the built in require
function. If @types/requirejs
needs to override that require I'm not sure how we can facilitate that or if it's something that needs to be fixed in those typings
from electron-prebuilt.
Sure, that's perfectly fine that you have electron building on node.js, but why do you expose @types/node
as a dependency when you don't even have any other .ts/d.ts in your package? Why is it not only a devDependency?
The thing I am telling you is that the @types/requirejs
typings are not wrong, they are just different as commonjs is not really a valid option when your code runs in a browser. Also as I mentioned above using electron for running unit tests are a pretty common use case for any projects not just for the ones targeting node.js.
from electron-prebuilt.
why do you expose @types/node as a dependency when you don't even have any other .ts/d.ts in your package
We do? Check an install of electron
, it will contain an electron typings file (only the more recent versions of electron have this file).
Also the latest version of this typings file is in the repo at the moment
https://github.com/electron-userland/electron-prebuilt/blob/master/electron.d.ts
The thing I am telling you is that the @types/requirejs typings are not wrong
I'm not saying they are, just saying there must be some way to resolve a conflict between two type declarations 😄
from electron-prebuilt.
Oh, sorry, I checked the wrong version. :( But I can see it now.
You could still separate the typings from the main npm package and push the typings to a @types
scoped package, but even typescript's recommendation is to publish them together:
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html
Unfortunately require
is a special function as it needs to be globally defined so there is not really a way (or at least none that I know of) to make both of them work in a single context.
from electron-prebuilt.
Why not using this https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/electron/index.d.ts ?
from electron-prebuilt.
@kenshyx That type definition file is community maintained and published to the @types
scope, we now publish our own first-party typings file generated at build time from our docs and ship it with the electron
module.
from electron-prebuilt.
Yeah, but it's a good base to use, right now that module will become unusable because they clash.
from electron-prebuilt.
@kenshyx First party typings are supposed to supersede the definitely typed modules. In the near future, the @types/electron
package will probably be deprecated as people shouldn't be using both. They will just naturally get typings from the electron
package.
from electron-prebuilt.
The electron-prebuilt repo is being retired and its code has been moved into the electron/electron repo. For the sake of historical transparency, we will leave GitHub Issues enabled on this repository, but if you are still affected by the issue reported here, please open a new issue on electron/electron repo and reference this issue from it so people can get the full context. The electron repository has a large and active contributor community, so your issue is more likely to get the attention it deserves there. Thanks!
For this issue specifically, https://github.com/electron/electron-typescript-definitions might be the most appropriate place to continue the discussion.
from electron-prebuilt.
Related Issues (20)
- OpenBSD as a supportet platform? HOT 2
- Unable to install Electron with the quick-start tutorial HOT 7
- "sudo npm install -g electron" fails HOT 1
- Electron not installing (Windows 10) HOT 2
- Got stuck after npm install -g HOT 1
- Error while installing npm in windows 10 HOT 1
- Mac: Failed at the [email protected] postinstall script 'node install.js'. HOT 4
- npm install hangs HOT 3
- Can't install electron 1.7.1 locally using npm 5 HOT 10
- Install on Bash on Ubuntu on Windows (WSL) HOT 13
- Postinstall script failing HOT 22
- Error: Generated checksum for "electron-v1.4.13-linux-x64.zip" did not match expected checksum. HOT 11
- Prebuilt electron package for Ubuntu 10.04 32 bits HOT 1
- node (vs. nodejs) is required when installing electron HOT 5
- Can't install in Windows10 HOT 1
- Change electron binary path via environment variable? HOT 2
- Electron not installing on Mac Os High Sierra HOT 1
- npm ERR! [email protected] postinstall
- Error while installing electron on Mac
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-prebuilt.