Questions tagged [types]
Types, and type systems, are used to enforce levels of abstraction in programs.
types
28,919
questions
1
vote
2
answers
73
views
Can't understand the reason for this Typescript generic issue
I am learning TS and have the following code:
function getOrDefault<T = string>(value: T, defaultValue: T, car: T): T {
return value || defaultValue;
}
const strValue = getOrDefault("...
1
vote
1
answer
87
views
Inherited functions returning self reference with derived type
I am trying to create a system where one base class has a bunch of functions, then derived classes can inherit it and add more functions. However, all of these functions return the this keyword and I ...
1
vote
1
answer
66
views
Handling Dynamic Outputs in Swift Functions Without Sacrificing Type Safety (Any)
I have a basic custom structure in Swift where using Any for input types is less than ideal due to the language's statically typed nature, which can bypass the compiler's type checking and lead to ...
0
votes
0
answers
76
views
c++ warning: non-void function does not return a value in all control paths
warning: non-void function does not return a value in all control paths...
I know what it means, because the for loops don't return something when the data is empty.
How should I fix it?
template<...
0
votes
0
answers
28
views
What is the benefit of Axios' type variable for response data?
Axios request functions are typed as
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>
(delete, post, etc. are analogously typed), where ...
0
votes
2
answers
33
views
Generic types dependencies between function arguments
I'm trying to use binding for a game engine. And I want to add a little typing
/** Engine external functions */
export type Message<TBody> = { }
// This function returns same unique object for ...
0
votes
1
answer
86
views
Should I prefer `dynamic` or `Object?` for generics in Dart?
I've been trying to understand how I should enforce the strict-raw-types rule from Dart, and make sure my code adheres strictly to the type system.
I understand the difference between dynamic and ...
2
votes
1
answer
92
views
Use of protocol as a type must be written with any (Learning Purposes)
I've translated code from a functional programming language to Swift, and it works well when verifying via variables. However, I encounter an error when testing, attributed to Streamable and any ...
-1
votes
0
answers
16
views
Tensorflow is not casting my tensor as type float64 when I want it to, how do I fix it?
It's basically in the title. I'm trying to cast a tensor as a float64 for extra precision and so it can match what the data type of my bias is. However, despite calling the tf.cast function, it's ...
1
vote
0
answers
77
views
Why does type inference fail in this Java program?
Let's consider the following Java program:
import java.util.*;
import java.util.stream.Collectors;
public class Main {
record Foo(String id, List<Bar> bars) {}
record Bar(String id) {}...
0
votes
0
answers
78
views
"Unable to Create App State Field 'saveforlater' with Document Reference Data Type in Flutter Flow"
Story
In my Flutter Flow project, I'm working on implementing an app with functionality similar to a shopping cart. I have successfully implemented the "Add to Cart" feature, but I am ...
2
votes
1
answer
39
views
Wrapped functions of a Python module raise TypeError
I am currently trying to replace a module in a large code base in a certain condition and to figure out when any function of this module is called, I wrap each function/method in the module with a ...
0
votes
0
answers
21
views
How to Mock a Boolean Hook and a Database Update Call Within a Custom Hook to Bypass Them
The issue I am facing is that I have a custom hook that is asynchronous and does three main things:
A. It makes a check; if the check is true, it continues.
B. It makes a Firebase call; if successful, ...
1
vote
1
answer
81
views
How does the arrow operator in haskell make sense in functions that take more than one parameter?
FYI: Second day into Haskell
MRE (what the function does, does not matter):
foo :: Int -> Int -> Int
foo x y
| x == y = x + y
| x < y = x
| x > y = y
This is what ...
0
votes
1
answer
30
views
Is there a smart Typescript way to handle complex union type problems with the Notion SDK?
I'm writing a function in Typescript for cloning a specified block/page in Notion using their API. Since there isn't a provided endpoint for duplicating pages programmatically, I've decided to attempt ...