types Questions
2
Solved
I'm trying to write an extension method that will add the function HasFactor to the class int in C#. This works wonderfully, like so:
static class ExtendInt
{
public static bool HasFactor(this in...
Hifalutin asked 1/1, 2010 at 23:41
0
I have been exploring different abstractions in Swift, and I found myself stumped on how to determine the type of a tuple's element from its own type. I know the compiler and Xcode are quick to pro...
Planography asked 24/8 at 23:4
3
Solved
I'm using Typescript inside my svelte project, I need to define strong type for my event. But I can't find any way to do that.
<script lang="ts">
const onKeyUp = (event: [type here...
Lucarne asked 19/11, 2021 at 7:19
6
I am very new to TypeScript. My TypeScript version is 3.7.5.
IMHO, it should be very easy, but I don't know why it does not work.
function add<T> (a:T, b:T):T {
return a + b ;
}
console.log...
Septarium asked 18/1, 2020 at 17:11
2
Solved
I have the following component:
<component value="3"></component>
And the component code is:
private _value:number;
get value(): number {
return this._value;
}
@Input()
set ...
Rebuild asked 3/10, 2016 at 8:24
2
Solved
I recently learnt that constructors do not have names. I am also aware that a function has a type called a function type. For example,
void func(int)
{
}
In the above snippet, func has the functio...
Rime asked 3/4, 2022 at 9:59
4
I want to implement a function that loops over the properties of an object and applies updates to another object of the same type.
interface Car {
tires: number;
name: string;
}
function updateC...
Buxtehude asked 25/8, 2020 at 9:42
3
After upgrading to tensorflow 2.9 I got the following Erro message
when calling model.fit()
with tf 2.8 there were no error.
The fit runs anways but its worrying.
2022-06-21 12:42:58.930086: W tens...
Oleomargarine asked 21/6, 2022 at 12:51
4
Solved
Consider the following program:
#include <tuple>
#include <vector>
#include <iostream>
#include <type_traits>
template <class T>
struct ordered {};
template <cla...
Ahem asked 10/2, 2018 at 18:9
2
Solved
I am using pandas 0.17.0 and have a df similar to this one:
df.head()
Out[339]:
A B C
DATE_TIME
2016-10-08 13:57:00 in 5.61 1
2016-10-08 14:02:00 in 8.05 1
2016-10-08 14:07:00 in 7.92 0
2016-10...
Moncada asked 30/8, 2016 at 4:57
3
Solved
Just out of curiousity (not really expecting a measurable result) which of the following codes are better in case of performance?
private void ReplaceChar(ref string replaceMe) {
if (replaceMe.Co...
Farl asked 20/4, 2016 at 8:22
3
I'm implementing Newton's method for finding roots in a precompiled library. The common case will be to work with functions from Float64 to Float64, and I want an optimized compiled version of it t...
4
Solved
How can I define a recursive Pydantic model?
Here's an example of what I mean:
from typing import List
from pydantic import BaseModel
class Task(BaseModel):
name: str
subtasks: List[Task] = []
...
Malo asked 22/6, 2021 at 22:43
4
Solved
Is it possible to make a function have either mandatory or optional parameters based on conditional types in TypeScript?
This is what I've got so far:
const foo = <T extends string | number>...
Actually asked 13/9, 2018 at 16:28
6
Solved
Can typescript type alias support default arguments? For instance:
export type SomeType = {
typename: string;
strength: number;
radius: number;
some_func: Function;
some_other_stat: number = ...
Kenney asked 18/5, 2020 at 4:0
14
Solved
I have a table with a column 'hotel'. The project is created in Laravel 5.4, so I used Migrations.
$table->string('hotel', 50);
This is MYSQL VARCHAR (50). It was working good, because when I w...
4
Solved
I am learning the characteristics of the different data type. For example, this program increasingly prints the power of 2 with four different formats: integer, unsigned integer, hexadecimal, octal...
11
I have the following example code snippet:
type Color = string;
interface Props {
color: Color;
text: string;
}
function Badge(props: Props) {
return `<div style="color:${props.color}">...
Obstetrician asked 3/3, 2017 at 16:42
10
Solved
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, b: B) {
return Object.assign({}, a, ...
Mississippian asked 5/4, 2018 at 22:37
3
Solved
There is no Date type. If I want an object that is only a date with no time, like a birthdate, what type would I use?
I'm sure this question has been asked and answered already, but I'm not findin...
5
Solved
Say I have a function like this:
function theFunction() {
$arr = array();
for ($i=0;$i<10;$i++) {
$arr[] = new theObject($i);
}
return $arr;
}
I need to document the return type of the f...
Adherence asked 11/6, 2013 at 11:6
4
Solved
I just noticed that an interface cannot be assigned to Record<string, unknown> (playground link):
interface Foo {
foo: number
}
const foo: Foo = { foo: 1 }
const bar: Record<string, unkn...
Transformation asked 19/1, 2021 at 20:48
3
Solved
I am doing a project that where I need to register all the properties, because of the system being so huge it would require a lot of work to register all the properties that i want to be dependent ...
Stpeter asked 22/12, 2010 at 0:33
2
I was confused by the following paragraph about type aliasing from cppreference (source):
Whenever an attempt is made to read or modify the stored value of an object of type DynamicType through a g...
Graiae asked 20/5, 2021 at 13:24
4
Solved
I would like to implement deep pick in typescript.
My example code is:
interface TestBook {
id: string;
name: string;
}
interface TestUser {
id: string;
email: string;
books: TestBook[];
}
I ...
Pshaw asked 10/11, 2022 at 14:5
1 Next >
© 2022 - 2024 — McMap. All rights reserved.