Skip to main content

Questions tagged [types]

Types, and type systems, are used to enforce levels of abstraction in programs.

types
1 vote
0 answers
21 views

Unexpected behavior when combining mapped type created from Union that is used within conditional type [duplicate]

I came across some unexpected behavior when trying to expand mapped type I created from an union of object types, when trying to use this type within conditional type: Playground export type ...
Jarek's user avatar
  • 7,641
1 vote
1 answer
19 views

How to Properly Implement Role-Based Authorization in React Using Context API and React Query?

I am trying to work on a React application where I want to implement role-based authorization. My goal is to fetch user roles from an API and store them in context so they can be accessed throughout ...
yzkael's user avatar
  • 43
0 votes
1 answer
108 views

How to parameter pack pairs of types?

Here's an example usage of a parameter pack: template <typename... T> bool foo(A x) { return (baz<T>(x) || ...); } I'd like to do something similar, but with pairs of types. Here's an ...
user129393192's user avatar
-3 votes
0 answers
85 views

c++ how to convert std::string to std::map? [closed]

i want to know how i can convert a std::string to std::map! map<string, string>New_Map = {{key1, value1}, {key2, value2}, {key3, value3}}; #include <sstream> #include <iostream> #...
Marius Romeiser's user avatar
1 vote
1 answer
57 views

C# generic method detect if T is array and then index into the array

I'm trying to write a Dbg debug function that will print out some debug info about the given parameter and then return it. I would like arrays to be printed as the list of elements, and scalars to ...
beyarkay's user avatar
  • 768
-2 votes
2 answers
87 views

Custom integer-like datatype with support for static casts without warnings

I'm writing my own little utility library, and I've opted to do something which I don't really see often (and there might be a reason) - I'm trying to implement a 'perfect' wrapper around C++ integer ...
Goubermouche's user avatar
-3 votes
2 answers
49 views

Pass Function with Struct Parameter to a Struct in Go [duplicate]

Taking this example struct (my side): type Route struct { // other fields Handler func(any) } This is what the example user of my code would look like: type HelloWorldInput struct { ...
theheavycoder's user avatar
0 votes
0 answers
26 views

exported variables always return undefined in discord.JS V14

in events/messageCache.ts: import { Events, Message } from 'discord.js'; export interface MessageCacheEntery { authorID: string; deleted: boolean; message: string; timestamp: number; }...
Jaco's user avatar
  • 11
1 vote
1 answer
31 views

Extract Generic Interface or Type keys as an Array [duplicate]

I want to know if it's possible to get a generic interface or type and get it's properties like an array of objects, like this: interface UserData { email: string } keys = extractKeys<UserData&...
João Pedro's user avatar
-2 votes
0 answers
38 views

Returning an array of raw type but instead of an array of parameterized type specified at the header

protected Collection<Node> createBucket() { return new LinkedList<>(); } /** * Returns a table to back our hash table. As per the comment * above, this table can be an array of ...
Pius's user avatar
  • 1
0 votes
0 answers
28 views

Joda-time type mapping in Hibernate ORM 6

I'm new to Java and I am trying to migrate from Hibernate 5 to 6. My application uses joda-time for the timestamp data type. It is using both annotation and hibernate mapping files. Following is a ...
tieuquynd's user avatar
0 votes
1 answer
47 views

Dynamically set the Property name to be the name of the Type(typeof(T).Name)

var appsettings = JsonConvert.DeserializeObject<AppSettings<PersonModel>>(configData); class AppSettings<T> { [JsonProperty(PropertyName = typeof(T).Name)] public T ...
Imran K's user avatar
  • 15
2 votes
1 answer
39 views

Casting RDD to a different type (from float64 to double)

I have a code like below, which uses pyspark. test_truth_value = RDD. test_predictor_rdd = RDD. valuesAndPred = test_truth_value.zip(lasso_model.predict(test_predictor_rdd)).map(lambda x: ((x[0]), (x[...
Inkyu Kim's user avatar
  • 145
1 vote
0 answers
22 views

When using WC_Product_Variable, it creates a simple product [duplicate]

I am trying to progmatticly create a Variable Product in WooCommerce like so: $currentProduct = new WC_Product_Variable(); $currentProduct->set_name( $product['Title'] ); ...
francis astin's user avatar
0 votes
2 answers
46 views

TypeScript Type narrowing not working for collection schema

I'm working on an Astro + TypeScript project where I have few data collections with specific schemas. I'm using the Zod library to define and structure each data collection, which in a simplified way ...
Mauricio Esparza's user avatar

15 30 50 per page
1
2 3 4 5
1934