From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

TypeScript type checking and .d.ts files

TypeScript type checking and .d.ts files

From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Start my 1-month free trial

TypeScript type checking and .d.ts files

- [Instructor] One way TypeScript helps me is that in the TypeScript side of the code I can give data types to any of these variables. Now there is another concept called TSLint. It goes through your TypeScript code and makes sure that you follow certain rules. Most major Yeoman templates will use TSLint. SharePoint Framework certainly does that. So one of the things they enforce is that you must specify a datatype. For instance, now that I specify a datatype on add, and now if I tried to add two numbers, it informs me that this must be a number. So if accidentally I pass in a string, it'll tell me that this is problem. Notice that the JavaScript code on the right hand side, well, it doesn't catch the error, because, technically, this is valid JavaScript. But what line two will end up doing here is that it will concatenate these two variables. This also works across files. It even works between variables. So if I say var something equals like that, and try and pass in something as the…

Contents