BETA
typescript
Nickname
Ruolo
Seleziona
Studente
Designer
Sviluppatore
Esploratore
Quale tipo si utilizza per una variabile che può contenere sia un numero che una stringa?
let valore: number | string;
let valore: number || string;
let valore: any;
let valore: string | number[];
Tempo residuo
Domanda
0
di
0
Come si definisce una funzione che restituisce un numero in TypeScript?
function somma(): string { return 10; }
function somma: number() { return 10; }
function somma(): number { return 10; }
function somma() number { return 10; }
Tempo residuo
Domanda
0
di
0
Qual è la sintassi corretta per dichiarare una variabile di tipo string in TypeScript?
let nome = 'string';
let nome: string;
string nome;
nome: string;
Tempo residuo
Domanda
0
di
0
Come si crea un tipo alias in TypeScript?
alias ID = string | number;
let ID: string | number;
type ID = string | number;
typedef ID = string | number;
Tempo residuo
Domanda
0
di
0
Come si specifica il tipo di ritorno di una funzione che non restituisce nulla in TypeScript?
function saluta() {}
function saluta(): undefined {}
function saluta(): null {}
function saluta(): void {}
Tempo residuo
Domanda
0
di
0
Come si fa a specificare che una funzione può restituire più tipi in TypeScript?
function getId(): string || number {}
function getId(): string, number {}
function getId(): string | number {}
function getId(): [string, number] {}
Tempo residuo
Domanda
0
di
0
Come si utilizza il tipo Partial in TypeScript?
let config: Optional<Config>;
let config: PartialConfig;
let config: Config?;
let config: Partial<Config>;
Tempo residuo
Domanda
0
di
0
Come si estende un'interfaccia in TypeScript?
interface Admin implements User {}
interface Admin inherit User {}
interface Admin extends User {}
interface Admin include User {}
Tempo residuo
Domanda
0
di
0
Come si definisce una classe astratta in TypeScript?
abstract class Forma {}
class abstract Forma {}
class Forma abstract {}
abstract Forma class {}
Tempo residuo
Domanda
0
di
0
Come si definisce un tipo per un oggetto con proprietà facoltative?
interface User { nome: string?; }
interface User { nome?: string; }
interface User { ?nome: string; }
interface User { nome: ?string; }
Tempo residuo
Domanda
0
di
0
Una tupla permette di specificare un array con un numero fisso di elementi di tipi specifici.
let persona: [string, number];
let persona: (string, number);
let persona: string | number;
let persona: {string, number};
Tempo residuo
Domanda
0
di
0
Qual è lo scopo del tipo unknown in TypeScript?
Un tipo che può essere assegnato solo a never
Un tipo che rappresenta un valore sconosciuto
Un tipo che può essere assegnato solo a any
Un tipo che rappresenta un valore nullo
Tempo residuo
Domanda
0
di
0
Come si usa ReadonlyArray<T> in TypeScript?
const arr: Array<number> = [1, 2, 3];
const arr: readonly number[] = [1, 2, 3];
const arr: ImmutableArray<number> = [1, 2, 3];
const arr: ReadonlyArray<number> = [1, 2, 3];
Tempo residuo
Domanda
0
di
0
Come si usa il tipo Exclude<T, U> in TypeScript?
type Result = Exclude<'a' & 'b' & 'c', 'a' | 'c'>;
type Result = Exclude<'a' | 'b' | 'c', 'a' | 'c'>;
type Result = Exclude<'a' | 'b' | 'c', 'a' & 'c'>;
type Result = Exclude<'a' | 'b' | 'c', 'b'>;
Tempo residuo
Domanda
0
di
0
Cosa fa il tipo ReturnType<T> in TypeScript?
Restituisce tutti i tipi di una funzione
Verifica se un tipo è una funzione
Combina i tipi di input di una funzione
Restituisce il tipo di ritorno di una funzione
Tempo residuo
Domanda
0
di
0
Come si utilizza il tipo Readonly<T> in TypeScript?
type ReadOnlyUser = Readonly<User>;
type ReadOnlyUser = Const<User>;
type ReadOnlyUser = Static<User>;
type ReadOnlyUser = Final<User>;
Tempo residuo
Domanda
0
di
0
Come si usa l'operatore in nelle definizioni dei tipi in TypeScript?
type Options = { [K in 'option1' | 'option2']: boolean };
type Options = { K in 'option1' | 'option2': boolean };
type Options = { 'option1' & 'option2': boolean };
type Options = { K of 'option1' | 'option2': boolean };
Tempo residuo
Domanda
0
di
0
Come si utilizza il tipo Partial<T> in TypeScript per creare un oggetto con tutte le proprietà opzionali?
type PartialUser = Optional<User>;
type PartialUser = PartialType<User>;
type PartialUser = Partial<User>;
type PartialUser = { [P in keyof User]: User[P] | undefined };
Tempo residuo
Domanda
0
di
0