Skip to content

Commit 11f4048

Browse files
committed
Support bigint route parameter
1 parent f42110a commit 11f4048

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [2.3.5]
4+
5+
* Support `bigint` route parameter
6+
7+
``` typescript
8+
import {nft_path} from "./routes"
9+
10+
nft_path(123456789012345678901234567890n)
11+
// => /nfts/123456789012345678901234567890
12+
```
13+
314
## [2.3.4]
415

516
* Fix deprecator usage in `rake js:routes:typescript` [#327](https://github.com/railsware/js-routes/issues/327)

lib/routes.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare type Optional<T> = {
22
[P in keyof T]?: T[P] | null;
33
};
44
declare type Collection<T> = Record<string, T>;
5-
declare type BaseRouteParameter = string | boolean | Date | number;
5+
declare type BaseRouteParameter = string | boolean | Date | number | bigint;
66
declare type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
77
declare type ModelRouteParameter = {
88
id: MethodRouteParameter;

lib/routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type Optional<T> = { [P in keyof T]?: T[P] | null };
22
type Collection<T> = Record<string, T>;
33

4-
type BaseRouteParameter = string | boolean | Date | number;
4+
type BaseRouteParameter = string | boolean | Date | number | bigint;
55
type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
66
type ModelRouteParameter =
77
| { id: MethodRouteParameter }

spec/js_routes/module_types/dts/routes.spec.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare type Optional<T> = {
22
[P in keyof T]?: T[P] | null;
33
};
44
declare type Collection<T> = Record<string, T>;
5-
declare type BaseRouteParameter = string | boolean | Date | number;
5+
declare type BaseRouteParameter = string | boolean | Date | number | bigint;
66
declare type MethodRouteParameter = BaseRouteParameter | (() => BaseRouteParameter);
77
declare type ModelRouteParameter = {
88
id: MethodRouteParameter;

spec/js_routes/rails_routes_compatibility_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,4 +540,15 @@
540540
)
541541
end
542542
end
543+
544+
describe "bigint parameter" do
545+
it "works" do
546+
number = 10**20
547+
expectjs(
548+
"Routes.inbox_path(#{number}n)"
549+
).to eq(
550+
test_routes.inbox_path(number)
551+
)
552+
end
553+
end
543554
end

0 commit comments

Comments
 (0)