Skip to content

Instantly share code, notes, and snippets.

View eyeccc's full-sized avatar
🌵
_(: 」∠)_

Chih-Ching Chang eyeccc

🌵
_(: 」∠)_
View GitHub Profile
const logEmail = (email: Email) => console.log(email);
logEmail("123");
/*
^^^^^^^^^^^^^^^
Argument of type '"123"' is not assignable to parameter of type 'string & { readonly Email: unique symbol; }'.
Type '"123"' is not assignable to type '{ readonly Email: unique symbol; }'.
*/
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
Email: string & { readonly Email: unique symbol };
};
export type Node = {
overwrite: true
schema: 'localhost:8000/graphql'
documents: '**/*.graphql'
generates:
genaratedSchema.tsx:
plugins:
- add: '// THIS IS A GENERATED FILE'
- typescript
- typescript-operations
config:
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
Email: any;
};
export type Node = {
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
export type Node = {
id: Scalars["ID"];
image: my-public-image # any image you want
pipelines:
pull-requests:
'**':
- step:
name: Unit Test and Build
caches:
- node
script:
@eyeccc
eyeccc / FormDataExample2.re
Created April 26, 2019 08:33
FormDataExample2.re
[@bs.new] external makeFormData: unit => Fetch.formData = "FormData";
[@bs.send]
external appendFormData: (Fetch.formData, string, string) => unit = "append";
let formData = makeFormData();
appendFormData(formData, "field1", "value1");
appendFormData(formData, "field2", "value2");
appendFormData(formData, "field3", "value3");
type username = string;
type state = {userName: option(username)};
type action =
| SetUserName(option(username));
/* Webapi: https://github.com/reasonml-community/bs-webapi-incubator */
let redirectToLogin = () => {
let currentUrl = Webapi.Dom.location |> Webapi.Dom.Location.href |> Js.Global.encodeURIComponent;
/* Keycloak V2 */
type keycloak;
type init;
type initParam;
[@bs.module] external keycloak : string => keycloak = "keycloak-js";
[@bs.obj] external makeInitParam : (~onLoad: string, unit) => initParam = "";
[@bs.send] external init : (keycloak, initParam) => Js.Promise.t(bool) = "";
let myConfig = "./keycloakConfig.json";
type state = {
isAuthed: bool
};
type action = | SetAuthenticated(bool);
let component = ReasonReact.reducerComponent("KeycloakApp");
let make = (_children) => {
...component,