MCPcopy Index your code
hub / github.com/nodejs/node / getImpliedTypeFromTypeofGuard

Function getImpliedTypeFromTypeofGuard

test/fixtures/snapshot/typescript.js:71104–71113  ·  view source on GitHub ↗
(type, text)

Source from the content-addressed store, hash-verified

71102 return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]);
71103 }
71104 function getImpliedTypeFromTypeofGuard(type, text) {
71105 switch (text) {
71106 case "function":
71107 return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType;
71108 case "object":
71109 return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71110 default:
71111 return typeofTypesByName.get(text);
71112 }
71113 }
71114 // When narrowing a union type by a `typeof` guard using type-facts alone, constituent types that are
71115 // super-types of the implied guard will be retained in the final type: this is because type-facts only
71116 // filter. Instead, we would like to replace those union constituents with the more precise type implied by

Callers 2

narrowTypeByTypeofFunction · 0.85
narrowBySwitchOnTypeOfFunction · 0.85

Calls 2

getUnionTypeFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…