BETA
typescript
Nickname
Ruolo
Seleziona
Studente
Designer
Sviluppatore
Esploratore
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 crea un'interfaccia per un oggetto con proprietà nome (string) e età (number)?
interface Persona { nome: string, età: number }
interface Persona { nome: 'string'; età: 'number'; }
interface Persona { nome = string; età = number; }
interface Persona { nome: string; età: number; }
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 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 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 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 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 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 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 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
Qual è il risultato dell'assegnazione 'let x: never = 5;' in TypeScript?
x sarà undefined
Errore di compilazione
x sarà null
x sarà 5
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
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 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
Qual è l'output dell'uso di typeof su una funzione in TypeScript?
Il nome della funzione
Il valore di ritorno della funzione
Il tipo della funzione
Il tipo dei parametri della funzione
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 usa il tipo Mapped in TypeScript?
type ReadonlyUser = { [K in keyof User]: User[K] };
type ReadonlyUser = { key in User };
type ReadonlyUser = { keyof User };
type ReadonlyUser = { K of User };
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