FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

Migrate codebase to TypeScript, close #323 #406

Closed Kocal closed 2 years ago

Kocal commented 3 years ago

Hi :wave:

This PR is a proposal for migrating the codebase to TypeScript. This way:

Some things to know:

WDYT? Thanks!

Kocal commented 3 years ago

Hum, the CI fails and I think it's because the Node.js version is outdated. I was able to reproduce the issue on local with Node 8, but everything works fine with Node 10.: image

Given Node.js 8 is unmaintened since a long time ago (https://nodejs.org/en/about/releases/), I think it won't be a problem to setup Node.js 10 on Travis.

Kocal commented 3 years ago

I've fixed some bugs I faced when trying to use my pull request on an existing project, and confirm the following code works (no types errors, and routes are generated correctly):

import Routing, { RouteParams } from '../../../vendor/friendsofsymfony/jsrouting-bundle/Resources';
import routes from '../../_generated/routes.json';

Routing.setRoutingData(routes);

export function generateRoute(name: string, params: RouteParams = {}, absolute = false): string {
  return Routing.generate(name, params, absolute);
}

image

Friendly ping @tobias-93

stof commented 3 years ago
* The TypeScript module `FOS` does not exist anymore. TBH I was not able to re-introduce this behaviour and didn't spend too much time on this, since the majority of users will just do a `import { Routing } from 'vendor/friendsofsymfony/jsrouting-bundle'` I guess

This makes it a BC break for people loading the router and the routes separately rather than using a webpack (see the first code snippet in the doc at https://symfony.com/doc/current/bundles/FOSJsRoutingBundle/usage.html)

Kocal commented 3 years ago

@tobias-93 The text has been removed and a more generic route (feed_post => eg: /feed/post.xml which deals with defaults and requirements) has been added.

@stof Sorry, maybe I was not clear enough. I was speaking about the TypeScript definition, FOS module does not exist anymore since. But fos.Router.setData is still a globally-accessible function: image image

Kocal commented 3 years ago

Hi everyone, is there any news on this? Thanks!

tobias-93 commented 2 years ago

Hi @Kocal,

Sorry, this bundle has been under my radar for a long time. Please rebase on the newest master and rework the tests for Github Actions, and I will have a new look on merging this.

Kocal commented 2 years ago

Hi @tobias-93, no worries! The PR has been rebased.

I will do the same for #408.

Thanks

tobias-93 commented 2 years ago

@Kocal awesome, thanks! I will make a 3.0 release with this new implementation, including support for SF 6 and dropping old PHP versions.

Kocal commented 2 years ago

Perfect! :)