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
From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What is TypeScript?2m 17s
-
(Locked)
Set up a simple TypeScript project7m 31s
-
(Locked)
TypeScript transpilation and sourcemaps4m 16s
-
(Locked)
TypeScript type checking and .d.ts files3m 20s
-
(Locked)
TypeScript modules and renaming across modules2m 40s
-
(Locked)
TypeScript classes ES3 vs. ES20154m 2s
-
(Locked)
-
-
-