address CR feedback: use typeof check instead of checking undefined and null value

This commit is contained in:
zhengbli 2016-01-15 16:55:25 -08:00
parent c2f453b8fb
commit c244306514

View file

@ -376,13 +376,11 @@ namespace ts {
/**
* @param watcherPath is the path from which the watcher is triggered.
*/
function fileEventHandler(eventName: string, relativefileName: string, baseDirPath: Path) {
function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: Path) {
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
/* tslint:disable:no-null */
const filePath = relativefileName === undefined || relativefileName === null
const filePath = typeof relativeFileName !== "string"
? undefined
: toPath(relativefileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
/* tslint:enable:no-null */
: toPath(relativeFileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
fileCallback(filePath);