https://github.com/zardoy/typescript-simpler
The same TypeScript but with some additional syntax
https://github.com/zardoy/typescript-simpler
Last synced: 4 months ago
JSON representation
The same TypeScript but with some additional syntax
- Host: GitHub
- URL: https://github.com/zardoy/typescript-simpler
- Owner: zardoy
- License: mit
- Created: 2021-07-01T20:28:08.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-01T21:38:08.000Z (almost 5 years ago)
- Last Synced: 2025-02-13T03:41:24.590Z (over 1 year ago)
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeScript Simpler
> Status: planned
It is like ReScript library, but it designed to work with more popular TypeScript language.
Please, open an issue if you know an alternative to it.
## New syntax
### [n * type]
```diff
-type Vector = [number, number, number];
+type Vector = [3 * number];
```
`updateSetting(...path.split(".") as [3 * string], value)` instead of `updateSetting(...path.split(".") as [string, string, string], value)` and so on
### Object type annotation
```diff
-type Users = { [name: string]: Info };
+type Users = { [name]: Info };
```
Bad (but useful sometimes tho): `Record`
Better: `{ [userId: string]: UserInfo }`
Ideal: `{ [userId]: UserInfo }`
## Type Helpers
Add types in some places for more strict checks.
### Default Type for Catch variables
🔧 defaultTypeInCatchVariables (default: `Error`)
Remember when TypeScript team has [changed the type of](https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-beta/#use-unknown-catch-variables) of variables in catch blocks from `any` to `unknown`? This project, will set type of these variables to `Error`. Just for your convenience, there is no guarantee that 3d party code always would use Error-like classes.
- TODO:
- [ ] Link ESLint rule that disallows throwing non Error classes like `throw "Hey there!"`