Skip to content

Commit 4650c81

Browse files
committed
Reenable other good lints to do with null assertion
1 parent ba00330 commit 4650c81

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
"@typescript-eslint/type-annotation-spacing": "error",
8383
"@typescript-eslint/unified-signatures": "error",
8484

85-
"@typescript-eslint/no-extra-non-null-assertion": "off", // TODO(jakebailey): reenable
86-
"@typescript-eslint/no-non-null-asserted-optional-chain": "off", // TODO(jakebailey): reenable
85+
"@typescript-eslint/no-extra-non-null-assertion": "error",
86+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
8787

8888
// scripts/eslint/rules
8989
"local/object-literal-surrounding-space": "error",

src/compiler/binder.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,8 +3041,11 @@ namespace ts {
30413041
return;
30423042
}
30433043
const rootExpr = getLeftmostAccessExpression(node.left);
3044-
if (isIdentifier(rootExpr) && lookupSymbolForName(container, rootExpr.escapedText)!?.flags & SymbolFlags.Alias) {
3045-
return;
3044+
if (isIdentifier(rootExpr)) {
3045+
const symbol = lookupSymbolForName(container, rootExpr.escapedText);
3046+
if (symbol && symbol.flags & SymbolFlags.Alias) {
3047+
return;
3048+
}
30463049
}
30473050
// Fix up parent pointers since we're going to use these nodes before we bind into them
30483051
setParent(node.left, node);
@@ -3074,7 +3077,7 @@ namespace ts {
30743077
}
30753078

30763079
function bindPotentiallyMissingNamespaces(namespaceSymbol: Symbol | undefined, entityName: BindableStaticNameExpression, isToplevel: boolean, isPrototypeProperty: boolean, containerIsClass: boolean) {
3077-
if (namespaceSymbol?.flags! & SymbolFlags.Alias) {
3080+
if (namespaceSymbol && namespaceSymbol.flags & SymbolFlags.Alias) {
30783081
return namespaceSymbol;
30793082
}
30803083
if (isToplevel && !isPrototypeProperty) {

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5837,8 +5837,8 @@ namespace ts {
58375837
}
58385838

58395839
function preserveCommentsOn<T extends Node>(node: T) {
5840-
if (some(propertySymbol.declarations, d => d.kind === SyntaxKind.JSDocPropertyTag)) {
5841-
const d = propertySymbol.declarations?.find(d => d.kind === SyntaxKind.JSDocPropertyTag)! as JSDocPropertyTag;
5840+
const d = propertySymbol.declarations?.find(d => d.kind === SyntaxKind.JSDocPropertyTag) as JSDocPropertyTag | undefined;
5841+
if (d) {
58425842
const commentText = getTextOfJSDocComment(d.comment);
58435843
if (commentText) {
58445844
setSyntheticLeadingComments(node, [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);

src/compiler/transformers/declarations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ namespace ts {
218218
}
219219

220220
function reportNonlocalAugmentation(containingFile: SourceFile, parentSymbol: Symbol, symbol: Symbol) {
221-
const primaryDeclaration = parentSymbol.declarations?.find(d => getSourceFileOfNode(d) === containingFile)!;
221+
const primaryDeclaration = parentSymbol.declarations?.find(d => getSourceFileOfNode(d) === containingFile);
222222
const augmentingDeclarations = filter(symbol.declarations, d => getSourceFileOfNode(d) !== containingFile);
223-
if (augmentingDeclarations) {
223+
if (primaryDeclaration && augmentingDeclarations) {
224224
for (const augmentations of augmentingDeclarations) {
225225
context.addDiagnostic(addRelatedInfo(
226226
createDiagnosticForNode(augmentations, Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized),

0 commit comments

Comments
 (0)