Skip to content

Commit 5480daf

Browse files
committed
style: replace ternary with nullish coalescing in sample code
1 parent 84de592 commit 5480daf

8 files changed

Lines changed: 16 additions & 40 deletions

File tree

‎sample/sample10-mixed/app.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ dataSource
5151
postRepository
5252
.save(post)
5353
.then((result) => console.log(result))
54-
.catch((error) => console.log(error.stack ? error.stack : error))
54+
.catch((error) => console.log(error.stack ?? error))
5555
})
56-
.catch((error) => console.log(error.stack ? error.stack : error))
56+
.catch((error) => console.log(error.stack ?? error))

‎sample/sample13-everywhere-abstraction/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ dataSource.initialize().then(
7777
return blogRepository.save(blog)
7878
})
7979
.catch((error) =>
80-
console.log(
81-
"Cannot save. Error: ",
82-
error.stack ? error.stack : error,
83-
),
80+
console.log("Cannot save. Error: ", error.stack ?? error),
8481
)
8582
},
86-
(error) =>
87-
console.log("Cannot connect: ", error.stack ? error.stack : error),
83+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8884
)

‎sample/sample24-schemas/app.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ dataSource
6666
.then((result) => {
6767
console.log(result)
6868
})
69-
.catch((error) => console.log(error.stack ? error.stack : error))
69+
.catch((error) => console.log(error.stack ?? error))
7070
})
71-
.catch((error) => console.log(error.stack ? error.stack : error))
71+
.catch((error) => console.log(error.stack ?? error))

‎sample/sample5-subscribers/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ dataSource.initialize().then(
7272
console.log("post removed.")
7373
})
7474
.catch((error) =>
75-
console.log(
76-
"Cannot save. Error: ",
77-
error.stack ? error.stack : error,
78-
),
75+
console.log("Cannot save. Error: ", error.stack ?? error),
7976
)
8077
},
81-
(error) =>
82-
console.log("Cannot connect: ", error.stack ? error.stack : error),
78+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8379
)

‎sample/sample6-abstract-table/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ dataSource.initialize().then(
7272
return blogRepository.save(blog)
7373
})
7474
.catch((error) =>
75-
console.log(
76-
"Cannot save. Error: ",
77-
error.stack ? error.stack : error,
78-
),
75+
console.log("Cannot save. Error: ", error.stack ?? error),
7976
)
8077
},
81-
(error) =>
82-
console.log("Cannot connect: ", error.stack ? error.stack : error),
78+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8379
)

‎sample/sample7-pagination/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ dataSource.initialize().then(
7171
console.log("count: ", entitiesWithCount[1])
7272
})
7373
.catch((error) =>
74-
console.log(
75-
"Cannot save. Error: ",
76-
error.stack ? error.stack : error,
77-
),
74+
console.log("Cannot save. Error: ", error.stack ?? error),
7875
)
7976
},
80-
(error) =>
81-
console.log("Cannot connect: ", error.stack ? error.stack : error),
77+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8278
)

‎sample/sample8-self-referencing/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ dataSource.initialize().then(
3535
console.log("saved category: ", savedCategory)
3636
})
3737
.catch((error) =>
38-
console.log(
39-
"Cannot save. Error: ",
40-
error.stack ? error.stack : error,
41-
),
38+
console.log("Cannot save. Error: ", error.stack ?? error),
4239
)
4340
},
44-
(error) =>
45-
console.log("Cannot connect: ", error.stack ? error.stack : error),
41+
(error) => console.log("Cannot connect: ", error.stack ?? error),
4642
)

‎sample/sample9-entity-listeners/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ dataSource.initialize().then(
7171
console.log("post removed.")
7272
})
7373
.catch((error) =>
74-
console.log(
75-
"Cannot save. Error: ",
76-
error.stack ? error.stack : error,
77-
),
74+
console.log("Cannot save. Error: ", error.stack ?? error),
7875
)
7976
},
80-
(error) =>
81-
console.log("Cannot connect: ", error.stack ? error.stack : error),
77+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8278
)

0 commit comments

Comments
 (0)