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)
orfunction(typed $var)
seems more understandable in code that the$var
parameter would need to have a type defined.
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.