-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support #548
Comments
|
Okay, how we can config compiled files?
But it's not included in webpack.mix.js |
In case anyone else is interested, I am using typescript in my laravel project and here is the configuration I am using: package.json:
webpack.mix.js:
tsconfig.json:
|
Hi @JeffreyWay wanted to know how angular (typescript) can be mixed with laravel to create a Non-SPA so that the custom components could be used along with blade. |
@NoelDeMartin Thanks for the configuration, It works well for me. |
Based on @NoelDeMartin solution, all I required was |
Since the release of laravel-mix v1.0.0 typescript is now officially supported. mix.ts('src/index.ts', 'dist/'); ( A Example: /* webpack.mix.js */
let mix = require('laravel-mix');
mix.ts('src/index.tsx', 'dist/')
.extract([ 'react' ])
.sourceMaps()
.setPublicPath('dist'); /* tsconfig.json */
{
"lib": [
"dom",
"es5",
],
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"jsx": "react"
}
} |
@NoelDeMartin Thanks for saving my life! |
@gilbertoalbino Could you be more specific about what is failing when using Minification is performed automatically when running |
@gilbertoalbino |
@Olian04 and @NoelDeMartin I figured it out! I had some of my packages installed via So, after running accross this situation I am encourage to install node packages via |
@siddhantfriends follow this tutorial: https://laracasts.com/discuss/channels/laravel/laravel-53-with-angular-2-1 |
Does this work with TS within single file Vue components? |
@eberkund Yes it does. |
Sorry to comment on an old Issue. How can I use TypeScript in combination with .js files? Say if in my resources/assets/js/app.js file I wanted to include some modules that were stored in .ts files? |
@martinbean I don't know about importing ts into js (except by importing the compiled js), but the other way around can be solved by setting "allowjs" to true in the tsconfig. |
@martinbean If I understand correctly, you want to import a .ts file into a .js file? It that's so, there is something you didn't quite understand about Typescript. At the end, .ts files will always be compiled into .js files, so if you are already using laravel-mix (which I guess you are since you are commenting here), you can do one of both:
Laravel mix uses webpack and even if you don't want to dig into webpack, I suggest that at least you learn some basic concepts on how dependencies and bundling is handled. When working with webpack, everything is considered a module (images, js, ts, css, etc) and is bundled into one or more files (in this case, app.js). You can start here: https://webpack.js.org/concepts/. In any case, I don't think this is related with this issue or even laravel-mix, so try to do some google search or post this somewhere more appropriate, like stackoverflow. If you do, try to be more specific about your problem because that seems too broad. |
@NoelDeMartin I was wanting to use TypeScript files in the default JavaScript files that come with Laravel (basically nicely-typed, standalone modules). But it sounds like I need to rename my app.js to app.ts and use that as a TypeScript entry point. Thanks for the pointer! |
@martinbean Yes, if you want to use Typescript I recommend you to do everything in TS, and worry about using .js files inside .ts instead. Basically the only thing you need to do is import them and provide typings. Most popular js packages already have ts definitions, and you can find a lot here: https://github.com/DefinitelyTyped/DefinitelyTyped. If you are getting started with typescript it may be a little confusing at the beginning, but it definitely pays off once you get the hang of it. |
Hi @JeffreyWay!
Can you explain how to compile .ts with Laravel Mix?
I try follow this issue #291 (comment) and here documentation https://github.com/TypeStrong/ts-loader#configuration
With this configuration .ts files just combined with all js and not preprocessed. What's wrong?
node -v
): 7.7.1npm -v
): 4.1.2The text was updated successfully, but these errors were encountered: