diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 081ed5b6e67bb..dce12d33dc4bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1037,6 +1037,7 @@ namespace ts { function getNodeLinks(node: Node): NodeLinks { const nodeId = getNodeId(node); + // tslint:disable-next-line no-object-literal-type-assertion TODO: GH#18217 return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 } as NodeLinks); } @@ -2517,6 +2518,7 @@ namespace ts { if (lookupTable && exportNode) { lookupTable.set(id, { specifierText: getTextOfNode(exportNode.moduleSpecifier!) + // tslint:disable-next-line no-object-literal-type-assertion (TODO: GH#18217) } as ExportCollisionTracker); } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 18e88ad9d3a82..e0a6093c9911b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -971,7 +971,7 @@ namespace ts { [unknownOptionDiagnostic, optionTypeMismatchDiagnostic]: ParseCommandLineWorkerDiagnostics, commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined) { - const options = {} as OptionsBase; + const options: OptionsBase = {}; const fileNames: string[] = []; const errors: Diagnostic[] = []; @@ -1335,6 +1335,7 @@ namespace ts { */ export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile { const textOrDiagnostic = tryReadFile(fileName, readFile); + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] }; } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ec19d2c906c12..ea93100c60052 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2558,6 +2558,7 @@ namespace ts { /* @internal */ export function createEndOfDeclarationMarker(original: Node) { const node = createSynthesizedNode(SyntaxKind.EndOfDeclarationMarker); + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) node.emitNode = {} as EmitNode; node.original = original; return node; @@ -2570,6 +2571,7 @@ namespace ts { /* @internal */ export function createMergeDeclarationMarker(original: Node) { const node = createSynthesizedNode(SyntaxKind.MergeDeclarationMarker); + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) node.emitNode = {} as EmitNode; node.original = original; return node; @@ -2824,6 +2826,7 @@ namespace ts { // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. if (node.kind === SyntaxKind.SourceFile) { + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) return node.emitNode = { annotatedNodes: [node] } as EmitNode; } @@ -2831,6 +2834,7 @@ namespace ts { getOrCreateEmitNode(sourceFile).annotatedNodes!.push(node); } + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) node.emitNode = {} as EmitNode; } @@ -3096,6 +3100,7 @@ namespace ts { helpers, startsOnNewLine, } = sourceEmitNode; + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) if (!destEmitNode) destEmitNode = {} as EmitNode; // We are using `.slice()` here in case `destEmitNode.leadingComments` is pushed to later. if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 21122b5f7ed4c..5068a82a391bc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -7877,9 +7877,11 @@ namespace ts { } } } + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) pragmas.push({ name, args: { arguments: argument, range } } as PragmaPseudoMapEntry); } else { + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) pragmas.push({ name, args: { arguments: {}, range } } as PragmaPseudoMapEntry); } return; @@ -7909,6 +7911,7 @@ namespace ts { const args = match[2]; // Split on spaces and match up positionally with definition const argument = getNamedPragmaArguments(pragma, args); if (argument === "fail") return; // Missing required argument, fail to parse it + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) pragmas.push({ name, args: { arguments: argument, range } } as PragmaPseudoMapEntry); return; } diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index b509c6dd00354..948a01d3e4aa7 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -779,6 +779,7 @@ namespace ts { ); // Mark this node as originally an async function + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) (generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody | EmitFlags.ReuseTempVariableScope; return createCall( diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index cd62cca2c9dfb..25c9be3349923 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -995,6 +995,7 @@ namespace ts { context.requestEmitHelper(asyncGeneratorHelper); // Mark this node as originally an async function + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) (generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody; return createCall( diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 4b9e75102b6af..8ce9f86256d95 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -393,7 +393,7 @@ namespace ts { } function getCompilerOptionsOfBuildOptions(buildOptions: BuildOptions): CompilerOptions { - const result = {} as CompilerOptions; + const result: CompilerOptions = {}; commonOptionsWithBuild.forEach(option => { result[option.name] = buildOptions[option.name]; }); @@ -1119,7 +1119,7 @@ namespace ts { host.setModifiedTime(file, now); } - projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime } as UpToDateStatus); + projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); } function getFilesToClean(): string[] { diff --git a/src/harness/documents.ts b/src/harness/documents.ts index 312339287e245..176defeefe631 100644 --- a/src/harness/documents.ts +++ b/src/harness/documents.ts @@ -29,11 +29,12 @@ namespace documents { } public asTestFile() { + const fileOptions: Record = {}; + this.meta.forEach((value, key) => { fileOptions[key] = value; }); return this._testFile || (this._testFile = { unitName: this.file, content: this.text, - fileOptions: Array.from(this.meta) - .reduce((obj, [key, value]) => (obj[key] = value, obj), {} as Record) + fileOptions, }); } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1f6a9d3be40d7..21aa2b5c6f8e8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -342,6 +342,7 @@ namespace FourSlash { "getReferencesAtPosition", "getDocumentHighlights", ]; + // tslint:disable-next-line no-object-literal-type-assertion const proxy = {} as ts.LanguageService; for (const k in ls) { const key = k as keyof typeof ls; diff --git a/src/harness/vfs.ts b/src/harness/vfs.ts index ee9519f254c07..b9fbc60646cfc 100644 --- a/src/harness/vfs.ts +++ b/src/harness/vfs.ts @@ -846,8 +846,8 @@ namespace vfs { private _mknod(dev: number, type: typeof S_IFREG, mode: number, time?: number): FileInode; private _mknod(dev: number, type: typeof S_IFDIR, mode: number, time?: number): DirectoryInode; private _mknod(dev: number, type: typeof S_IFLNK, mode: number, time?: number): SymlinkInode; - private _mknod(dev: number, type: number, mode: number, time = this.time()) { - return { + private _mknod(dev: number, type: number, mode: number, time = this.time()): Inode { + return { dev, ino: ++inoCount, mode: (mode & ~S_IFMT & ~0o022 & 0o7777) | (type & S_IFMT), @@ -940,7 +940,7 @@ namespace vfs { let shadow = shadows.get(root.ino); if (!shadow) { - shadow = { + const inode: Inode = { dev: root.dev, ino: root.ino, mode: root.mode, @@ -951,6 +951,7 @@ namespace vfs { nlink: root.nlink, shadowRoot: root }; + shadow = inode; if (isSymlink(root)) (shadow).symlink = root.symlink; shadows.set(shadow.ino, shadow); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index ac80f43c84c26..3d91dd197e799 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1695,6 +1695,7 @@ namespace ts.server { const result = parseJsonText(configFilename, configFileContent); if (!result.endOfFileToken) { + // tslint:disable-next-line no-object-literal-type-assertion (TODO: GH#18217) result.endOfFileToken = { kind: SyntaxKind.EndOfFileToken }; } const configFileErrors = result.parseDiagnostics as Diagnostic[]; @@ -1849,10 +1850,11 @@ namespace ts.server { const diagnostics = project.getLanguageService().getCompilerOptionsDiagnostics(); diagnostics.push(...project.getAllProjectErrors()); - this.eventHandler({ + const event: ConfigFileDiagEvent = { eventName: ConfigFileDiagEvent, data: { configFileName: project.getConfigFilePath(), diagnostics, triggerFile } - }); + }; + this.eventHandler(event); } private getOrCreateInferredProjectForProjectRootPathIfEnabled(info: ScriptInfo, projectRootPath: NormalizedPath | undefined): InferredProject | undefined { diff --git a/src/server/project.ts b/src/server/project.ts index 7b11f48fbd623..f599c644f15a9 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1105,6 +1105,7 @@ namespace ts.server { // Provide global: true so plugins can detect why they can't find their config this.projectService.logger.info(`Loading global plugin ${globalPluginName}`); + // tslint:disable-next-line no-object-literal-type-assertion (TODO: GH#18217) this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths, pluginConfigOverrides); } } diff --git a/src/server/session.ts b/src/server/session.ts index 7ff1364c4a095..269665dd1a8b4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -896,18 +896,18 @@ namespace ts.server { } private convertToDiagnosticsWithLinePosition(diagnostics: ReadonlyArray, scriptInfo: ScriptInfo | undefined): protocol.DiagnosticWithLinePosition[] { - return diagnostics.map(d => { + return diagnostics.map((d): protocol.DiagnosticWithLinePosition => ({ message: flattenDiagnosticMessageText(d.messageText, this.host.newLine), - start: d.start, - length: d.length, + start: d.start!, // TODO: GH#18217 + length: d.length!, category: diagnosticCategoryName(d), code: d.code, - source: d.source, - startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start!), // TODO: GH#18217 - endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start! + d.length!), + ["sour" + "ce"]: d.source, // TODO: GH#18217 + startLocation: (scriptInfo && scriptInfo.positionToLineOffset(d.start!))!, // TODO: GH#18217 + endLocation: (scriptInfo && scriptInfo.positionToLineOffset(d.start! + d.length!))!, reportsUnnecessary: d.reportsUnnecessary, relatedInformation: map(d.relatedInformation, formatRelatedInformation), - }); + })); } private getDiagnosticsWorker( @@ -2404,7 +2404,7 @@ namespace ts.server { } } - public executeCommand(request: protocol.Request): HandlerResponse { + public executeCommand(request: T): HandlerResponse { const handler = this.handlers.get(request.command); if (handler) { return this.executeWithRequestId(request.seq, () => handler(request)); diff --git a/src/services/sourcemaps.ts b/src/services/sourcemaps.ts index 92ebcc8c261d2..d005d9632519c 100644 --- a/src/services/sourcemaps.ts +++ b/src/services/sourcemaps.ts @@ -145,13 +145,13 @@ namespace ts { if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; // And failing that, check the disk const text = host.readFile(path)!; // TODO: GH#18217 - const file = { + const file: SourceFileLike = { text, lineMap: undefined, getLineAndCharacterOfPosition(pos: number) { return computeLineAndCharacterOfPosition(getLineStarts(this), pos); } - } as SourceFileLike; + }; cached.set(path, file); return file; } diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index c10be2a9ff8e3..d88eda94fca4b 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -348,10 +348,12 @@ namespace Harness.Parallel.Host { } worker.currentTasks = taskList; if (taskList.length === 1) { - worker.process.send({ type: "test", payload: taskList[0] } as ParallelHostMessage); // TODO: GH#18217 + // tslint:disable-next-line no-object-literal-type-assertion (TODO: GH#18217) + worker.process.send({ type: "test", payload: taskList[0] } as ParallelHostMessage); } else { - worker.process.send({ type: "batch", payload: taskList } as ParallelHostMessage); // TODO: GH#18217 + // tslint:disable-next-line no-object-literal-type-assertion (TODO: GH#18217) + worker.process.send({ type: "batch", payload: taskList } as ParallelHostMessage); } } } diff --git a/src/testRunner/unittests/session.ts b/src/testRunner/unittests/session.ts index ac5d8093e31db..12a21e8503ee3 100644 --- a/src/testRunner/unittests/session.ts +++ b/src/testRunner/unittests/session.ts @@ -160,9 +160,9 @@ namespace ts.server { } }; session.onMessage(JSON.stringify(setOptionsRequest)); - assert.deepEqual( + assert.deepEqual( session.getProjectService().getCompilerOptionsForInferredProjects(), - { + { module: ModuleKind.System, target: ScriptTarget.ES5, jsx: JsxEmit.React, @@ -316,14 +316,15 @@ namespace ts.server { session.onMessage(JSON.stringify(req)); - expect(lastSent).to.deep.equal({ + const response: protocol.ConfigureResponse = { command: CommandNames.Configure, type: "response", success: true, request_seq: 0, seq: 0, body: undefined - }); + }; + assert.deepEqual(lastSent, response); }); }); diff --git a/src/testRunner/unittests/tsconfigParsing.ts b/src/testRunner/unittests/tsconfigParsing.ts index 255129d9fb6e5..e013f9828c08f 100644 --- a/src/testRunner/unittests/tsconfigParsing.ts +++ b/src/testRunner/unittests/tsconfigParsing.ts @@ -22,18 +22,22 @@ namespace ts { function getParsedCommandJson(jsonText: string, configFileName: string, basePath: string, allFileList: string[]) { const parsed = parseConfigFileTextToJson(configFileName, jsonText); - const files = allFileList.reduce((files, value) => (files[value] = "", files), {} as vfs.FileSet); - const host: ParseConfigHost = new fakes.ParseConfigHost(new vfs.FileSystem(/*ignoreCase*/ false, { cwd: basePath, files: { "/": {}, ...files } })); + const host: ParseConfigHost = new fakes.ParseConfigHost(new vfs.FileSystem(/*ignoreCase*/ false, { cwd: basePath, files: { "/": {}, ...filesToFileSet(allFileList) } })); return parseJsonConfigFileContent(parsed.config, host, basePath, /*existingOptions*/ undefined, configFileName); } function getParsedCommandJsonNode(jsonText: string, configFileName: string, basePath: string, allFileList: string[]) { const parsed = parseJsonText(configFileName, jsonText); - const files = allFileList.reduce((files, value) => (files[value] = "", files), {} as vfs.FileSet); - const host: ParseConfigHost = new fakes.ParseConfigHost(new vfs.FileSystem(/*ignoreCase*/ false, { cwd: basePath, files: { "/": {}, ...files } })); + const host: ParseConfigHost = new fakes.ParseConfigHost(new vfs.FileSystem(/*ignoreCase*/ false, { cwd: basePath, files: { "/": {}, ...filesToFileSet(allFileList) } })); return parseJsonSourceFileConfigFileContent(parsed, host, basePath, /*existingOptions*/ undefined, configFileName); } + function filesToFileSet(allFileList: ReadonlyArray): vfs.FileSet { + const files: vfs.FileSet = {}; + for (const file of allFileList) { files[file] = ""; } + return files; + } + function assertParseFileList(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedFileList: string[]) { { const parsed = getParsedCommandJson(jsonText, configFileName, basePath, allFileList); diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index 085b5cf18af31..a3ace43292f40 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -1,3 +1,5 @@ +// tslint:disable no-object-literal-type-assertion (TODO: GH#18217) + namespace ts.projectSystem { import TI = server.typingsInstaller; import protocol = server.protocol; diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index df83f1a677c39..d46ed4ad0c07c 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -325,6 +325,7 @@ namespace ts.server.typingsInstaller { this.installRunCount++; // send progress event + // tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217) this.sendResponse({ kind: EventBeginInstallTypes, eventId: requestId, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index ac36533a09454..a6c4429e72a63 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8919,7 +8919,7 @@ declare namespace ts.server { private setCurrentRequest; private resetCurrentRequest; executeWithRequestId(requestId: number, f: () => T): T; - executeCommand(request: protocol.Request): HandlerResponse; + executeCommand(request: T): HandlerResponse; onMessage(message: string): void; private getFormatOptions; private getPreferences; diff --git a/tslint.json b/tslint.json index a3ca10e75edbc..6121972469900 100644 --- a/tslint.json +++ b/tslint.json @@ -101,7 +101,6 @@ "no-debugger": false, "no-empty-interface": false, "no-eval": false, - "no-object-literal-type-assertion": false, "no-shadowed-variable": false, "no-submodule-imports": false, "no-var-requires": false,