Skip to content

Commit fadd95f

Browse files
authored
Fix unneeded cast lints (#29383)
1 parent 9f19c06 commit fadd95f

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/compiler/builder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ namespace ts {
7878
if (useOldState) {
7979
// Verify the sanity of old state
8080
if (!oldState!.currentChangedFilePath) {
81-
Debug.assert(!oldState!.affectedFiles && (!oldState!.currentAffectedFilesSignatures || !oldState!.currentAffectedFilesSignatures!.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
81+
const affectedSignatures = oldState!.currentAffectedFilesSignatures;
82+
Debug.assert(!oldState!.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
8283
}
8384
if (canCopySemanticDiagnostics) {
8485
Debug.assert(!forEachKey(oldState!.changedFilesSet, path => oldState!.semanticDiagnosticsPerFile!.has(path)), "Semantic diagnostics shouldnt be available for changed files");

src/compiler/parser.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7774,17 +7774,18 @@ namespace ts {
77747774
const libReferenceDirectives = context.libReferenceDirectives;
77757775
forEach(toArray(entryOrList), (arg: PragmaPseudoMap["reference"]) => {
77767776
// TODO: GH#18217
7777+
const { types, lib, path } = arg!.arguments;
77777778
if (arg!.arguments["no-default-lib"]) {
77787779
context.hasNoDefaultLib = true;
77797780
}
7780-
else if (arg!.arguments.types) {
7781-
typeReferenceDirectives.push({ pos: arg!.arguments.types!.pos, end: arg!.arguments.types!.end, fileName: arg!.arguments.types!.value });
7781+
else if (types) {
7782+
typeReferenceDirectives.push({ pos: types.pos, end: types.end, fileName: types.value });
77827783
}
7783-
else if (arg!.arguments.lib) {
7784-
libReferenceDirectives.push({ pos: arg!.arguments.lib!.pos, end: arg!.arguments.lib!.end, fileName: arg!.arguments.lib!.value });
7784+
else if (lib) {
7785+
libReferenceDirectives.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
77857786
}
7786-
else if (arg!.arguments.path) {
7787-
referencedFiles.push({ pos: arg!.arguments.path!.pos, end: arg!.arguments.path!.end, fileName: arg!.arguments.path!.value });
7787+
else if (path) {
7788+
referencedFiles.push({ pos: path.pos, end: path.end, fileName: path.value });
77887789
}
77897790
else {
77907791
reportDiagnostic(arg!.range.pos, arg!.range.end - arg!.range.pos, Diagnostics.Invalid_reference_directive_syntax);

src/harness/compiler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ namespace compiler {
183183
}
184184

185185
public getSourceMapRecord(): string | undefined {
186-
if (this.result!.sourceMaps && this.result!.sourceMaps!.length > 0) {
187-
return Harness.SourceMapRecorder.getSourceMapRecord(this.result!.sourceMaps!, this.program!, Array.from(this.js.values()).filter(d => !ts.fileExtensionIs(d.file, ts.Extension.Json)), Array.from(this.dts.values()));
186+
const maps = this.result!.sourceMaps;
187+
if (maps && maps.length > 0) {
188+
return Harness.SourceMapRecorder.getSourceMapRecord(maps, this.program!, Array.from(this.js.values()).filter(d => !ts.fileExtensionIs(d.file, ts.Extension.Json)), Array.from(this.dts.values()));
188189
}
189190
}
190191

0 commit comments

Comments
 (0)