CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 00:05:15 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/neo4j/neo4j-javascript-driver.git
etag: W/"38e103e6d5405efeb2e7c910beb79d12"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=a97mDvgEscQhJDSKpWfmxfdLT57gSxrKFWm1ki8X0u9u9X8HnMPEJILQ9ulrA45%2FOe%2FArBv9faYgXs7eJPSuRB9aUnRpD%2FaGP9WIJBB9HF9AlVvupVIjUXN5NTXxFrsmjdOYMJXOtehE1HEzl7eS2QQR3klkV3WXovCh3ODz7v5ZsocwWujNHgI0BE1ubwhW%2BC%2FMBP1qnKVzr0Yj1T7MrdRzAiQyFm0PXpJ8hQO1nOiCLfKFJ6toMguIG03I4LU5NJ9llcUi5H5LNxiWFH2YkA%3D%3D--98Qep0SmXKQWbIH9--iNbhij0utpQX8e%2BYbe%2FueQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.26022905.1753229114; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 00:05:14 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 00:05:14 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E496:17EAA:1E616A:2A0A3A:6880273A
Add and Improve type guards for `is` methods (#1037) · neo4j/neo4j-javascript-driver@3db98f5 · GitHub
⚠️ Generic types miss-match in runtime will not trigger errors.
Co-authored-by: Robsdedude <dev@rouvenbauer.de>
Copy file name to clipboardExpand all lines: packages/core/src/graph-types.ts
Copy file name to clipboardExpand all lines: packages/core/src/spatial-types.ts
Copy file name to clipboardExpand all lines: packages/core/src/temporal-types.ts
Copy file name to clipboardExpand all lines: packages/core/test/graph-types.test.ts
Copy file name to clipboardExpand all lines: packages/core/test/spatial-types.test.ts
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit 3db98f5
Add and Improve type guards for
* Add and Improve type guards for `is` methods
The following methods were update to include type-guards and improve the generics over when using the type-guards:
* isNode
* isRelationship
* isUnboundRelationship
* isPath
* isPathSegment
* isPoint
* isDuration
* isLocalTime
* isTime
* isDate
* isLocalDateTime
* isDateTime
Usage example without generics:
```
function handleDuration(duration: unknown) {
if (isDuration(duration)) {
// from this point i can access the duration properties
// and methods without issue
const months: Integer = duration.months
} else {
// this is not a duration object
// @ts-expect-error
const months = duration.months
}
}
```
Usage example with generics:
The following methods were update to include type-guards and improve the generics over when using the type-guards:
* isNode
* isRelationship
* isUnboundRelationship
* isPath
* isPathSegment
* isPoint
* isDuration
* isLocalTime
* isTime
* isDate
* isLocalDateTime
* isDateTime
Usage example without generics:
```typescript
function handleDuration(duration: unknown) {
if (isDuration(duration)) {
// from this point i can access the duration properties
// and methods without issue
const months: Integer = duration.months
} else {
// this is not a duration object
// @ts-expect-error
const months = duration.months
}
}
```
Usage example with generics:
```typescript
function handleDuration(duration: unknown) {
if (isDuration<number>(duration)) {
// from this point i can access the duration properties
// and methods without issue
const months: number = duration.months
// @ts-expect-error
const intMonths: Integer = duration.months
} else {
// this is not a duration object
// @ts-expect-error
const months = duration.months
}
}
```
is
methods (#1037)1 parent d55e175 commit 3db98f5Copy full SHA for 3db98f5
File tree
Expand file treeCollapse file tree
9 files changed
+374
-34
lines changedFilter options
- packages
- core
- src
- test
- neo4j-driver-deno/lib/core
Expand file treeCollapse file tree
9 files changed
+374
-34
lines changedpackages/core/src/graph-types.ts
Copy file name to clipboardExpand all lines: packages/core/src/graph-types.ts+14-5Lines changed: 14 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
120 |
| - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 |
| |
122 | 125 |
| |
123 | 126 |
| |
| |||
228 | 231 |
| |
229 | 232 |
| |
230 | 233 |
| |
231 |
| - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
232 | 238 |
| |
233 | 239 |
| |
234 | 240 |
| |
| |||
346 | 352 |
| |
347 | 353 |
| |
348 | 354 |
| |
349 |
| - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
350 | 359 |
| |
351 | 360 |
| |
352 | 361 |
| |
| |||
394 | 403 |
| |
395 | 404 |
| |
396 | 405 |
| |
397 |
| - | |
| 406 | + | |
398 | 407 |
| |
399 | 408 |
| |
400 | 409 |
| |
| |||
448 | 457 |
| |
449 | 458 |
| |
450 | 459 |
| |
451 |
| - | |
| 460 | + | |
452 | 461 |
| |
453 | 462 |
| |
454 | 463 |
| |
|
packages/core/src/spatial-types.ts
Copy file name to clipboardExpand all lines: packages/core/src/spatial-types.ts+3-2Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
96 |
| - | |
97 |
| - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
98 | 99 |
|
packages/core/src/temporal-types.ts
Copy file name to clipboardExpand all lines: packages/core/src/temporal-types.ts+6-6Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
111 |
| - | |
| 111 | + | |
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
| |||
206 | 206 |
| |
207 | 207 |
| |
208 | 208 |
| |
209 |
| - | |
| 209 | + | |
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
| |||
315 | 315 |
| |
316 | 316 |
| |
317 | 317 |
| |
318 |
| - | |
| 318 | + | |
319 | 319 |
| |
320 | 320 |
| |
321 | 321 |
| |
| |||
399 | 399 |
| |
400 | 400 |
| |
401 | 401 |
| |
402 |
| - | |
| 402 | + | |
403 | 403 |
| |
404 | 404 |
| |
405 | 405 |
| |
| |||
532 | 532 |
| |
533 | 533 |
| |
534 | 534 |
| |
535 |
| - | |
| 535 | + | |
536 | 536 |
| |
537 | 537 |
| |
538 | 538 |
| |
| |||
733 | 733 |
| |
734 | 734 |
| |
735 | 735 |
| |
736 |
| - | |
| 736 | + | |
737 | 737 |
| |
738 | 738 |
| |
739 | 739 |
| |
|
packages/core/test/graph-types.test.ts
Copy file name to clipboardExpand all lines: packages/core/test/graph-types.test.ts+182-3Lines changed: 182 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
25 |
| - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 |
| |
27 | 31 |
| |
28 | 32 |
| |
| |||
70 | 74 |
| |
71 | 75 |
| |
72 | 76 |
| |
73 |
| - | |
| 77 | + | |
74 | 78 |
| |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
75 | 88 |
| |
76 | 89 |
| |
77 |
| - | |
| 90 | + | |
78 | 91 |
| |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
79 | 101 |
| |
80 | 102 |
| |
81 | 103 |
| |
| |||
219 | 241 |
| |
220 | 242 |
| |
221 | 243 |
| |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
222 | 270 |
| |
223 | 271 |
| |
224 | 272 |
| |
| |||
346 | 394 |
| |
347 | 395 |
| |
348 | 396 |
| |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
349 | 423 |
| |
350 | 424 |
| |
351 | 425 |
| |
| |||
388 | 462 |
| |
389 | 463 |
| |
390 | 464 |
| |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
391 | 570 |
| |
392 | 571 |
| |
393 | 572 |
| |
|
packages/core/test/spatial-types.test.ts
Copy file name to clipboardExpand all lines: packages/core/test/spatial-types.test.ts+24-4Lines changed: 24 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
94 | 94 |
| |
95 | 95 |
| |
96 | 96 |
| |
97 |
| - | |
98 |
| - | |
99 |
| - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
100 | 109 |
| |
101 | 110 |
| |
102 | 111 |
| |
103 | 112 |
| |
104 | 113 |
| |
105 | 114 |
| |
106 |
| - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
107 | 127 |
|
You can’t perform that action at this time.
0 commit comments