-
Notifications
You must be signed in to change notification settings - Fork 152
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
export types in generated file #329
Conversation
What is a purpose of the change? |
@bogdan apologies i had not intended to contribute this change back to mainline. I made this change so that I could import the generated types & methods into my client-side js. How do others use the generated code? I fear I may have missed something important or perhaps an editor config (vscode). |
Normally people just use the exported methods. Types are not exported because most of them are not a part of public API. Believe only a few do, but people never asked to use them. Give me an example of what kind of code you use on frontend if you want a concrete advice. |
Here is an example of what I use on the front end, pretty simple. Where are the methods exported? Maybe i am importing them incorrectly import { market_quote_api_path, show_symbol_path } from '../routes'; |
What is the content of you |
here are the generated snippets
/**
* File generated by js-routes 2.3.0 on 2024-12-19 07:38:57 -0500
* Based on Rails 7.1.3.4 routes of ::Application
*/
/**
* Generates rails route to
* /market/ticker/:symbol(.:format)
* @param {any} symbol
* @param {object | undefined} options
* @returns {string} route path
*/
show_symbol_path: __jsr.r({"symbol":{"r":true},"format":{}}, [2,[7,"/"],[2,[6,"market"],[2,[7,"/"],[2,[6,"ticker"],[2,[7,"/"],[2,[3,"symbol"],[1,[2,[8,"."],[3,"format"]]]]]]]]]),
/**
* Generates rails route to
* /api/v1/market/quotes(.:format)
* @param {object | undefined} options
* @returns {string} route path
*/
market_quote_api_path: __jsr.r({"format":{}}, [2,[7,"/"],[2,[6,"api"],[2,[7,"/"],[2,[6,"v1"],[2,[7,"/"],[2,[6,"market"],[2,[7,"/"],[2,[6,"quotes"],[1,[2,[8,"."],[3,"format"]]]]]]]]]]]),
/**
* Generates rails route to
* /market/ticker/:symbol(.:format)
* @param {any} symbol
* @param {object | undefined} options
* @returns {string} route path
*/
declare const show_symbol_path: ((
symbol: RequiredRouteParameter,
options?: {format?: OptionalRouteParameter} & RouteOptions
) => string) & RouteHelperExtras;
/**
* Generates rails route to
* /api/v1/market/quotes(.:format)
* @param {object | undefined} options
* @returns {string} route path
*/
declare const market_quote_api_path: ((
options?: {format?: OptionalRouteParameter} & RouteOptions
) => string) & RouteHelperExtras; |
This is the code with your patch right? Well, I can't debug that. Please use original source code. |
@bogdan i ran my code against the latest version (2.3.2) and my front-end code works fine now with no changes. not sure why this was needed before but now it is not. thanks for helping! greatly appreciate it I think I am using CJS module system |
works locally but getting some issues building, this may be what triggered my change
|
It looks like the problem is that routes.d.ts is trying to be compiled, but it should be completely ignored by esbuild. This file is only useful in development. |
here is generated code from latest 2.3.2
|
@bogdan ah I see. I will ignore it from esbuild then. |
If you are using any gem providing esbuild wrapping, you should probably report a bug there because ignoring d.ts files by default is a good idea. |
No description provided.