GithubHelp home page GithubHelp logo

kornalaravel / laravel-typescript-transformer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spatie/laravel-typescript-transformer

0.0 0.0 0.0 142 KB

Transform PHP types to Typescript

Home Page: https://docs.spatie.be/typescript-transformer/v2/introduction/

License: MIT License

PHP 97.10% TypeScript 2.90%

laravel-typescript-transformer's Introduction

Transform PHP types to TypeScript

Latest Version on Packagist GitHub Tests Action Status Styling Psalm Total Downloads

Always wanted type safety within PHP and TypeScript without duplicating a lot of code? Then you will like this package! Let's say you have an enum:

class Languages extends Enum
{
    const TYPESCRIPT = 'typescript';
    const PHP = 'php';
}

Wouldn't it be cool if you could have an automatically generated TypeScript definition like this:

export type Languages = 'typescript' | 'php';

This package will automatically generate such definitions for you, the only thing you have to do is adding this annotation:

/** @typescript **/
class Languages extends Enum
{
    const TYPESCRIPT = 'typescript';
    const PHP = 'php';
}

You can even take it a bit further and generate TypeScript from classes:

/** @typescript */
class User
{
    public int $id;

    public string $name;

    public ?string $address;
}

This will be transformed to:

export type User = {
    id: number;
    name: string;
    address: string | null;
}

Want to know more? You can find the documentation here.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-typescript-transformer's People

Contributors

rubenvanassche avatar freekmurze avatar adrianmrn avatar ayoobmh avatar badams avatar njoguamos avatar tofandel avatar bram-pkg avatar ekateiva avatar innocenzi avatar erikgaal avatar kenan-recebli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.