Skip to content

Commit cef25bf

Browse files
Only check source file when we have one.
1 parent c8e106e commit cef25bf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/compiler/core.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,11 @@ module ts {
301301

302302
Debug.assert(start >= 0, "start must be non-negative, is " + start);
303303
Debug.assert(length >= 0, "length must be non-negative, is " + length);
304-
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
305-
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
304+
305+
if (file) {
306+
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
307+
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
308+
}
306309

307310
let text = getLocaleSpecificMessage(message.key);
308311

src/compiler/utilities.ts

+4
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ module ts {
165165
return "";
166166
}
167167

168+
if (!sourceFile && node.kind === SyntaxKind.Identifier) {
169+
return (<Identifier>node).text;
170+
}
171+
168172
let text = sourceFile.text;
169173
return text.substring(skipTrivia(text, node.pos), node.end);
170174
}

0 commit comments

Comments
 (0)