Git Product home page Git Product logo

never-argument-type's People

Contributors

jordanrl avatar

Stargazers

 avatar

Watchers

 avatar  avatar

never-argument-type's Issues

never is confusing / not as readable in code

Having never as a function return type makes sense since the function is expected to always exit or otherwise never return.
For parameters, it seems confusing. function foo(never $var) seems like it should never have a $var parameter.

never having 2 different definitions is confusing. It meaning no further execution will occur for a function, and meaning a parameter requires a type is confusing.

As a side note, to me, it seems like it would be along the lines violating named parameters:

foo(
   reqVal: 1,
   var: 3
);

and that it would throw an error because a parameter named $var was being passed in.

The TypeScript article linked in the RFC indicates when to use the base types:

  • Use never in positions where there will not or should not be a value.
  • Use unknown where there will be a value, but it might have any type.

Seems like unknown or possibly typed would be a better, more understandable fit that a parameter must have a type. Such a type could potentially just be an alias or extension of the never base type, but would be more readable for parameters.

  • function foo(unknown $var) or function(typed $var) seems more understandable in code that the $var parameter would need to have a type defined.

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.