https://github.com/unclechu/typescript-redux-and-data-request-flow-proper-typing-experiment
https://github.com/unclechu/typescript-redux-and-data-request-flow-proper-typing-experiment
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/unclechu/typescript-redux-and-data-request-flow-proper-typing-experiment
- Owner: unclechu
- Created: 2020-03-12T01:58:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T02:58:51.000Z (over 6 years ago)
- Last Synced: 2024-12-27T22:21:20.029Z (over 1 year ago)
- Language: TypeScript
- Size: 15.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Proof of Concept
It's a prototype of TypeScript & Redux project
that brings 2 main things to the table:
1. [x] Proper discriminated typing for different state of
data requesting (like ADT type in Haskell, no need to
provide any dummy value plugs for all the fields of data
model as well as you don't need to make all of the fields
being nullable/optional which wouldn't be a correct data
model)
2. [ ] Validating data by Swagger model in runtime when
receiving that data from a server which solves the issue
when types are correct but JavaScript don't parse but
just eats whatever JSON a server gives to it, and while
your whole project is being well-typed you get that awful
"undefined bla-bla something" exception with no clue of
what went wrong
## Requirements
1. [nix](https://nixos.org/nix/) package manager
## Run
```sh
(cd nominatim-api && ./generate-swagger-schema.hs > schema.json)
nix-shell -p nodejs-12_x --run 'npm i && npm run build-from-schema && npm start'
```
### Run shell with work environment
With `tsc`, `tslint`, etc.
```sh
nix-shell -p nodejs-12_x --run 'npm i && PATH="${PWD}/node_modules/.bin:${PATH}" bash'
```
# Author
Viacheslav Lotsmanov