Category "types"

SQL Server : unable to save decimal digits

I am facing a peculiar problem. I have a few tables in SQL Server where I have properly declared a few columns as decimal(18, 2). Unfortunately, whenever, I sav

Is there a way to keep type inference in union types from type guards inside a function?

Let's say I have three types (and a union one) type A = { type: 'a' title: string description: string } type B = { type: 'b' title: string

Typescript: Enforcing property type based on another property value which is a key of a generic

Given the following type: export type MyType = { a: boolean; b: number; } I want to create a type: export type Mapper<T> = { key: keyof T;

Elasticsearch “data”: { “type”: “float” } query returns incorrect results

I have a query like below and when date_partition field is "type" => "float" it returns queries like 20220109, 20220108, 20220107. When field "type" => "l

Alternative to index signature

I have an array of object like this: [ { "bio": "Douglas Gerald Hurley is an American engineer, former Marine Corps pilot and former NASA astronaut. He la

how to make an iterable type in type script that has a key value pair

I am using type script and I want to make a type that represents an object like this the keys generated are genrated dynamically how do I do that { dog:true,

Typescript, merge object types?

Is it possible to merge the props of two generic object types? I have a function similar to this: function foo<A extends object, B extends object>(a: A,

Typescript reduce return wrong Type and also forbid to assert it

Faced very strange ts behaviour. type Labels = Record<string, boolean | undefined> type LabelGroups = Record<string, Labels> export function reduc

Which C/C++ data type should I use for PHI(N) calculator?

I found a source code online for calculating PHI. I made some small adjustments to the variable types, such as using an unsigned long int, however I am limited

How to capture Typescript conditional property type

I have the following Typescript type: type Config = { key: string, type: `input` | `switch` | `radios` | `select` | `checklist` | `image`, options: string

Destructure a function parameter in Typescript

I'm trying to give a type to the members of below function. args is an object with a data property of type UserCreateInput So, from this: createUser(parent: a

How to create a generic buffer in TypeScript?

I have the following class: export class BufferData { arr: Float32Array; index: number; constructor() { this.arr = new Float32Array(8); this.inde

It Is possibile to map typescript object to another based on interface/or type [duplicate]

If i have an object in typescript const x = {a:1, b:2} And an interfacce interface MyInterface { a: number } It possibile to do something li

VHDL: Are enumerations in multiple type declarations named the same treated as the same value?

See the following simplified code example. The reason for trying to do this is do to reporting on missing FSM transitions to ST1 in return_to_states when retur

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