Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [types]

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

types
1 vote
1 answer
39 views

R get local variable from formula

Consider the R code : foo <- function(formula){ Y <- get(formula[[2]]) print(Y) } main <- function(){ Y <- 1 X <- 2 foo(Y ~ X) } main() The outcome says that in get(...
温泽海's user avatar
  • 344
0 votes
0 answers
22 views

check if given object implements certain generic interface; type argument(s) NOT known [duplicate]

I have some object. I want to check at runtime if it is an IReadOnlyCollection<T> of any T, i.e. I cannot specify that T in my check. So it should return true for e.g. IReadOnlyCollection<...
Kjara's user avatar
  • 2,794
0 votes
0 answers
37 views

As a wrapper object in JavaScript, why can not use 'new' to create a BigInt in JavasScript? [duplicate]

There are 5 wrapper objects in JavaScript: Number, BigInt, String, Boolean, and Symbol.You can use 'new' to create a Number, String, Boolean, Symbol. But you can not use 'new' to create a BigInt. what ...
Leo qiao's user avatar
-2 votes
0 answers
80 views

Are there objects for primitive data types? [duplicate]

If the object represents a data type, is the variable for a primitive data type like an integer also an object representing this type, or do objects not represent primitive data types? // Let's assume ...
Ahmed Hamed's user avatar
1 vote
1 answer
55 views

Why print(f"{variable = }") in Python 3.12 also prints numpy type?

I noticed, that with Python 3.12 and a numpy.float64 when I simply do a x = numpy.sqrt(3) # type is <class 'numpy.float64'> now print(f"{x = }") # this is printed >>>x = np....
emefff's user avatar
  • 11
0 votes
1 answer
53 views

How to enforce error on impossible switch case?

There is a linter we can enable for equality check. What about switch case ? This does not seem to work. https://stackoverflow.com/a/78736339/6727914 How to convert the warning into errors ? Example: ...
TSR's user avatar
  • 19.5k
3 votes
1 answer
62 views

How to enforce error on impossible equality check?

There is a linter to it https://dart.dev/tools/linter-rules/unrelated_type_equality_checks but it just shows a warning, rendering it almost useless for large projects. How to convert the warning into ...
TSR's user avatar
  • 19.5k
1 vote
0 answers
18 views

Why am I having an issue with typescript and Prisma ORM when trying to find a unique item?

I am having issues with my ability to use the prisma .findUnique() function call. My code doesn't show any compilation error, but when I actually try to go to a product page it causes a runtime error. ...
The Elina's user avatar
0 votes
1 answer
21 views

Checking subclass against metaclass type

I have a set of plugins that inherit from a metaclass. the metaclasss is defined like so: from abc import ABC, abstractmethod class MetaReader(ABC): def __init__(self, arg1, arg2, **kwargs): ...
KBriggs's user avatar
  • 1,362
1 vote
0 answers
28 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,673
1 vote
1 answer
46 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
  • 67
0 votes
1 answer
161 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
2 votes
1 answer
62 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
  • 809
-2 votes
2 answers
94 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
0 votes
0 answers
32 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

15 30 50 per page