Skip to content

Commit 28991e1

Browse files
author
Andy Hanson
committed
Fix API baselines
1 parent e31b4e9 commit 28991e1

File tree

10 files changed

+39
-39
lines changed

10 files changed

+39
-39
lines changed

Jakefile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
386386
else {
387387
options += " --lib es5";
388388
}
389-
options += " --noUnusedLocals --noUnusedParameters";
389+
options += " --noUnusedLocals --noUnusedParameters --strictNullChecks";
390390

391391
var cmd = host + " " + compilerPath + " " + options + " ";
392392
cmd = cmd + sources.join(" ");

scripts/buildProtocol.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function endsWith(s: string, suffix: string) {
88
}
99

1010
function isStringEnum(declaration: ts.EnumDeclaration) {
11-
return declaration.members.length && declaration.members.every(m => m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
11+
return declaration.members.length && declaration.members.every(m => !!m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
1212
}
1313

1414
class DeclarationsWalker {
@@ -30,7 +30,7 @@ class DeclarationsWalker {
3030
text += "\ndeclare namespace ts {\n";
3131
text += " // these types are empty stubs for types from services and should not be used directly\n"
3232
for (const type of walker.removedTypes) {
33-
text += ` export type ${type.symbol.name} = never;\n`;
33+
text += ` export type ${type.symbol!.name} = never;\n`;
3434
}
3535
text += "}"
3636
}
@@ -130,7 +130,7 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
130130
function getInitialDtsFileForProtocol() {
131131
const program = ts.createProgram([protocolTs, typeScriptServicesDts], options);
132132

133-
let protocolDts: string;
133+
let protocolDts: string | undefined;
134134
program.emit(program.getSourceFile(protocolTs), (file, content) => {
135135
if (endsWith(file, ".d.ts")) {
136136
protocolDts = content;
@@ -162,7 +162,7 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
162162
let protocolDts = getInitialDtsFileForProtocol();
163163
const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true);
164164

165-
const protocolFile = program.getSourceFile("protocol.d.ts");
165+
const protocolFile = program.getSourceFile("protocol.d.ts")!;
166166
const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile);
167167
if (extraDeclarations) {
168168
protocolDts += extraDeclarations;
@@ -178,7 +178,7 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
178178
ts.sys.writeFile(outputFile, protocolDts);
179179

180180
if (diagnostics.length) {
181-
const flattenedDiagnostics = diagnostics.map(d => `${ts.flattenDiagnosticMessageText(d.messageText, "\n")} at ${d.file.fileName} line ${d.start}`).join("\n");
181+
const flattenedDiagnostics = diagnostics.map(d => `${ts.flattenDiagnosticMessageText(d.messageText, "\n")} at ${d.file!.fileName} line ${d.start!}`).join("\n");
182182
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
183183
}
184184
}

scripts/processDiagnosticMessages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function main(): void {
2424
}
2525

2626
const inputFilePath = sys.args[0].replace(/\\/g, "/");
27-
const inputStr = sys.readFile(inputFilePath);
27+
const inputStr = sys.readFile(inputFilePath)!;
2828

2929
const diagnosticMessagesJson: { [key: string]: DiagnosticDetails } = JSON.parse(inputStr);
3030

scripts/tslint/rules/noInOperatorRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class Rule extends Lint.Rules.AbstractRule {
1212
function walk(ctx: Lint.WalkContext<void>): void {
1313
ts.forEachChild(ctx.sourceFile, recur);
1414
function recur(node: ts.Node): void {
15-
if (node.kind === ts.SyntaxKind.InKeyword && node.parent.kind === ts.SyntaxKind.BinaryExpression) {
15+
if (node.kind === ts.SyntaxKind.InKeyword && node.parent!.kind === ts.SyntaxKind.BinaryExpression) {
1616
ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
1717
}
1818
}

src/compiler/factory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,7 @@ namespace ts {
27922792
/**
27932793
* Gets the constant value to emit for an expression.
27942794
*/
2795-
export function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression) {
2795+
export function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number | undefined {
27962796
const emitNode = node.emitNode;
27972797
return emitNode && emitNode.constantValue;
27982798
}

src/compiler/sys.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace ts {
8282
declare const global: any;
8383
declare const __filename: string;
8484

85-
export function getNodeMajorVersion() {
85+
export function getNodeMajorVersion(): number | undefined {
8686
if (typeof process === "undefined") {
8787
return undefined;
8888
}

src/compiler/tsc.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace ts {
4747
const commandLine = parseCommandLine(args);
4848

4949
// Configuration file name (if any)
50-
let configFileName: string;
50+
let configFileName: string | undefined;
5151
if (commandLine.options.locale) {
5252
validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
5353
}
@@ -71,7 +71,7 @@ namespace ts {
7171

7272
if (commandLine.options.help || commandLine.options.all) {
7373
printVersion();
74-
printHelp(commandLine.options.all);
74+
printHelp(!!commandLine.options.all);
7575
return sys.exit(ExitStatus.Success);
7676
}
7777

@@ -104,13 +104,13 @@ namespace ts {
104104

105105
if (commandLine.fileNames.length === 0 && !configFileName) {
106106
printVersion();
107-
printHelp(commandLine.options.all);
107+
printHelp(!!commandLine.options.all);
108108
return sys.exit(ExitStatus.Success);
109109
}
110110

111111
const commandLineOptions = commandLine.options;
112112
if (configFileName) {
113-
const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, sys, reportDiagnostic);
113+
const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, sys, reportDiagnostic)!; // TODO: GH#18217
114114
udpateReportDiagnostic(configParseResult.options);
115115
if (isWatchSet(configParseResult.options)) {
116116
reportWatchModeWithoutSysSupport();
@@ -155,7 +155,7 @@ namespace ts {
155155
enableStatistics(options);
156156
return compileUsingBuilder(rootNames, options, host, oldProgram);
157157
};
158-
const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
158+
const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate!; // TODO: GH#18217
159159
watchCompilerHost.afterProgramCreate = builderProgram => {
160160
emitFilesUsingBuilder(builderProgram);
161161
reportStatistics(builderProgram.getProgram());
@@ -167,7 +167,7 @@ namespace ts {
167167
}
168168

169169
function createWatchOfConfigFile(configParseResult: ParsedCommandLine, optionsToExtend: CompilerOptions) {
170-
const watchCompilerHost = ts.createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath, optionsToExtend, sys, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(configParseResult.options));
170+
const watchCompilerHost = ts.createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath!, optionsToExtend, sys, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(configParseResult.options)); // TODO: GH#18217
171171
updateWatchCompilationHost(watchCompilerHost);
172172
watchCompilerHost.rootFiles = configParseResult.fileNames;
173173
watchCompilerHost.options = configParseResult.options;
@@ -292,7 +292,7 @@ namespace ts {
292292
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
293293
const optsList = showAllOptions ?
294294
sort(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) :
295-
filter(optionDeclarations.slice(), v => v.showInSimplifiedHelpView);
295+
filter(optionDeclarations.slice(), v => !!v.showInSimplifiedHelpView);
296296

297297
// We want our descriptions to align at the same column in our output,
298298
// so we keep track of the longest option usage string.

src/compiler/utilities.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,7 @@ namespace ts {
37773777
return overlapStart < overlapEnd;
37783778
}
37793779

3780-
export function textSpanOverlap(span1: TextSpan, span2: TextSpan) {
3780+
export function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined {
37813781
const overlapStart = Math.max(span1.start, span2.start);
37823782
const overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
37833783
if (overlapStart < overlapEnd) {
@@ -3805,7 +3805,7 @@ namespace ts {
38053805
return position <= textSpanEnd(span) && position >= span.start;
38063806
}
38073807

3808-
export function textSpanIntersection(span1: TextSpan, span2: TextSpan) {
3808+
export function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined {
38093809
const intersectStart = Math.max(span1.start, span2.start);
38103810
const intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
38113811
if (intersectStart <= intersectEnd) {

src/server/server.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ namespace ts.server {
310310
args.push(Arguments.EnableTelemetry);
311311
}
312312
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
313-
args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
313+
args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName()!)), `ti-${process.pid}.log`));
314314
}
315315
if (this.typingSafeListLocation) {
316316
args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation);
@@ -466,7 +466,7 @@ namespace ts.server {
466466
}
467467

468468
while (this.requestQueue.length > 0) {
469-
const queuedRequest = this.requestQueue.shift();
469+
const queuedRequest = this.requestQueue.shift()!;
470470
if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) {
471471
this.requestMap.delete(queuedRequest.operationId);
472472
this.scheduleRequest(queuedRequest);
@@ -499,7 +499,7 @@ namespace ts.server {
499499
}
500500

501501
class IOSession extends Session {
502-
private eventPort: number;
502+
private eventPort: number | undefined;
503503
private eventSocket: NodeSocket | undefined;
504504
private socketEventQueue: { body: any, eventName: string }[] | undefined;
505505
private constructed: boolean | undefined;
@@ -557,7 +557,7 @@ namespace ts.server {
557557
}
558558

559559
event<T extends object>(body: T, eventName: string): void {
560-
Debug.assert(this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession");
560+
Debug.assert(!!this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession");
561561

562562
if (this.canUseEvents && this.eventPort) {
563563
if (!this.eventSocket) {
@@ -578,7 +578,7 @@ namespace ts.server {
578578
}
579579

580580
private writeToEventSocket(body: object, eventName: string): void {
581-
this.eventSocket.write(formatMessage(toEvent(eventName, body), this.logger, this.byteLength, this.host.newLine), "utf8");
581+
this.eventSocket!.write(formatMessage(toEvent(eventName, body), this.logger, this.byteLength, this.host.newLine), "utf8");
582582
}
583583

584584
exit() {

tests/baselines/reference/api/tsserverlibrary.d.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,7 @@ declare namespace ts {
28962896
interface FileWatcher {
28972897
close(): void;
28982898
}
2899-
function getNodeMajorVersion(): number;
2899+
function getNodeMajorVersion(): number | undefined;
29002900
let sys: System;
29012901
}
29022902
declare namespace ts {
@@ -2906,12 +2906,12 @@ declare namespace ts {
29062906
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
29072907
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
29082908
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
2909-
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
2909+
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined;
29102910
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
29112911
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
29122912
function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean;
29132913
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
2914-
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
2914+
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined;
29152915
function createTextSpan(start: number, length: number): TextSpan;
29162916
function createTextSpanFromBounds(start: number, end: number): TextSpan;
29172917
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
@@ -3293,8 +3293,8 @@ declare namespace ts {
32933293
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
32943294
function forEachTrailingCommentRange<U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined;
32953295
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
3296-
function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
3297-
function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
3296+
function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined;
3297+
function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined;
32983298
function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
32993299
function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
33003300
/** Optionally, get the shebang */
@@ -3797,7 +3797,7 @@ declare namespace ts {
37973797
/**
37983798
* Gets the constant value to emit for an expression.
37993799
*/
3800-
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number;
3800+
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
38013801
/**
38023802
* Sets the constant value to emit for an expression.
38033803
*/
@@ -7440,7 +7440,7 @@ declare namespace ts.server {
74407440
clear(): void;
74417441
getVersion(): number;
74427442
remove(path: Path): void;
7443-
get(path: Path): ReadonlyArray<string>;
7443+
get(path: Path): ReadonlyArray<string> | undefined;
74447444
set(path: Path, value: ReadonlyArray<string>): void;
74457445
}
74467446
interface PluginCreateInfo {
@@ -7557,7 +7557,7 @@ declare namespace ts.server {
75577557
abstract getTypeAcquisition(): TypeAcquisition;
75587558
protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition;
75597559
getExternalFiles(): SortedReadonlyArray<string>;
7560-
getSourceFile(path: Path): SourceFile;
7560+
getSourceFile(path: Path): SourceFile | undefined;
75617561
close(): void;
75627562
private detachScriptInfoIfNotRoot(uncheckedFilename);
75637563
isClosed(): boolean;
@@ -7586,8 +7586,8 @@ declare namespace ts.server {
75867586
private detachScriptInfoFromProject(uncheckedFileName);
75877587
private addMissingFileWatcher(missingFilePath);
75887588
private isWatchedMissingFile(path);
7589-
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo;
7590-
getScriptInfo(uncheckedFileName: string): ScriptInfo;
7589+
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined;
7590+
getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined;
75917591
filesToString(writeProjectFileNames: boolean): string;
75927592
setCompilerOptions(compilerOptions: CompilerOptions): void;
75937593
protected removeRoot(info: ScriptInfo): void;
@@ -7846,7 +7846,7 @@ declare namespace ts.server {
78467846
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void;
78477847
findProject(projectName: string): Project | undefined;
78487848
getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined;
7849-
getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo;
7849+
getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined;
78507850
/**
78517851
* Ensures the project structures are upto date
78527852
* This means,
@@ -7930,18 +7930,18 @@ declare namespace ts.server {
79307930
private getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath);
79317931
private getOrCreateSingleInferredProjectIfEnabled();
79327932
private createInferredProject(currentDirectory, isSingleInferredProject?, projectRootPath?);
7933-
getScriptInfo(uncheckedFileName: string): ScriptInfo;
7933+
getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined;
79347934
private watchClosedScriptInfo(info);
79357935
private stopWatchingScriptInfo(info);
79367936
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: {
79377937
fileExists(path: string): boolean;
7938-
}): ScriptInfo;
7938+
}): ScriptInfo | undefined;
79397939
private getOrCreateScriptInfoWorker(fileName, currentDirectory, openedByClient, fileContent?, scriptKind?, hasMixedContent?, hostToQueryFileExistsOn?);
79407940
/**
79417941
* This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred
79427942
*/
7943-
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo;
7944-
getScriptInfoForPath(fileName: Path): ScriptInfo;
7943+
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined;
7944+
getScriptInfoForPath(fileName: Path): ScriptInfo | undefined;
79457945
setHostConfiguration(args: protocol.ConfigureRequestArguments): void;
79467946
closeLog(): void;
79477947
/**

0 commit comments

Comments
 (0)