Typing issue with void functions
See original GitHub issueDescribe the bug
When using typescript and operation like drop
, it cannot be chained directly to another operation or the compiler will throw an error like Property 'to_csv' does not exist on type 'void | DataFrame'.\n Property 'to_csv' does not exist on type 'void'.
To Reproduce
import { DataFrame } from 'danfojs-node';
const df = new DataFrame([]);
df.drop({ columns, inplace: false }).to_csv();
Expected behavior
It should return void
only when using inplace: true
. Currently it assumes it could be both, but the parameters should infer which return type it expects.
Typescript version 3.9.10
and danfojs-node
version 0.3.3
used
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Functions 2: Void (NonValue-Returning) Functions
Void functions are created and used just like value-returning functions except they do not return a value after the function executes.
Read more >Why any type can be assigned void* but I can not return void ...
void is an incomplete type; it does not specify an integer type, a floating-point type, a structure type, or any other specific type....
Read more >2.3 — Void functions (non-value returning functions) - Learn C++
A void function will automatically return to the caller at the end of the function. No return statement is required.
Read more >Optional typing in GDScript: Allow return "void" from ... - GitHub
One reason you might need it is if you are calling a function that you don't know in advance, like if it is...
Read more >Void in TypeScript - TutorialsTeacher
TypeScript Data Type - Void ... Similar to languages like Java, void is used where there is no data. For example, if a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hum maybe later, I currently cant even use the library because I am on a M1 Mac so…
FYI, this can be fixed this way: https://www.typescriptlang.org/docs/handbook/2/functions.html#function-overloads