Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, TypeScript is compile time only. There's no runtime type info.


The parent comment is saying that if you write the string twice, you can get the compiler to check #1 and the runtime to use #2.


Not exactly (there is no duplication), a string constant in typescript is it's own type:

  const sql = 'SELECT ...';
  type SQL = typeof sql; 
  // type SQL = "SELECT ..."




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: