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.
This commit is contained in:
Daniel Rosenwasser 2022-01-20 11:33:30 -08:00 committed by GitHub
parent 6c8c829148
commit 04d77fe900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 23 additions and 23 deletions

6
package-lock.json generated
View File

@ -7686,9 +7686,9 @@
"dev": true
},
"typescript": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"version": "4.5.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true
},
"umd": {

View File

@ -93,7 +93,7 @@
"q": "latest",
"source-map-support": "latest",
"through2": "latest",
"typescript": "^4.2.3",
"typescript": "^4.5.5",
"vinyl": "latest",
"vinyl-sourcemaps-apply": "latest",
"xml2js": "^0.4.19"

View File

@ -8704,7 +8704,7 @@ namespace ts {
const isProperty = isPropertyDeclaration(declaration) || isPropertySignature(declaration);
const isOptional = includeOptionality && (
isProperty && !!(declaration as PropertyDeclaration | PropertySignature).questionToken ||
isProperty && !!declaration.questionToken ||
isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) ||
isOptionalJSDocPropertyLikeTag(declaration));
@ -27886,7 +27886,7 @@ namespace ts {
const isNodeOpeningLikeElement = isJsxOpeningLikeElement(node);
if (isNodeOpeningLikeElement) {
checkGrammarJsxElement(node as JsxOpeningLikeElement);
checkGrammarJsxElement(node);
}
checkJsxPreconditions(node);
@ -27896,7 +27896,7 @@ namespace ts {
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
const jsxFactoryNamespace = getJsxNamespace(node);
const jsxFactoryLocation = isNodeOpeningLikeElement ? (node as JsxOpeningLikeElement).tagName : node;
const jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
// allow null as jsxFragmentFactory
let jsxFactorySym: Symbol | undefined;
@ -27926,9 +27926,9 @@ namespace ts {
}
if (isNodeOpeningLikeElement) {
const jsxOpeningLikeNode = node as JsxOpeningLikeElement;
const jsxOpeningLikeNode = node ;
const sig = getResolvedSignature(jsxOpeningLikeNode);
checkDeprecatedSignature(sig, node as JsxOpeningLikeElement);
checkDeprecatedSignature(sig, node);
checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
}
}
@ -36988,7 +36988,7 @@ namespace ts {
// Don't validate for-in initializer as it is already an error
const widenedType = getWidenedTypeForVariableLikeDeclaration(node);
if (needCheckInitializer) {
const initializerType = checkExpressionCached(node.initializer!);
const initializerType = checkExpressionCached(node.initializer);
if (strictNullChecks && needCheckWidenedType) {
checkNonNullNonVoidType(initializerType, node);
}

View File

@ -3156,7 +3156,7 @@ namespace ts {
if (isCompilerOptionsValue(opt, value)) {
const optType = opt.type;
if (optType === "list" && isArray(value)) {
return convertJsonOptionOfListType(opt as CommandLineOptionOfListType, value, basePath, errors);
return convertJsonOptionOfListType(opt , value, basePath, errors);
}
else if (!isString(optType)) {
return convertJsonOptionOfCustomType(opt as CommandLineOptionOfCustomType, value as string, errors);

View File

@ -654,7 +654,7 @@ namespace ts {
if (text === undefined) {
const parseNode = getParseTreeNode(this);
const sourceFile = parseNode && getSourceFileOfNode(parseNode);
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode!, includeTrivia) : "";
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
map?.set(this, text);
}
return text;

View File

@ -1051,7 +1051,7 @@ namespace ts {
writeLine();
const pos = writer.getTextPos();
const savedSections = bundleFileInfo && bundleFileInfo.sections;
if (savedSections) bundleFileInfo!.sections = [];
if (savedSections) bundleFileInfo.sections = [];
print(EmitHint.Unspecified, prepend, /*sourceFile*/ undefined);
if (bundleFileInfo) {
const newSections = bundleFileInfo.sections;

View File

@ -977,7 +977,7 @@ namespace ts {
perFolderCache.set(moduleName, resolutionMode, result);
if (!isExternalModuleNameRelative(moduleName)) {
// put result in per-module name cache
cache!.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
}
}
}

View File

@ -878,7 +878,7 @@ namespace ts {
}
if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input as DeclarationDiagnosticProducing);
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input);
}
if (isTypeQueryNode(input)) {
@ -1073,7 +1073,7 @@ namespace ts {
function cleanup<T extends Node>(returnValue: T | undefined): T | undefined {
if (returnValue && canProduceDiagnostic && hasDynamicName(input as Declaration)) {
checkName(input as DeclarationDiagnosticProducing);
checkName(input);
}
if (isEnclosingDeclaration(input)) {
enclosingDeclaration = previousEnclosingDeclaration;

View File

@ -528,7 +528,7 @@ namespace ts {
inHasLexicalThisContext(),
hasLexicalArguments,
promiseConstructor,
transformAsyncFunctionBodyWorker(node.body!)
transformAsyncFunctionBodyWorker(node.body)
);
const declarations = endLexicalEnvironment();

View File

@ -2260,7 +2260,7 @@ namespace ts {
const e = isBinaryExpression(initializer)
&& (initializer.operatorToken.kind === SyntaxKind.BarBarToken || initializer.operatorToken.kind === SyntaxKind.QuestionQuestionToken)
&& getExpandoInitializer(initializer.right, isPrototypeAssignment);
if (e && isSameEntityName(name, (initializer as BinaryExpression).left)) {
if (e && isSameEntityName(name, initializer.left)) {
return e;
}
}

View File

@ -2257,7 +2257,7 @@ namespace ts.Completions {
const attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes);
if (!attrsType) return GlobalsSearch.Continue;
const completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, ContextFlags.Completions);
symbols = concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer!.attributes, typeChecker), jsxContainer!.attributes.properties));
symbols = concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties));
setSortTextToOptionalMember();
completionKind = CompletionKind.MemberLike;
isNewIdentifierLocation = false;
@ -3587,8 +3587,8 @@ namespace ts.Completions {
export function getPropertiesForObjectExpression(contextualType: Type, completionsType: Type | undefined, obj: ObjectLiteralExpression | JsxAttributes, checker: TypeChecker): Symbol[] {
const hasCompletionsType = completionsType && completionsType !== contextualType;
const type = hasCompletionsType && !(completionsType!.flags & TypeFlags.AnyOrUnknown)
? checker.getUnionType([contextualType, completionsType!])
const type = hasCompletionsType && !(completionsType.flags & TypeFlags.AnyOrUnknown)
? checker.getUnionType([contextualType, completionsType])
: contextualType;
const properties = getApparentProperties(type, obj, checker);

View File

@ -1276,7 +1276,7 @@ namespace ts.FindAllReferences {
- But if the parent has `export as namespace`, the symbol is globally visible through that namespace.
*/
const exposedByParent = parent && !(symbol.flags & SymbolFlags.TypeParameter);
if (exposedByParent && !(isExternalModuleSymbol(parent!) && !parent!.globalExports)) {
if (exposedByParent && !(isExternalModuleSymbol(parent) && !parent.globalExports)) {
return undefined;
}

View File

@ -130,7 +130,7 @@ namespace ts.NavigateTo {
textSpan: createTextSpanFromNode(declaration),
// TODO(jfreeman): What should be the containerName when the container has a computed name?
containerName: containerName ? (containerName as Identifier).text : "",
containerKind: containerName ? getNodeKind(container!) : ScriptElementKind.unknown, // TODO: GH#18217 Just use `container ? ...`
containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown,
};
}
}