π Agora node [[typescript]] β
π File typescript.md by @flancian β π οΈπ βοΈ βΆ
TypescriptΒ§
-
A [[language]]
- A language I don’t know it very well built to replace or complement another language I know little/badly/in an old school way (JS).
- But I think I need to learn client side coding, so there you go; TS it is.
- I started a 20% contribution at the day job in [[typescript]] and I learnt a bit; I liked what I learnt. It’s a better javascript with what I would call solid type inference (unsure if that’s the right technical term though, need to review.)
- [[clojurescript]] could be an alternative. It is [[cojure]] for the browser. I started learning [[clojure]]. I start doing many things :)
- [[agora ext]] uses [[typescript]].
- [[agora bridge api]] uses [[typescript]].
- [[agora server]] uses [[typescript]] for it’s client side code.
π File TypeScript.md by @bunnynabbit β π οΈπ π€ βΆ
Why not TypeScript?Β§
This is what I initially thought.
- Higher barrier to entry.
To a newcomer who might not know what strong typing is, TypeScript could feel confusing. As is the added amount of unfamiliar syntax or typing conventions. - Adds a build step.
Before backend runtimes were able to use type stripping, TypeScript was usually executed after a compilation step. Though, for the frontend, a build step is always necessary.
I think convenience is to tell users to just run npm install. Thatβs just one common command when working with the [[JavaScript]] ecosystem.
Why TypeScript?Β§
TypeScript is pretty necessary for maintenance and reducing guess work.
- Provides documentation.
- Reliable editor hints.
- Enforces restraint.
As JavaScript is dynamically typed. Putting some guardrails is only a natural step to better maintenance.
How I use itΒ§
I figured that to get the least number of problems when introducing TypeScript to a project, I continued to use JavaScript with added JSDoc comments. I only use TypeScript files for defining complex types. This maintains having no build step.
An issue with this may be verbosity. Since the JSDoc tags are to be in multiple lines, comments can be massive. Solutions to this are in editors:
- JSDoc Folder. An extension for [[Visual Studio Code]] to automatically collapse documentation comments.
- [[Explicit folding]].
An example of a JavaScript-only project using TypeScript is celaria-formats.
-
tsconfig.json.- Only checks JavaScript if explicitly marked for type checking using
// @ts-check. - Emits type declarations but is not used for compiling.
- Only checks JavaScript if explicitly marked for type checking using
- Documentation generated from TypeDoc.
- Release workflow emits type declarations for better support with TypeScript-based projects.
- Complex types defined in TypeScript files. JavaScript imports these using the @import tag. TypeScript is never executed.
π File typescript.md by @goldfishlaser β π οΈπ βΆ
typescriptΒ§
Core ideaΒ§
TypeScript is a strict, statically typed "superset" built on top of [[JavaScript]] by Microsoft to catch errors early during development.
LinksΒ§
https://www.typescriptlang.org/docs/
[[yaml datastore]]
π File typescript.md by @s5bug β π βΆ
TypeScriptΒ§
- A [[programming language]].
- Aims to add [[static typing]] to [[JavaScript]].
π File typescript.md by @an_agora@twitter.com β π βΆ
β¨ AI Synthesis Mistral Gemini ChatGPT Claude
Expanding this section will automatically generate an AI synthesis of the contributions in this node.