What are identifiers and keywords in TypeScript?
Identifiers
Identifiers are names given to functions, variables, classes, etc., that we can use to refer to them.
In TypeScript, we do not just name variables using any name. Rather, we follow some rules that guide naming in Typescript, which is similar to JavaScript.
The rules for identifiers
- Identifiers should not include special symbols except
_or$sign, e.g.,full_name. - Identifiers are case sensitive.
- Identifiers can include digits, but most do not begin with a digit.
- Identifiers must not be the reserved keywords used in TypeScript like
anyorfor. - Identifiers must be unique in naming.
Keywords
Keywords are a predefined set of reserved words that have special meaning in a program.
Examples of keywords in Typescript include the following:
break,as,any,switchcase,if,throw,else,var,number,string,get,module,type,instanceof,typeof,public,private,enum,export,finally,for,while,void,null,super,this,new,in,return,true,false,any,extends,static,let,package,implements,interface,function,new,try,yield,const,continue,do,catch
Many others are words reserved in TypeScript.
Typescript ignores indentation and whitespace. However, you can add them to make your code look more readable.