aem-sling-2-ts

0.0.12 • Public • Published

AEM Sling to Typescript Converter

A CLI tool which scans a projects for Apache Sling models and generates equivalent Typescript definitions.

This is a useful tool for any AEM + React Typescript projects, promoting type-safety between the BE and FE.

Installation

Install package as dev depedency

npm install --save-dev aem-sling-2-ts

Add script to package.json

{
    "scripts": {
        "generate:sling-ts": "aem-sling-2-ts ../core ./src/types/sling-interfaces.d.ts"
    }
}

Usage

The generate the Typescript definition file containing the sling model interfaces, run:

npm run generate:sling-ts

Importing Definitions

After generating the .d.ts definition file, the interfaces can be referenced globally:

const MyComponent = (props: Sling.ExampleModelProps) => (
    <div>{props.example}</div>
)

Future scope

  1. Make code namespace aware!
  2. Scaffold react components from Sling models
  3. Improved type mappings

Readme

Keywords

none

Package Sidebar

Install

npm i aem-sling-2-ts

Weekly Downloads

35

Version

0.0.12

License

none

Unpacked Size

33 kB

Total Files

12

Last publish

Collaborators

  • cheproximity