mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
docs: Add ".ts" support in docs and configuration.
Add references to TypeScript in documentation where appropriate, such as in example bash commands and discussions of the file structure. Add a new section to the Reading List with TypeScript resources. Also update `.editorconfig` to support ".ts" files. Fix part of #12000.
This commit is contained in:
committed by
Tim Abbott
parent
ce7d2fde70
commit
ae5496020b
@@ -145,7 +145,7 @@ string, use the `id` function, as it will simplify future code changes.
|
||||
In most contexts in JavaScript where a string is needed, you can pass a
|
||||
number without any explicit conversion.
|
||||
|
||||
### JavaScript var
|
||||
### JavaScript `var`
|
||||
|
||||
Always declare JavaScript variables using `var`. JavaScript has
|
||||
function scope only, not block scope. This means that a `var`
|
||||
@@ -153,7 +153,12 @@ declaration inside a `for` or `if` acts the same as a `var`
|
||||
declaration at the beginning of the surrounding `function`. To avoid
|
||||
confusion, declare all variables at the top of a function.
|
||||
|
||||
### JavaScript `for (i in myArray)`
|
||||
#### TypeScript `const` and `let`
|
||||
|
||||
When writing TypeScript, we prefer to use `const` or `let` where
|
||||
possible.
|
||||
|
||||
### JavaScript and TypeScript `for (i in myArray)`
|
||||
|
||||
Don't use it:
|
||||
[[1]](http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays),
|
||||
@@ -164,7 +169,7 @@ Don't use it:
|
||||
|
||||
Remember to
|
||||
[tag all user-facing strings for translation](../translating/translating.html), whether
|
||||
they are in HTML templates or JavaScript editing the HTML (e.g. error
|
||||
they are in HTML templates or JavaScript/TypeScript editing the HTML (e.g. error
|
||||
messages).
|
||||
|
||||
### State and logs files
|
||||
@@ -212,7 +217,7 @@ we should still avoid extremely long lines. A general guideline is:
|
||||
refactor stuff to get it under 85 characters, unless that makes the
|
||||
code a lot uglier, in which case it's fine to go up to 120 or so.
|
||||
|
||||
### JavaScript
|
||||
### JavaScript and TypeScript
|
||||
|
||||
When calling a function with an anonymous function as an argument, use
|
||||
this style:
|
||||
|
||||
Reference in New Issue
Block a user