“Template Tipe Literal” Kode Jawaban

Template Sintaks literal

`half of 100 is ${100 / 2}`
Crazy Cobra

Template Tipe Literal

/** A template literal produces a new string literal type by concatenating
    the contents. When a union is used in the interpolated position, the 
    type is the set of every possible string literal that could be 
    represented by each union member: */

type Taste = "Delicious" | "Spicy";
type Food = "Pizza" | "Meat";
 
type Menu = `${Taste | Food}`;

// Menu will now be one of the following:
// 'DeliciousPizza' | 'DeliciousMeat' | 'SpicyPizza' | 'SpicyMeat'
Stupid Scarab

Jawaban yang mirip dengan “Template Tipe Literal”

Pertanyaan yang mirip dengan “Template Tipe Literal”

Lebih banyak jawaban terkait untuk “Template Tipe Literal” di TypeScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya