Code Monkey home page Code Monkey logo

Comments (7)

janslow avatar janslow commented on June 30, 2024 1

I think that would be ideal, as it's unlikely Node will perfectly fit into an ECMAscript standard in the near future.

As far as I'm aware, it's not possible to use lib.es6.d.ts without fully targeting ES6/ES2015 in the compiler options . This has the issue that some ES2015 features which aren't supported by Node 4.x (such as default arguments), aren't transpiled back to ES5, so causes an error when run on Node 4.

I'll have an experiment with trying to merge the modular ES2015 lib definitions into node.d.ts and will create a PR if I find something useful.

from env-node.

blakeembrey avatar blakeembrey commented on June 30, 2024

Things get tricky here, since it's technically provided by TypeScript if you enable lib.es6.d.ts.

One thing I'm interested in is whether we want something that works with pure noLib, I do think that would be great.

from env-node.

louy avatar louy commented on June 30, 2024

So the problem we have here, which is the reason why this will probably be done in a separate version/variation of the node typings and not the main one, is that you might get conflicts and break things for users who would use target: es7.

It's the same issue when using es6-promise typings with target: es6. It simply breaks your build and you can do nothing about it.

I'd love to see typescript allowing conflicts like that, but in the mean time, this will have to be in a separate declarations file probably called node-nolib or something.

We can still <reference /> the original file in the nolib version though.

Related: #1

from env-node.

janslow avatar janslow commented on June 30, 2024

That's a good point and it probably means this won't be fully solvable until microsoft/TypeScript#4692 is complete, to allow targetting platforms between ES versions in the TS compiler.

However, that issue is still at proposal stage and doesn't have a milestone release target, so I believe it would be useful to have an intermediate solution.

My thoughts are, if you are developing for Node.JS 4.3, you should target ES5 (the highest fully supported ES version, without any harmony options). You then use a node env definition to help fill in the gaps between ES5 and Node 4.3 (e.g., polyfills, collections).

As harmony options become core features across different minor versions, these definitions would need to target minor versions, as opposed to just targeting 4.x.

I'm not sure whether this solution belongs in this particular repository though, or in a repository called node-es5 (or similar), which depends on node@4.

Any thoughts on this idea?

from env-node.

louy avatar louy commented on June 30, 2024

I know the problem with TS now, and why Console worked but Error didn't.

Everything in interface Console was a function. Typescript has no problems with functions as it treats them as overloads. But anything else (read: attributes) becomes a problem.

I've added interfaces for Map/Set etc in map-set branch. The only important thing that's missing is Map#size and if we find a workaround for it everything else should be fine.

from env-node.

louy avatar louy commented on June 30, 2024

Actually, I found a workaround.

from env-node.

felixfbecker avatar felixfbecker commented on June 30, 2024

We should also add Object.assign() to Node 5.

from env-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.