OLD | NEW |
1 # Closure Compilation | 1 # Closure Compilation |
2 | 2 |
3 ## What is type safety? | 3 ## What is type safety? |
4 | 4 |
5 [Strongly-typed languages](https://en.wikipedia.org/wiki/Strong_and_weak_typing) | 5 [Strongly-typed languages](https://en.wikipedia.org/wiki/Strong_and_weak_typing) |
6 like C++ and Java have the notion of variable types. | 6 like C++ and Java have the notion of variable types. |
7 | 7 |
8 This is typically baked into how you declare variables: | 8 This is typically baked into how you declare variables: |
9 | 9 |
10 ```c++ | 10 ```c++ |
(...skipping 26 matching lines...) Expand all Loading... |
37 tool for analyzing JavaScript and checking for syntax errors, variable | 37 tool for analyzing JavaScript and checking for syntax errors, variable |
38 references, and other common JavaScript pitfalls. | 38 references, and other common JavaScript pitfalls. |
39 | 39 |
40 To get the fullest type safety possible, it's often required to annotate your | 40 To get the fullest type safety possible, it's often required to annotate your |
41 JavaScript explicitly with [Closure-flavored @jsdoc | 41 JavaScript explicitly with [Closure-flavored @jsdoc |
42 tags](https://developers.google.com/closure/compiler/docs/js-for-compiler) | 42 tags](https://developers.google.com/closure/compiler/docs/js-for-compiler) |
43 | 43 |
44 ```js | 44 ```js |
45 /** | 45 /** |
46 * @param {string} version A software version number (i.e. "50.0.2661.94"). | 46 * @param {string} version A software version number (i.e. "50.0.2661.94"). |
47 * @return {!Array<number>} Numbers corresponing to |version| (i.e. [50, 0, 2661
, 94]). | 47 * @return {!Array<number>} Numbers corresponding to |version| (i.e. [50, 0, 266
1, 94]). |
48 */ | 48 */ |
49 function versionSplit(version) { | 49 function versionSplit(version) { |
50 return version.split('.').map(Number); | 50 return version.split('.').map(Number); |
51 } | 51 } |
52 ``` | 52 ``` |
53 | 53 |
54 See also: | 54 See also: |
55 [the design doc](https://docs.google.com/a/chromium.org/document/d/1Ee9ggmp6U-lM
-w9WmxN5cSLkK9B5YAq14939Woo-JY0/edit). | 55 [the design doc](https://docs.google.com/a/chromium.org/document/d/1Ee9ggmp6U-lM
-w9WmxN5cSLkK9B5YAq14939Woo-JY0/edit). |
56 | 56 |
57 ## Typechecking Your Javascript | 57 ## Typechecking Your Javascript |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ++ '../my_project/compiled_resources2.gyp:*', | 189 ++ '../my_project/compiled_resources2.gyp:*', |
190 ], | 190 ], |
191 } | 191 } |
192 ] | 192 ] |
193 } | 193 } |
194 ``` | 194 ``` |
195 | 195 |
196 This file is used by the | 196 This file is used by the |
197 [Closure compiler bot](http://build.chromium.org/p/chromium.fyi/builders/Closure
%20Compilation%20Linux) | 197 [Closure compiler bot](http://build.chromium.org/p/chromium.fyi/builders/Closure
%20Compilation%20Linux) |
198 to automatically compile your code on every commit. | 198 to automatically compile your code on every commit. |
OLD | NEW |