Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit adc34f8

Browse files
cdaringevsavkin
authored andcommitted
feat(core): add user-friendly error on invalid input
Prevent cryptic error of `TypeError: Cannot read property 'map' of undefined`, which doesn't guide the user towards success
1 parent d1f740e commit adc34f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/workspace/src/schematics/move/lib/update-imports.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ export function updateImports(schema: Schema) {
8888
const path = tsConfig.compilerOptions.paths[
8989
projectRef.from
9090
] as string[];
91-
91+
if (!path) {
92+
throw new Error(
93+
[
94+
`unable to find "${projectRef.from}" in`,
95+
`${tsConfigPath} compilerOptions.paths`,
96+
].join(' ')
97+
);
98+
}
9299
const updatedPath = path.map((x) =>
93100
x.replace(new RegExp(projectRoot.from, 'g'), projectRoot.to)
94101
);

0 commit comments

Comments
 (0)