GithubHelp home page GithubHelp logo

Comments (7)

danvk avatar danvk commented on May 18, 2024

Comment by Viacheslav Dobromyslov (viacheslavdobromyslov) on 2020-08-13 06:12:

Thank you for these examples. I want to add just one small note: els.map(el => '' + el) is not a good way to convert number to string. ESlint will mark it as an error.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by danvdk on 2020-08-14 10:38:

Are you referring to the no-implicit-coercions rule? The argument against '' + x for string coercion there is entirely stylistic. Error and "not a good way" seem a bit strong for a matter of style.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by Zackery Zing (zackeryzing) on 2020-08-14 02:59:

In my linting rules, I always force functions to have a return type. I think in an article like this it is useful to have return types on all functions so there is no missing information.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by danvdk on 2020-08-14 07:35:

What I’d really like is to have mouseover in the code snippets on the blog to see the inferred type, just like in your editor. I know some people (and some linters) insist on annotating all return types, but I do not.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by Romain Deneau (romain_deneau) on 2020-08-18 04:22:

Useful rule, nicely explained in this article πŸ‘

I suggest to rename it "The Golden Rule of Generic Functions", because it's about functions, not all generic types - see basic counter example: in this generic type, type WithValue<t> = { value: T }, T appears only once.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by Vincent Jaubert (vincentjaubert) on 2021-05-16 05:14:

This is indeed pure gold, thank you.

from effective-typescript.

danvk avatar danvk commented on May 18, 2024

Comment by ThomasBurleson on 2021-12-07 11:32:

I really enjoyed reading this. Very important heuristics.

from effective-typescript.

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.