-
Notifications
You must be signed in to change notification settings - Fork 263
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
Migrate codebase to TypeScript, close #323 #406
Migrate codebase to TypeScript, close #323 #406
Conversation
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.: 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. |
d8f1016
to
b47af3b
Compare
defaults: undefined[] | RouteDefaults; | ||
requirements: undefined[] | RouteRequirements; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of JSON serialization from PHP, an empty array is serialized to []
but a non-empty array is serialized to { 'default1': '...', 'default2: '...' }
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);
} Friendly ping @tobias-93 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, some small comments but otherwise nice job!
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) |
@tobias-93 The text has been removed and a more generic route ( @stof Sorry, maybe I was not clear enough. I was speaking about the TypeScript definition, |
Hi everyone, is there any news on this? Thanks! |
Hi @Kocal, Sorry, this bundle has been under my radar for a long time. |
23681af
to
b9f5de6
Compare
Hi @tobias-93, no worries! The PR has been rebased. I will do the same for #408. Thanks |
@Kocal awesome, thanks! I will make a 3.0 release with this new implementation, including support for SF 6 and dropping old PHP versions. |
Perfect! :) |
Hi 👋
This PR is a proposal for migrating the codebase to TypeScript. This way:
Some things to know:
@babel/typescript-preset
js/router.js
file has been migrated to TypeScript. But I didn't rewrite the whole file, just adapting it to make TypeScript and tests happyFOS
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 aimport { Routing } from 'vendor/friendsofsymfony/jsrouting-bundle'
I guessWDYT? Thanks!