Category "types"

How can you define a function who's return type depends on the value of its parameter?

Let's say I want to define a function called zero that takes a string like "f" or "i" and returns the zero value for either float or int. So we could do somethi

How to check if enum type?

How can I tell if a variable is of type enum? I have installed PHP 8.1 on my Ubuntu 20.04. I'm testing the new "enum" types. Is something like that possible? is

Dependent Disjoint Unions in Typescript

Given a simple Record<string, Record<string, any>> defined as a constant record of possible named configurations, I want a type which dynamically re

How do I find Hash type If I know INPUT an OUTPUT

I have an encrypted hash and I don't know the HASH TYPE. I have 2 alternatives, one of them is surely correct (matches INPUT with OUTPUT). How can I find the ha

How do I check that a number is float or integer?

How to find that a number is float or integer? 1.25 --> float 1 --> integer 0 --> integer 0.25 --> float

Why can one column of the pandas DataFrame not be filled?

I'm having some problems iteratively filling a pandas DataFrame with two different types of values. As a simple example, please consider the following initializ

TS Types for Google Calander API

So was experimenting with the Google Calendar API and working on it with TS. However, I can't seem to find a proper type for most of its functions. I do know th

TypeScript failes to infer return type of constrained generic function in some cases, why is this happening?

I have this code, which works just fine in a simple case, meaning the "permissionList" const is type inferred, VSCode can suggest me the properties, such as "pe

React Navigation V5 custom header + Typescript Error: custom property 'rightButtons' does not exist on type 'object' (router.params)

I create custom header: const header = ({ navigation, route, options, back }: NativeStackHeaderProps): React.ReactNode => { const buttons: HeaderRightBut

How to do structural pattern matching in Python 3.10 with a type to match?

I am trying to match a type in Python 3.10 using the console: t = 12.0 match type(t): case int: print("int") case float: print("float") And I get t

I am trying to create a react app with typescript but I keep getting failed to compile on start

I am trying to create a react app with --template typescript and I keep getting this error: ERROR in Plugin "react" was conflicted between "package.json »

Oracle PLSQL extend type with date abs timestamp

I have the following code, which seems to be working. Is there a way I can add a date, timestamp to the type definition? If so, how would reference the columns

Can I short-circuit type evaluation?

I'm trying to create a composable configuration framework wherein each node in the dependency graph can access all of its upstream nodes. Although I've managed

prevent numpy stack method change INT data to float

I try to stack three one dimension array. a and b are int that can be work as index and c is float. After I stack this three with axis=0, the a and b data chang

How to add a value within specific key when extending an interface?

Let's say I have an interface: interface Person { age: number name: { first: string second: string } } And I want to extend Person to Friend, whi

Is there any reason or advantage to specify string column length in BigQuery?

I am new to BQ and experienced in OLTP RDBMS, I found the data in BQ for my company are mostly in STRING type while it was VARCHAR(255) or even less in the OLTP

Declare types from file with `export .. from` to global interface

I have the file with a lot of export { default as NAME } from './PATH_TO_FILE'; And I want to declare types to global @vue/runtime-core inside GlobalComponents.

Specifying a type in an interface of the type that inherits this interface

Need a real implementation of this code interface IExample{ public this ReturnMe(); } class Example : IExample { public this ReturnMe(){...} //returns an

How is a binary/bytes column sorted in sql?

The following query sorts a binary column in BigQuery: with tbl as ( select B'123' as col union all select B'234' ) select * from tbl order by col; ----------

Workaround for TypeVar bound on a TypeVar?

Is there some way of expressing this Scala code with Python's type hints? trait List[A] { def ::[B >: A](x: B): List[B] } I'm trying to achieve this sort