-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Handle missing registry entries #24596
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
Handle missing registry entries #24596
Conversation
src/services/jsTyping.ts
Outdated
@@ -160,7 +160,7 @@ namespace ts.JsTyping { | |||
} | |||
// Add the cached typing locations for inferred typings that are already installed | |||
packageNameToTypingLocation.forEach((typing, name) => { | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name)!)) { | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && typesRegistry.has(name) && isTypingUpToDate(typing, typesRegistry.get(name)!)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Better to .get()
once and check against undefined, instead of using has()
(in the usual case where a map shouldn't contain undefined
values)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/services/jsTyping.ts
Outdated
@@ -160,7 +160,8 @@ namespace ts.JsTyping { | |||
} | |||
// Add the cached typing locations for inferred typings that are already installed | |||
packageNameToTypingLocation.forEach((typing, name) => { | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && typesRegistry.has(name) && isTypingUpToDate(typing, typesRegistry.get(name)!)) { | |||
const registryEntry = typesRegistry.get(name); | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, typesRegistry.get(name)!)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to replace the second typesRegistry.get
with registryEntry
src/services/jsTyping.ts
Outdated
@@ -160,7 +160,8 @@ namespace ts.JsTyping { | |||
} | |||
// Add the cached typing locations for inferred typings that are already installed | |||
packageNameToTypingLocation.forEach((typing, name) => { | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name)!)) { | |||
const registryEntry = typesRegistry.get(name); | |||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry!)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not think u need the null assertion now.
Currently, if a previously installed ATA package is removed from the types-registry, we throw an exception when trying to determine whether to update it on typings install.
This PR fixes that issue by reporting the package as not cached, and then appropriately does not attempt to install it (due to it being missing from the registry).