Typescript: List of reserved keywords

Created on 28 Mar 2015  ·  5Comments  ·  Source: microsoft/TypeScript

Is there a list of reserved keywords for Typescript somewhere? I have looked around and couldn't find it, even in the language specification.

Question

Most helpful comment

While you could refer to the ES6 spec to figure out a partial list, it might be better to go directly to the code for the current list. Perhaps it would be better to keep a complete list as part of the TS spec (@ahejlsberg)

Based on the code, I ripped this out for you:

| Reserved Words | Strict Mode Reserved Words | Contextual Keywords |
| --- | --- | --- |
| break | as | any |
| case | implements | boolean |
| catch | interface | constructor |
| class | let | declare |
| const | package | get |
| continue | private | module |
| debugger | protected | require |
| default | public | number |
| delete | static | set |
| do | yield | string |
| else | symbol | |
| enum | type | |
| export | from | |
| extends | of | |
| false | | |
| finally | | |
| for | | |
| function | | |
| if | | |
| import | | |
| in | | |
| instanceof | | |
| new | | |
| null | | |
| return | | |
| super | | |
| switch | | |
| this | | |
| throw | | |
| true | | |
| try | | |
| typeof | | |
| var | | |
| void | | |
| while | | |
| with | | |

And if you want to just copy more easily:

| Reserved Words |
| --- |
| break |
| case |
| catch |
| class |
| const |
| continue |
| debugger |
| default |
| delete |
| do |
| else |
| enum |
| export |
| extends |
| false |
| finally |
| for |
| function |
| if |
| import |
| in |
| instanceof |
| new |
| null |
| return |
| super |
| switch |
| this |
| throw |
| true |
| try |
| typeof |
| var |
| void |
| while |
| with |

| Strict Mode Reserved Words |
| --- |
| as |
| implements |
| interface |
| let |
| package |
| private |
| protected |
| public |
| static |
| yield |

| Contextual Keywords |
| --- |
| any |
| boolean |
| constructor |
| declare |
| get |
| module |
| require |
| number |
| set |
| string |
| symbol |
| type |
| from |
| of |

All 5 comments

While you could refer to the ES6 spec to figure out a partial list, it might be better to go directly to the code for the current list. Perhaps it would be better to keep a complete list as part of the TS spec (@ahejlsberg)

Based on the code, I ripped this out for you:

| Reserved Words | Strict Mode Reserved Words | Contextual Keywords |
| --- | --- | --- |
| break | as | any |
| case | implements | boolean |
| catch | interface | constructor |
| class | let | declare |
| const | package | get |
| continue | private | module |
| debugger | protected | require |
| default | public | number |
| delete | static | set |
| do | yield | string |
| else | symbol | |
| enum | type | |
| export | from | |
| extends | of | |
| false | | |
| finally | | |
| for | | |
| function | | |
| if | | |
| import | | |
| in | | |
| instanceof | | |
| new | | |
| null | | |
| return | | |
| super | | |
| switch | | |
| this | | |
| throw | | |
| true | | |
| try | | |
| typeof | | |
| var | | |
| void | | |
| while | | |
| with | | |

And if you want to just copy more easily:

| Reserved Words |
| --- |
| break |
| case |
| catch |
| class |
| const |
| continue |
| debugger |
| default |
| delete |
| do |
| else |
| enum |
| export |
| extends |
| false |
| finally |
| for |
| function |
| if |
| import |
| in |
| instanceof |
| new |
| null |
| return |
| super |
| switch |
| this |
| throw |
| true |
| try |
| typeof |
| var |
| void |
| while |
| with |

| Strict Mode Reserved Words |
| --- |
| as |
| implements |
| interface |
| let |
| package |
| private |
| protected |
| public |
| static |
| yield |

| Contextual Keywords |
| --- |
| any |
| boolean |
| constructor |
| declare |
| get |
| module |
| require |
| number |
| set |
| string |
| symbol |
| type |
| from |
| of |

Also namespace, maybe async and await eventually.

@DanielRosenwasser looks like this should have a wiki page

I tried a few of reserve words mentioned here on the Typescript Playground and didn't encounter any issues. IMO, the keywords should match at least those for ES6. For the later I have a list here https://github.com/crissdev/is-keyword-js/blob/master/index.js which is a list created from MDN site.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Roam-Cooper picture Roam-Cooper  ·  3Comments

siddjain picture siddjain  ·  3Comments

remojansen picture remojansen  ·  3Comments

MartynasZilinskas picture MartynasZilinskas  ·  3Comments

uber5001 picture uber5001  ·  3Comments