Skip to content

Instantly share code, notes, and snippets.

@vmaark
vmaark / reactNavigation.ts
Created March 23, 2019 22:07
proposal for custom typings for navigation
interface Routes {
App: {};
Loading: {};
Welcome: {};
Post: {};
Root: {};
FeedListViewerContainer: {
showExplore: boolean,
};
Feed: {
@vmaark
vmaark / inference.md
Last active February 17, 2020 08:01
TypeScript type inference

How and where should we annotate our code with types?

interface ImageProps {
  width: number;
  height: number;
  fileName: string;
}
@vmaark
vmaark / mobx.tsx
Last active April 21, 2020 20:15
minimal MobX example
import { observable } from 'mobx'
import { Observer, useObserver, observer } from 'mobx-react' // 6.x or mobx-react-lite@1.4.0
import ReactDOM from 'react-dom'
const person = observable({
name: 'John',
})
const P3 = ({ person }) => {
return useObserver(() => <h1>{person.name}</h1>)
@vmaark
vmaark / unionIssue.ts
Created August 4, 2020 08:49
TypeScript problem with discriminated union types with object property
export enum MediaType {
PHOTO = "image",
VIDEO = "video",
}
type MediaMessage = PhotoMediaMessage | VideoMediaMessage;
type PhotoMediaMessage = {
type: MediaType.PHOTO,
id: string,