Skip to content

Commit e6cfb91

Browse files
authored
Fix ts error for potentially undefined newFileName (#1564)
## Purpose We had a ts error on build that wasn't caught by eslint. Apparently we were too clever with an if statement, and had to be more explicit. ``` lib/osf-components/addon/components/file-browser/file-rename-modal/component.ts:31:46 - error TS2532: Object is possibly 'undefined'. 31 return (Boolean(this.newFileName) && this.newFileName.trim() !== this.originalFileName && ~~~~~~~~~~~~~~~~ lib/osf-components/addon/components/file-browser/file-rename-modal/component.ts:32:13 - error TS2532: Object is possibly 'undefined'. 32 this.newFileName.trim() !== ''); ~~~~~~~~~~~~~~~~ ``` ## Summary of Changes 1. Wrap return in an if statement to check for the existence of newFileName
1 parent db99566 commit e6cfb91

File tree

1 file changed

+4
-2
lines changed
  • lib/osf-components/addon/components/file-browser/file-rename-modal

1 file changed

+4
-2
lines changed

lib/osf-components/addon/components/file-browser/file-rename-modal/component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ export default class FileRenameModal extends Component<Args> {
2828
}
2929

3030
get isValid() {
31-
return (Boolean(this.newFileName) && this.newFileName.trim() !== this.originalFileName &&
32-
this.newFileName.trim() !== '');
31+
if(this.newFileName) {
32+
return (this.newFileName.trim() !== this.originalFileName && this.newFileName.trim() !== '');
33+
}
34+
return false;
3335
}
3436

3537
@action

0 commit comments

Comments
 (0)