Skip to content

Commit

Permalink
Support bigint route parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Dec 23, 2024
1 parent f42110a commit 11f4048
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [2.3.5]

* Support `bigint` route parameter

``` typescript
import {nft_path} from "./routes"

nft_path(123456789012345678901234567890n)
// => /nfts/123456789012345678901234567890
```

## [2.3.4]

* Fix deprecator usage in `rake js:routes:typescript` [#327](https://github.com/railsware/js-routes/issues/327)
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ declare type Optional<T> = {
[P in keyof T]?: T[P] | null;
};
declare type Collection<T> = Record<string, T>;
declare type BaseRouteParameter = string | boolean | Date | number;
declare type BaseRouteParameter = string | boolean | Date | number | bigint;
declare type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
declare type ModelRouteParameter = {
id: MethodRouteParameter;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type Optional<T> = { [P in keyof T]?: T[P] | null };
type Collection<T> = Record<string, T>;

type BaseRouteParameter = string | boolean | Date | number;
type BaseRouteParameter = string | boolean | Date | number | bigint;
type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
type ModelRouteParameter =
| { id: MethodRouteParameter }
Expand Down
2 changes: 1 addition & 1 deletion spec/js_routes/module_types/dts/routes.spec.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ declare type Optional<T> = {
[P in keyof T]?: T[P] | null;
};
declare type Collection<T> = Record<string, T>;
declare type BaseRouteParameter = string | boolean | Date | number;
declare type BaseRouteParameter = string | boolean | Date | number | bigint;
declare type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
declare type ModelRouteParameter = {
id: MethodRouteParameter;
Expand Down
11 changes: 11 additions & 0 deletions spec/js_routes/rails_routes_compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,15 @@
)
end
end

describe "bigint parameter" do
it "works" do
number = 10**20
expectjs(
"Routes.inbox_path(#{number}n)"
).to eq(
test_routes.inbox_path(number)
)
end
end
end

0 comments on commit 11f4048

Please sign in to comment.