mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks' * Fix API baselines * Make sys.getEnvironmentVariable non-nullable * make properties optional instead of using `| undefined` in thier type * reportDiagnostics should be required * Declare firstAccessor as non-nullable * Make `some` a type guard * Fix `getEnvironmentVariable` definition in tests * Pretend transformFlags are always defined * Fix one more use of sys.getEnvironmentVariable * `requiredResponse` accepts undefined, remove assertions * Mark optional properties as optional instead of using `| undefined` * Mark optional properties as optional instead of using ` | undefined` * Remove unnecessary null assertions * Put the bang on the declaration instead of every use * Make `createMapFromTemplate` require a parameter * Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional * Plumb through undefined in emitLsit and EmitExpressionList * `ElementAccessExpression.argumentExpression` can not be `undefined` * Add overloads for `writeTokenText` * Make `shouldWriteSeparatingLineTerminator` argument non-nullable * Make `synthesizedNodeStartsOnNewLine` argument required * `PropertyAssignment.initializer` cannot be undefined * Use one `!` at declaration site instead of on every use site * Capture host in a constant and avoid null assertions * Remove few more unused assertions * Update baselines * Use parameter defaults * Update baselines * Fix lint * Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions * Make Node#symbol and Type#symbol non-optional to reduce assertions * Make `flags` non-nullable to reduce assertions * Convert some asserts to type guards * Make `isNonLocalAlias` a type guard * Add overload for `getSymbolOfNode` for `Declaration` * Some more `getSymbolOfNode` changes * Push undefined suppression into `typeToTypeNodeHelper` * `NodeBuilderContext.tracker` is never `undefined` * use `Debug.assertDefined` * Remove unnecessary tag * Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
This commit is contained in:
@@ -55,7 +55,7 @@ namespace ts.server {
|
||||
this.stack = [this.lineIndex.root];
|
||||
}
|
||||
|
||||
insertLines(insertedText: string, suppressTrailingText: boolean) {
|
||||
insertLines(insertedText: string | undefined, suppressTrailingText: boolean) {
|
||||
if (suppressTrailingText) {
|
||||
this.trailingText = "";
|
||||
}
|
||||
@@ -72,8 +72,8 @@ namespace ts.server {
|
||||
lines.pop();
|
||||
}
|
||||
}
|
||||
let branchParent: LineNode;
|
||||
let lastZeroCount: LineCollection;
|
||||
let branchParent: LineNode | undefined;
|
||||
let lastZeroCount: LineCollection | undefined;
|
||||
|
||||
for (let k = this.endBranch.length - 1; k >= 0; k--) {
|
||||
(<LineNode>this.endBranch[k]).updateCounts();
|
||||
@@ -88,7 +88,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
if (lastZeroCount) {
|
||||
branchParent.remove(lastZeroCount);
|
||||
branchParent!.remove(lastZeroCount);
|
||||
}
|
||||
|
||||
// path at least length two (root and leaf)
|
||||
@@ -159,7 +159,7 @@ namespace ts.server {
|
||||
this.lineCollectionAtBranch = lineCollection;
|
||||
}
|
||||
|
||||
let child: LineCollection;
|
||||
let child: LineCollection | undefined;
|
||||
function fresh(node: LineCollection): LineCollection {
|
||||
if (node.isLeaf()) {
|
||||
return new LineLeaf("");
|
||||
@@ -332,7 +332,7 @@ namespace ts.server {
|
||||
if (oldVersion >= this.minVersion) {
|
||||
const textChangeRanges: TextChangeRange[] = [];
|
||||
for (let i = oldVersion + 1; i <= newVersion; i++) {
|
||||
const snap = this.versions[this.versionToIndex(i)];
|
||||
const snap = this.versions[this.versionToIndex(i)!]; // TODO: GH#18217
|
||||
for (const textChange of snap.changesSincePreviousVersion) {
|
||||
textChangeRanges.push(textChange.getTextChangeRange());
|
||||
}
|
||||
@@ -370,7 +370,7 @@ namespace ts.server {
|
||||
return this.index.getLength();
|
||||
}
|
||||
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined {
|
||||
if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) {
|
||||
if (this.version <= oldSnapshot.version) {
|
||||
return unchangedTextChangeRange;
|
||||
@@ -397,7 +397,7 @@ namespace ts.server {
|
||||
return { line: oneBasedLine, offset: zeroBasedColumn + 1 };
|
||||
}
|
||||
|
||||
private positionToColumnAndLineText(position: number): { zeroBasedColumn: number, lineText: string } {
|
||||
private positionToColumnAndLineText(position: number): { zeroBasedColumn: number, lineText: string | undefined } {
|
||||
return this.root.charOffsetToLineInfo(1, position);
|
||||
}
|
||||
|
||||
@@ -471,9 +471,10 @@ namespace ts.server {
|
||||
this.load(LineIndex.linesFromText(newText).lines);
|
||||
return this;
|
||||
}
|
||||
return undefined!; // TODO: GH#18217
|
||||
}
|
||||
else {
|
||||
let checkText: string;
|
||||
let checkText: string | undefined;
|
||||
if (this.checkEdits) {
|
||||
const source = this.getText(0, this.root.charCount());
|
||||
checkText = source.slice(0, pos) + newText + source.slice(pos + deleteLength);
|
||||
@@ -499,7 +500,7 @@ namespace ts.server {
|
||||
const { zeroBasedColumn, lineText } = this.positionToColumnAndLineText(e);
|
||||
if (zeroBasedColumn === 0) {
|
||||
// move range end just past line that will merge with previous line
|
||||
deleteLength += lineText.length;
|
||||
deleteLength += lineText!.length; // TODO: GH#18217
|
||||
// store text by appending to end of insertedText
|
||||
newText = newText ? newText + lineText : lineText;
|
||||
}
|
||||
@@ -700,7 +701,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private splitAfter(childIndex: number) {
|
||||
let splitNode: LineNode;
|
||||
let splitNode: LineNode | undefined;
|
||||
const clen = this.children.length;
|
||||
childIndex++;
|
||||
const endLength = childIndex;
|
||||
|
||||
Reference in New Issue
Block a user