Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to TypeScript 4.5.5, fix semantic lints. #47529

Merged
merged 3 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8703,7 +8703,7 @@ namespace ts {

const isProperty = isPropertyDeclaration(declaration) || isPropertySignature(declaration);
const isOptional = includeOptionality && (
isProperty && !!(declaration as PropertyDeclaration | PropertySignature).questionToken ||
isProperty && !!declaration.questionToken ||
jakebailey marked this conversation as resolved.
Show resolved Hide resolved
isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) ||
isOptionalJSDocPropertyLikeTag(declaration));

Expand Down Expand Up @@ -27885,7 +27885,7 @@ namespace ts {
const isNodeOpeningLikeElement = isJsxOpeningLikeElement(node);

if (isNodeOpeningLikeElement) {
checkGrammarJsxElement(node as JsxOpeningLikeElement);
checkGrammarJsxElement(node);
}

checkJsxPreconditions(node);
Expand All @@ -27895,7 +27895,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;
jakebailey marked this conversation as resolved.
Show resolved Hide resolved

// allow null as jsxFragmentFactory
let jsxFactorySym: Symbol | undefined;
Expand Down Expand Up @@ -27925,9 +27925,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);
}
}
Expand Down Expand Up @@ -36962,7 +36962,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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ namespace ts {
}

if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input as DeclarationDiagnosticProducing);
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input);
}

if (isTypeQueryNode(input)) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/es2017.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ namespace ts {
inHasLexicalThisContext(),
hasLexicalArguments,
promiseConstructor,
transformAsyncFunctionBodyWorker(node.body!)
transformAsyncFunctionBodyWorker(node.body)
);

const declarations = endLexicalEnvironment();
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,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;
Expand Down Expand Up @@ -3575,8 +3575,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);
Expand Down
2 changes: 1 addition & 1 deletion src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/navigateTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}