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
18
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
18
Come si definisce un parametro con valore predefinito in una funzione TypeScript?
function saluta(nome: string = 'Guest') {}
function saluta(nome: ?string = 'Guest') {}
function saluta(nome: string ?= 'Guest') {}
function saluta(nome = 'Guest': string) {}
Tempo residuo
Domanda
0
di
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18
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
18