package ppx_ts
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
On This Page
  
  
  A PPX helps binding to typescript modules
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
  
    
      v0.1.6-opam.tar.gz
    
    
        
    
  
  
  
    
  
  
    
  
        md5=6a0615247c0bf1b28b856a7b6fddaa5c
    
    
  sha512=dc09a6f9cb74ca15ed35d8b16afcbc9f5b61e8d50bed49ccedd81bebca4161320c20d3664a4151fade55d77ac45c7225e37d3c56453d4cb38b862fd3b69ccf1b
    
    
  Description
Published: 08 Mar 2022
README
PPX_ts
ppx_ts is a ReScript preprocessor, which helps generating helper types to bind to typescript modules.
Install
yarn add -D @greenlabs/ppx_ts// bsconfig.json
"ppx-flags": [
  ...,
  "@greenlabs/ppx_ts/ppx"
],Features
Attributes @
keyOf
@ppx_ts.keyOf
type t = {
  name: string,
  age: int
}
// automatically generated
type t_keyOf = Name | Age
// automatically generated
let t_keyToString = key =>
  switch key {
  | Name => "name"
  | Age => "age"
  }setType(t)
module Error = {
  type t
}
@ppx_ts.setType(Error.t)
type t = {
  name: string,
  age: int
}
// automatically generated
type t_setType = {
  name: Error.t
  age: Error.t
}toGeneric
@ppx_ts.toGeneric
type t = {
  name: string,
  age: int
}
// automatically generated
type t_toGeneric<'a> = {
  name: 'a
  age: 'a
}partial
@ppx_ts.partial
type t = {
  name: string,
  age: int
}
// automatically generated
type t_partial = {
  name: option<string>,
  age: option<int>
}pick
@ppx_ts.pick(["name"])
type t = {
  name: string,
  age: int
}
// automatically generated
type t_pick_name = {
  name: string,
}omit
@ppx_ts.omit(["name"])
type t = {
  name: string,
  age: int
}
// automatically generated
type t_omit_name = {
  age: int,
}Extension %
keyOf
module Error = {
  type t = {
    name: string,
    age: int
  }
}
@spice // attributes are available
type t1 = %ppx_ts.keyOf(Error.t) // type t1 = Name | Age
// automatically generated
let t1_keyToString = key =>
  switch key {
  | Name => "name"
  | Age => "age"
  }setType
type t = {
  name: string,
  age: int
}
@spice // attributes are available
type t1 = %ppx_ts.setType((t, string))
// changed
type t1 = {
  name: string
  age: string
}setTypeExceptBool
type t = {
  name: string,
  age: int,
  isKorean: bool
}
@spice // attributes are available
type t1 = %ppx_ts.setTypeExceptBool((t, string))
// changed
type t1 = {
  name: string,
  age: string,
  isKorean: bool
}toGeneric
type t = {
  name: string,
  age: int
}
@spice // attributes are available
type t1 = %ppx_ts.toGeneric(t)
// generated
type t1<'a> = {
  name: 'a
  age: 'a
}partial
type t = {
  name: string,
  age: int,
  isKorean: bool
}
@spice // attributes are available
type t1 = %ppx_ts.partial(t)
// generated
type t1 = {
  name: option<string>,
  age: option<int>,
  isKorean: option<bool>
}Contribution
- Create a sandbox with opam
 
opam switch create ppx_ts 4.12.1- Install dependencies
 
opam install . --deps-only --with-test- Build
 
opam exec -- dune build- Test
 
cd rescript
(install dependencies)
yarn
(build --watch)
yarn res:clean && yarn res:watch
(run test --watch)
yarn test:watch
          Dependencies (6)
- ppx_deriving
 - ppx_expect
 - ppx_inline_test
 - 
  
    ppxlib
  
  
    
>= "0.22.0" - 
  
    dune
  
  
    
>= "3.0" - 
  
    ocaml
  
  
    
>= "4.12.1" 
Dev Dependencies (1)
- 
  
    odoc
  
  
    
with-doc 
Used by
None
Conflicts
None
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
  On This Page