템플릿 리터럴 타입
템플릿 리터럴 타입
type Literal = 'literal';
type Template = `template ${Literal}`; //"template literal"
// Template 타입을 사용하면 정해진 문자열만 변수에 대입할 수 있음
const str: Template = 'template literal';type Template = `template ${string}`;
let str: Template = 'template ';
str = 'template hello';
str = 'teamplte 123';
str = 'template'; // error -> template 문자열 뒤에 띄어쓰기가 없기 때문infer 와 함께 사용하면 더 강력하다
Last updated