Generics Questions
Ad
Generics with Higher Order Function
I want to create a function that returns a constructor function for one of my existing react components. the return value is a
React/Typscript: typehint any doesn't work
I have a very simple react component named: github.tsx in it, i have this code: import react from 'react'
Generics that extend a static type aren't intellisensing
The handleonchange function does not autocomplete the key parameter and does not provide the correct type for
Best resource for learning .NET generics?
I've never used any of the .net generics in my work, but i understand that they are fairly popular. does anyone have any good links or book
How to remove switch to convert string to generic function
This is probably a newbie question but i couldn´t find a good answer even googling and reading a lot about the subject. i have a generic
Typescript creating a utility type for converting multiple optional props into required props
I am in the process of creating a utility type that could convert multiple explicitly specified optional props into required props. i am
Is there any way for generics themselves to take type parameters in Java?
Let's say i have a function with the following signature: <t> t f(list<t> a, t b) obviously, i can do the
Accessing non-generic members of a generic object
Is there a way to collect (e.g. in a list) multiple 'generic' objects that don't share a common super class? if so, how can i access their common
Generics in c# & accessing the static members of T
My question concerns c# and how to access static members ... well i don't really know how to explain it (which kind of is bad for a question isn't
Using Castle Windsor's fluent interface to register components in a decorator chain, when there are also specialised service-types?
I am trying to implement a decorator chain for my data-access based on irepository. i have a repository that does the data- access (at the moment
Ad
scala function to operate on any case class
I've been trying ot create a function that does some inflection on any case class but can't figure out how to pull it off on non concrete generic
Swift generics in protocols
What is an appropriate way to solve the following example with swift? i know because of type erasure that you cannot assign
Reduction procedure for MethodReference Expressions
Consider the following article from jls that describes the reduction procedure for the methodreference expressions during type inference
Generic function typedef in C - how to get rid of initialization warning?
I'm experimenting with generic-like code and i have a function like this (a lot of not relevant code removed): typedef uint8_t
Typescript mapped type from Array
Just an example function: // merges objects | arrays function merge(...values) { return
error: type may not reference itself as a requirement associatedtype Suffix: SuffixableContainer where Suffix.Item == Item
Above error come error comes in apple documentation code when i run on playground xcode 9.2
Generic type param in interface
I have an interface, interface a<in t> { fun onsuccess(response: t) fun onfailure() }
Property 'componentStack' does not exist on type 'string'.ts
I am implementing an errorboundary using typescript and react tslint is showing an error property 'componentstack' does not exist on
Generic React TypeScript component with 'as' prop (able to render any valid dom node)
I have this working as expected in the below example, my question is - is there anyway i can rewrite this so that i don't have to pass both a
Java compiler forcing raw use of paramatized interface
I'm trying to implement a generic interface with concrete types, but the java compiler is forcing me to instantiate it as raw. this is a mock-up
Define the type of an object with string keys and function values
I have a node js function with one parameter that is an object with keys and the values are functions that then resolve to the underlying
Ad
Would like to return different classes from a single generic method call without using object
I have three classes--very simple example: public class mytablelayoutpanelbase : tablelayoutpanel { } public class
Why cannot I use TypeToken the way I need?
I am trying to resolve a problem i have when deserializing a hashmap<integer, myparcelablepojo>. trying to find an answer, i
TypeScript - How to use Generic in a Re-Usable React Component
I have a reusable react component. it has a few props, which accept a generic. this is the compoent: export interface mappedobject
Python typing: return type with generics like Clazz[T] as in Java Clazz<T>
So i am aware of python's typing.optional. but i wrote my own crude pyoptional (code
Kotlin MVP implementation issue with generics
Trying to implement a simple mvp structure with kotlin, here are my base classes: abstract class baseactivity<p :
Generic[T] base class - how to get type of T from within instance?
Assume you have a python class that inherits from generic[t]. is there any way to get a hold of the actual type passed in from within the
undefined_named_parameter in super constructor of abstract class
I am very new to dart and flutter, and i've been trying to make two classes (successstate and errorstate) that implement an abstract class
Replacing string "true" and "false" from union type to booleans
I've got one union type that is constructed from object keys, which may contain string, number, and boolean keys. example:
Typescript: Infer generic type by checking string value
I have types like this: export type notificationtype = 'comment' | 'like' | 'message' | 'follow' | unknown type messagebody<t
How to deal with this Generic list conversion from Java to Kotlin?
In the process of rewriting java code to kotlin i need to define the object type of a list. the thing is that it is unknown and
Combine generic interfaces with two generic types into one type with only one generic type
In my case i'm working with usereducer from react
Ad
How to enable 'constructor-tearoffs' feature?
When i try to get the type of a class with generic class dummy<t> { t? value; } void main() { type t = dummy<int>;
Flutter: Generics assignment is not working on extended types of T
Why this generic classes throw errors? since t extends datamodel, it should allow to assign instances of datamodel but
Pass a class to Kotlin function to create ViewHolder in adapter
I have an abstract class: abstract class abstractviewholder(itemview: view) : recyclerview.viewholder(itemview)
Using subclasses with RxJava Observable
I'm facing an error with the following code: interface a1 { val string: string } data class a2(override var string: string =
Dart feed template/generic class with Type object, is it possible?
Is it possible to some how achieve something like that? class someclass<t> { }
Why direct usage of generic value is not possible but same is possible if returned from method in Dart
Why is it assigning a value to a generic field is not possible when assigned directly, but same is possible when using a variable reference or
interface contains type constraints: cannot use interface in conversion
Type number interface { int | int64 | float64 } type nnumber interface { } //interface
Filtering IEnumerable<T> dataset with T as Dictionary<string, object>
There is a data set as ienumerable<t> griddata which is bound to a data grid. in one scenario data loaded with t
Kotlin: check class type in a function
I want to have a list of activities and i want to loop through it to check if the current activity is of
Generic field/method in non-generic class in Dart
Is it possible, in dart, to have generic methods in non-generic class, like in java? i use
Dart: generic type extending a class with generic types in it
I have a class defined like this: abstract class questionpagebasestate<t extends question<dynamic, dynamic>>
Ad
Dart List.sortedBy function with generic Comparable as parameter wont manipulate the list
I want to order objects in a list by the value of the objects instance variables and i actually found exactly what i was looking for in this post:
How to use a generic type with `typeof Node<T>`?
Let's say we have some java node, stringnode and nodefactory classes:
Check if an operator is defined for the object in dart
I want to create an extension for a list which would return an in iterable of cumulative values, my approach was like this:-
Any reason C#'s List<T> Class, not having save or update method?
C#'s list<t> class
What's the difference between a generic slice argument and an argument constrained to slice types?
Consider the experimental package slices. the
How to turn an HList of Const functors into a Seq?
I have a higher-kinded data type like this case class foo[f[_] : functor](a: f[int], b: f[double]) and a value
How to solve 2nd level inheritance with generic classes?
I'm implementing an mvp architecture in kotlin and android studio shows no error, however it doesn't compile:
Passing generics to a component wrapped in a HOC
I have an implementation of the apollographql query component. when using the apollo client query component, typings can be passed as
Using a string as an index in typescript
I am trying to type the following interface istudenttype { [key: `${students}`]: istudent | istudentmaths|
How can I use a decorated name with _Generic?
I'm writing a library which lets the user decorate the function names like this: #ifndef
typescript map object return type
I run into some behavior that seems a bit weird to me. in the following example, i have two functions that take an object as an input and
Ad
How to do generic onTouchEvent method for kotlin?
I have such a method. in loginactivity.kt. what i want to do is make this method generic and use it everywhere. i want to write a method in
Generic type in useReducer for a returned parameter
I am writing a custom hook to fetch some data from an api. i would like the returned data to be type-safe if possible. can this be done with
Dart generic type as class-member function's type
I have a class which wokring with generics: screen bloc class
Typescript Generics: Use output argument type to build input argument type
I want to use generics to decrease maintenance, and possible chance of errors while maintaining, typescript types. i have a function
Freezed class with generic callback
I would like to define a freezed class [https://pub.dev/packages/freezed] with a generic callback. freezed class: import
How to pass a function onto a generic function parameter in Flutter?
For example, i have this function parameter: class myclass { u function<t, u>(t data) callback; myclass ({ this.callback
How to force generic argument to be only one type of an union
I have following code (simplified): const todoapi = { add(name: string) {}, edit(id:
How to properly convert currency in C#
I have been working on a currency convert on vs in c# , my current challenging is how to properly convert dollar to frank ,euro to pound sterling
Dart Result with TypeError Exception
I have the following result object: class result<t> { result._(); factory result.success(t t) =
Is there any way to instantiate a Generic literal type in typescript?
I want to do something that's probably unorthodox (and borderline useless if we're being honest) so here we go: i want to pass a literal
How to exclude interface property from extended class in typescript
I have two classes interface ibasicfunctionalityprops { propertyspecificforbasicfunctionality: mytype;
Ad
Typescript function with an argument that gets its keys from another argument
I want to create a function that accepts two arguments, the first is an object that includes an array of strings that are the required fields for
What is the same as `R` (generics) in Rust?
What is equivalent java's r (stands for return) in rust? for example, how can i write something like this in
java generic how to ensure type has specified annotation?
I'm trying to create a generic class in android using java but i want to make sure that the type would take specific classes with specific
Why does my generic extension method require dynamic instead of concrete type?
Given an extension method extension listextensions<t> on iterable<t> { double sum(double extract(t)) { double
Type '{}' is not assignable to type 'ComponentProps'
I'm getting the following error when creating a high order component with typescript. can you please help me solve this issue ?
Use typescript to create union object of keys in objects
I have the following object: const myobject = { one: { fixed: { a: 1 } }, two: { fixed: { b: true
How to use generics in props in React in a functional component?
In a class based component, i can easily write some code like this: import * as react from 'react'; import { render } from
Flutter/Dart: The argument type 'bool Function(MyStateNotifier)' can't be assigned to the parameter type 'dynamic Function(dynamic)'
I have a such class declaration in dart, but when using it the compiler reports error
Declare a variable in type that includes Generic
I am trying to declare a variable and define it's type: const state: state<a, b, c> = { ... }; i am
How to enforce Implements constraint on generic type T in generic Dart method?
What i'm trying to achieve i am trying to create a generic dart method that takes a generic type t where t has to implement class imodel.
Typescript syntax
I'm new to typescript, and working one of my company's repos that uses it heavily. (we're building a react/redux app.) i'm familiar with the
Ad
Kotlin Generic abstract function
I have an abstract function, where i want to get any of my activity presenters in baseactivity protected
Improving code with reflection and generics
With the following code, how could i improve its readability using reflection and generics? it's a lot of repeated code, but i'm new to these
TypeScript: Infer type of <this> in Object extension method
I am trying to implement something similiar to the let
how to make a function to return a generic of struct?
I'm learning genric in go. i have struct user and member, and i want to make a function to return user or
Rust: different return values dependent on value of generic constant
Let's consider a function like this: fn test<const n: usize>() -> [f64; n] { if
Kotlin extension function with Generic doesn't work with Any?
I want to have an extension function from the realmlist class: private inline fun realmlist<any?>.saveall() {
typescript generics definition dependency
I want to define a generic class like table <t> where t is the interface of the data structure that the table will be bound
template doesn't exist using generic views
Following the django tutorial i have changed to generic views and now my templates cannot be found anymore. error: templatedoesnotexist
Typescript Generics wrapper: Untyped function calls may not accept type arguments
This code snippet with generics works perfectly fine
Typescript type not narrowed in generic function
Take for example the following types. type zoneandtools = { a: number, b: string, c: object, } type zonetypes = keyof
C# base class extension is called instead of the one for a derived class
I have class a which is a base class for b. and an extension for both types. then if i call an extension from a generic function (even with an
Ad
Java generics: Does "T2 extends T1" imply "T1 super T2"?
If i have a generic <t2 extends t1>, does the compiler infer t1 super t2? i have a more complex collection,
How do I access the properties of a generic object by index in TypeScript?
I have the following function that goes through all the attributes of an object and converts them from iso strings to dates:
Kotlin Upper Bound: What difference does `:Any` make to Kotlin's generic type inference?
Following the kotlin for android developers book, we come across extension function fun <t:any>
Dart - Casting List<SuperType> to List<SubType> using generics
I am new to flutter and dart, coming from native android. android has a very nice database abstraction architecture called the room
Typescript Create a type whose properties are the properties of an interface
I have an interface definition as follows export interface routingmap { ticket: { id: number }, car: {
Reflect on TypeVar in Custom Generic Class method
Consider the code bellow. >>> class a(typing.generic[t]): ... @classmethod ...
Why doesn't union distribution happen with T[number] where T is an ArrayLike?
In the example below
Typescript: Type '{}' is not assignable to type 'Pick<T, K>', how do I type javascript `pick` function correctly?
I want to type a function called pick, i know typescript has built-in pick<t, k>, now i want to implement the
In flow how to accept a heterogeneous array, and return that array
When i have a function which accepts an array of a generic type and return a transformed array, i could write: function
Typescript: Typing a function that returns a subset of an object
I'm trying to type a function that returns a subset of the properties of an object that it is given. i'm not sure why the following does not
Eureka Forms Hide validation errors based on SegmentedRow
I am unable to hide the validation errors based on the value of each segmentedrow (upon switching). edit: eureka version 4.0.1
Ad
How to compare generic type to 1
The following extension method returns a plural version of s only when value is not equal to 1. public
java enforcing the return type to generic types instead of Object types for constructing map using collectors and streams
I'm trying to construct map<string, graphnode<character>> from list<pair<graphnode<character>,
Ad
Blog Categories
Ad