Skip to content

Commit 2a8e063

Browse files
authored
Merge pull request #20441 from emberjs/fix-ts-nightly
[BUGFIX beta] fix for TS 5.1 nightly narrowing change
2 parents 38f53ef + 226fc02 commit 2a8e063

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/@ember/routing/route.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ function buildRenderOptions(
18501850
options?: PartialRenderOptions
18511851
): RenderOptions {
18521852
let isDefaultRender = !nameOrOptions && !options;
1853-
let _name;
1853+
let _name: string;
18541854
if (!isDefaultRender) {
18551855
if (typeof nameOrOptions === 'object' && !options) {
18561856
_name = route.templateName || route.routeName;
@@ -1860,7 +1860,11 @@ function buildRenderOptions(
18601860
'The name in the given arguments is undefined or empty string',
18611861
!isEmpty(nameOrOptions)
18621862
);
1863-
_name = nameOrOptions!;
1863+
// SAFETY: the check for `nameOrOptions` above should be validating this,
1864+
// and as of TS 5.1.0-dev.2023-0417 it is *not*. This cast can go away if
1865+
// TS validates it correctly *or* if we refactor this entire function to
1866+
// be less wildly dynamic in its argument handling.
1867+
_name = nameOrOptions as string;
18641868
}
18651869
}
18661870
assert(

0 commit comments

Comments
 (0)