top | item 24616249

(no title)

james-mcelwain | 5 years ago

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

discuss

order

whatshisface|5 years ago

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.

ricksharp|5 years ago

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 ..."