BETA
typescript
Nickname
Ruolo
Seleziona
Studente
Designer
Sviluppatore
Esploratore
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 definisce un array di numeri in TypeScript?
let numeri: number[];
let numeri: [number];
let numeri: array<number>;
let numeri: numbers[];
Tempo residuo
Domanda
0
di
0
Come si dichiara una variabile di tipo array di stringhe in TypeScript?
let arr: string[];
let arr: [string];
let arr: array<string>;
let arr: strings[];
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
Come si specifica un parametro opzionale in una funzione TypeScript?
function saluta(?nome: string) {}
function saluta(nome?: string) {}
function saluta(nome: string?) {}
function saluta(opzionale nome: string) {}
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 specifica una funzione come parametro di un'altra funzione in TypeScript?
function esegui(callback: function) {}
function esegui(callback: () -> void) {}
function esegui(callback: () => void) {}
function esegui(callback: void()) {}
Tempo residuo
Domanda
0
di
0
Come si usa l'operatore as per il type assertion in TypeScript?
let valore = (input as string);
let valore = (input: string);
let valore = <string>input;
let valore = string(input);
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
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
Come si utilizza il tipo Record in TypeScript per creare un oggetto con chiavi di tipo string e valori di tipo number?
type MyObject = { [key: string]: number };
type MyObject = Record<string, number>;
type MyObject = { string: number };
type MyObject = Record<number, string>;
Tempo residuo
Domanda
0
di
0
Come si crea un tipo unione in TypeScript?
let id: string || number;
let id: string, number;
let id: string | number;
let id: [string, number];
Tempo residuo
Domanda
0
di
0
Qual è lo scopo dell'operatore keyof in TypeScript?
Verifica se una chiave esiste in un oggetto
Combina più tipi in uno
Restituisce le chiavi di un tipo
Converte un tipo in una stringa
Tempo residuo
Domanda
0
di
0
Come si usa il tipo NonNullable<T> in TypeScript?
type Safe = Nullable<string>;
type Safe = string & null;
type Safe = string | undefined;
type Safe = NonNullable<string | null>;
Tempo residuo
Domanda
0
di
0
Qual è lo scopo del tipo infer in TypeScript?
Rimuove i tipi null e undefined
Inferisce il tipo all'interno di una condizione
Combina più tipi in uno
Converte un tipo in un altro
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
Qual è l'uso del tipo Extract<T, U> in TypeScript?
type Result = Extract<'a' & 'b' & 'c', 'a' | 'c'>;
type Result = Extract<'a' | 'b' | 'c', 'a' | 'c'>;
type Result = Extract<'a' | 'b' | 'c', 'b'>;
type Result = Extract<'a' | 'b' | 'c', 'a' & 'c'>;
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