Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian De Deyne:
TypeScript With Laravel Mix
May 25, 2017 @ 10:21:16

In a post to his site Sebastian De Deyne shows how to use Laravel Mix to work with Typescript right alongside other packages and libraries included in your mix configuration.

In a recent Spatie project we decided to give TypeScript a shot for the business critical part of a new application. TypeScript provides static analysis to reduce the chance of introducing bugs, to have self-documenting code, and to improve our tooling (autocompletion!)

We've been happily using Laravel Mix since it's release with Laravel 5.4. Luckily, extending Mix isn't too hard with some webpack knowledge. [...] As long as you've configured an appropriate loader, you could import anything from a plain old JavaScript file to an animated gif. This means that if we want to support TypeScript with Laravel Mix, we don't need to change any configuration, we only need to add the ability to bundle TypeScript files.

The remainder of the article is broken down into the four steps (and a bonus) for getting Mix and TypeScript playing together nicely:

  • Install The Necessary Dependencies
  • Configure TypeScript
  • Configure Laravel Mix
  • Write Some TypeScript!

The bonus at the end shows how to use this working setup to go one step further and use TypeScript in the Vue.js components in your Laravel application.

tagged: laravel laravelmix typescript combination tutorial configuration

Link: https://sebastiandedeyne.com/posts/2017/typescript-with-laravel-mix