Skip to content

Commit 04d77fe

Browse files
Update to TypeScript 4.5.5, fix semantic lints. (#47529)
* Update to TypeScript 4.5.5, fix semantic lints. * Remove extra parens. * Remove now-outdated non-null comment around #18217.
1 parent 6c8c829 commit 04d77fe

13 files changed

+23
-23
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"q": "latest",
9494
"source-map-support": "latest",
9595
"through2": "latest",
96-
"typescript": "^4.2.3",
96+
"typescript": "^4.5.5",
9797
"vinyl": "latest",
9898
"vinyl-sourcemaps-apply": "latest",
9999
"xml2js": "^0.4.19"

src/compiler/checker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8704,7 +8704,7 @@ namespace ts {
87048704

87058705
const isProperty = isPropertyDeclaration(declaration) || isPropertySignature(declaration);
87068706
const isOptional = includeOptionality && (
8707-
isProperty && !!(declaration as PropertyDeclaration | PropertySignature).questionToken ||
8707+
isProperty && !!declaration.questionToken ||
87088708
isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) ||
87098709
isOptionalJSDocPropertyLikeTag(declaration));
87108710

@@ -27886,7 +27886,7 @@ namespace ts {
2788627886
const isNodeOpeningLikeElement = isJsxOpeningLikeElement(node);
2788727887

2788827888
if (isNodeOpeningLikeElement) {
27889-
checkGrammarJsxElement(node as JsxOpeningLikeElement);
27889+
checkGrammarJsxElement(node);
2789027890
}
2789127891

2789227892
checkJsxPreconditions(node);
@@ -27896,7 +27896,7 @@ namespace ts {
2789627896
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
2789727897
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
2789827898
const jsxFactoryNamespace = getJsxNamespace(node);
27899-
const jsxFactoryLocation = isNodeOpeningLikeElement ? (node as JsxOpeningLikeElement).tagName : node;
27899+
const jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
2790027900

2790127901
// allow null as jsxFragmentFactory
2790227902
let jsxFactorySym: Symbol | undefined;
@@ -27926,9 +27926,9 @@ namespace ts {
2792627926
}
2792727927

2792827928
if (isNodeOpeningLikeElement) {
27929-
const jsxOpeningLikeNode = node as JsxOpeningLikeElement;
27929+
const jsxOpeningLikeNode = node ;
2793027930
const sig = getResolvedSignature(jsxOpeningLikeNode);
27931-
checkDeprecatedSignature(sig, node as JsxOpeningLikeElement);
27931+
checkDeprecatedSignature(sig, node);
2793227932
checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
2793327933
}
2793427934
}
@@ -36988,7 +36988,7 @@ namespace ts {
3698836988
// Don't validate for-in initializer as it is already an error
3698936989
const widenedType = getWidenedTypeForVariableLikeDeclaration(node);
3699036990
if (needCheckInitializer) {
36991-
const initializerType = checkExpressionCached(node.initializer!);
36991+
const initializerType = checkExpressionCached(node.initializer);
3699236992
if (strictNullChecks && needCheckWidenedType) {
3699336993
checkNonNullNonVoidType(initializerType, node);
3699436994
}

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3156,7 +3156,7 @@ namespace ts {
31563156
if (isCompilerOptionsValue(opt, value)) {
31573157
const optType = opt.type;
31583158
if (optType === "list" && isArray(value)) {
3159-
return convertJsonOptionOfListType(opt as CommandLineOptionOfListType, value, basePath, errors);
3159+
return convertJsonOptionOfListType(opt , value, basePath, errors);
31603160
}
31613161
else if (!isString(optType)) {
31623162
return convertJsonOptionOfCustomType(opt as CommandLineOptionOfCustomType, value as string, errors);

src/compiler/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ namespace ts {
654654
if (text === undefined) {
655655
const parseNode = getParseTreeNode(this);
656656
const sourceFile = parseNode && getSourceFileOfNode(parseNode);
657-
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode!, includeTrivia) : "";
657+
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
658658
map?.set(this, text);
659659
}
660660
return text;

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ namespace ts {
10511051
writeLine();
10521052
const pos = writer.getTextPos();
10531053
const savedSections = bundleFileInfo && bundleFileInfo.sections;
1054-
if (savedSections) bundleFileInfo!.sections = [];
1054+
if (savedSections) bundleFileInfo.sections = [];
10551055
print(EmitHint.Unspecified, prepend, /*sourceFile*/ undefined);
10561056
if (bundleFileInfo) {
10571057
const newSections = bundleFileInfo.sections;

src/compiler/moduleNameResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ namespace ts {
977977
perFolderCache.set(moduleName, resolutionMode, result);
978978
if (!isExternalModuleNameRelative(moduleName)) {
979979
// put result in per-module name cache
980-
cache!.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
980+
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
981981
}
982982
}
983983
}

src/compiler/transformers/declarations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ namespace ts {
878878
}
879879

880880
if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
881-
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input as DeclarationDiagnosticProducing);
881+
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input);
882882
}
883883

884884
if (isTypeQueryNode(input)) {
@@ -1073,7 +1073,7 @@ namespace ts {
10731073

10741074
function cleanup<T extends Node>(returnValue: T | undefined): T | undefined {
10751075
if (returnValue && canProduceDiagnostic && hasDynamicName(input as Declaration)) {
1076-
checkName(input as DeclarationDiagnosticProducing);
1076+
checkName(input);
10771077
}
10781078
if (isEnclosingDeclaration(input)) {
10791079
enclosingDeclaration = previousEnclosingDeclaration;

src/compiler/transformers/es2017.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ namespace ts {
528528
inHasLexicalThisContext(),
529529
hasLexicalArguments,
530530
promiseConstructor,
531-
transformAsyncFunctionBodyWorker(node.body!)
531+
transformAsyncFunctionBodyWorker(node.body)
532532
);
533533

534534
const declarations = endLexicalEnvironment();

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ namespace ts {
22602260
const e = isBinaryExpression(initializer)
22612261
&& (initializer.operatorToken.kind === SyntaxKind.BarBarToken || initializer.operatorToken.kind === SyntaxKind.QuestionQuestionToken)
22622262
&& getExpandoInitializer(initializer.right, isPrototypeAssignment);
2263-
if (e && isSameEntityName(name, (initializer as BinaryExpression).left)) {
2263+
if (e && isSameEntityName(name, initializer.left)) {
22642264
return e;
22652265
}
22662266
}

src/services/completions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ namespace ts.Completions {
22572257
const attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes);
22582258
if (!attrsType) return GlobalsSearch.Continue;
22592259
const completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, ContextFlags.Completions);
2260-
symbols = concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer!.attributes, typeChecker), jsxContainer!.attributes.properties));
2260+
symbols = concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties));
22612261
setSortTextToOptionalMember();
22622262
completionKind = CompletionKind.MemberLike;
22632263
isNewIdentifierLocation = false;
@@ -3587,8 +3587,8 @@ namespace ts.Completions {
35873587

35883588
export function getPropertiesForObjectExpression(contextualType: Type, completionsType: Type | undefined, obj: ObjectLiteralExpression | JsxAttributes, checker: TypeChecker): Symbol[] {
35893589
const hasCompletionsType = completionsType && completionsType !== contextualType;
3590-
const type = hasCompletionsType && !(completionsType!.flags & TypeFlags.AnyOrUnknown)
3591-
? checker.getUnionType([contextualType, completionsType!])
3590+
const type = hasCompletionsType && !(completionsType.flags & TypeFlags.AnyOrUnknown)
3591+
? checker.getUnionType([contextualType, completionsType])
35923592
: contextualType;
35933593

35943594
const properties = getApparentProperties(type, obj, checker);

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ namespace ts.FindAllReferences {
12761276
- But if the parent has `export as namespace`, the symbol is globally visible through that namespace.
12771277
*/
12781278
const exposedByParent = parent && !(symbol.flags & SymbolFlags.TypeParameter);
1279-
if (exposedByParent && !(isExternalModuleSymbol(parent!) && !parent!.globalExports)) {
1279+
if (exposedByParent && !(isExternalModuleSymbol(parent) && !parent.globalExports)) {
12801280
return undefined;
12811281
}
12821282

src/services/navigateTo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace ts.NavigateTo {
130130
textSpan: createTextSpanFromNode(declaration),
131131
// TODO(jfreeman): What should be the containerName when the container has a computed name?
132132
containerName: containerName ? (containerName as Identifier).text : "",
133-
containerKind: containerName ? getNodeKind(container!) : ScriptElementKind.unknown, // TODO: GH#18217 Just use `container ? ...`
133+
containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown,
134134
};
135135
}
136136
}

0 commit comments

Comments
 (0)