Fix many no-object-literal-type-assertion lint errors (#17278)

* Fix many no-object-literal-type-assertion lint errors

* Simple fixes

* Use a union for FlowNode

* PR feedback and remove remaining `id()` uses

* Use a union for CodeBlock

* Discriminate CodeBlock by CodeBlockKind
This commit is contained in:
Andy
2017-08-10 12:52:15 -07:00
committed by GitHub
parent fe3a05e89a
commit 08fbcd8b80
17 changed files with 140 additions and 148 deletions

View File

@@ -441,10 +441,11 @@ namespace ts.server {
if (!this.eventHandler) {
return;
}
this.eventHandler(<ProjectLanguageServiceStateEvent>{
const event: ProjectLanguageServiceStateEvent = {
eventName: ProjectLanguageServiceStateEvent,
data: { project, languageServiceEnabled }
});
};
this.eventHandler(event);
}
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void {
@@ -602,10 +603,11 @@ namespace ts.server {
}
for (const openFile of this.openFiles) {
this.eventHandler(<ContextEvent>{
const event: ContextEvent = {
eventName: ContextEvent,
data: { project: openFile.getDefaultProject(), fileName: openFile.fileName }
});
};
this.eventHandler(event);
}
}
@@ -1105,10 +1107,11 @@ namespace ts.server {
return;
}
this.eventHandler(<ConfigFileDiagEvent>{
const event: ConfigFileDiagEvent = {
eventName: ConfigFileDiagEvent,
data: { configFileName, diagnostics: diagnostics || emptyArray, triggerFile }
});
};
this.eventHandler(event);
}
private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: ReadonlyArray<Diagnostic>, clientFileName?: string) {

View File

@@ -540,7 +540,7 @@ namespace ts.server {
}
private convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnostics: ReadonlyArray<Diagnostic>): protocol.DiagnosticWithLinePosition[] {
return diagnostics.map(d => <protocol.DiagnosticWithLinePosition>{
return diagnostics.map<protocol.DiagnosticWithLinePosition>(d => ({
message: flattenDiagnosticMessageText(d.messageText, this.host.newLine),
start: d.start,
length: d.length,
@@ -548,7 +548,7 @@ namespace ts.server {
code: d.code,
startLocation: d.file && convertToLocation(getLineAndCharacterOfPosition(d.file, d.start)),
endLocation: d.file && convertToLocation(getLineAndCharacterOfPosition(d.file, d.start + d.length))
});
}));
}
private getCompilerOptionsDiagnostics(args: protocol.CompilerOptionsDiagnosticsRequestArgs) {
@@ -829,7 +829,7 @@ namespace ts.server {
return renameLocations.map(location => {
const locationScriptInfo = project.getScriptInfo(location.fileName);
return <protocol.FileSpan>{
return {
file: location.fileName,
start: locationScriptInfo.positionToLineOffset(location.textSpan.start),
end: locationScriptInfo.positionToLineOffset(textSpanEnd(location.textSpan)),

View File

@@ -356,14 +356,15 @@ namespace ts.server.typingsInstaller {
this.sendResponse(this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles)));
}
finally {
this.sendResponse(<EndInstallTypes>{
const response: EndInstallTypes = {
kind: EventEndInstallTypes,
eventId: requestId,
projectName: req.projectName,
packagesToInstall: scopedTypings,
installSuccess: ok,
typingsInstallerVersion: ts.version // qualified explicitly to prevent occasional shadowing
});
};
this.sendResponse(response);
}
});
}