-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 2.9
Search Terms:
Control flow, recursive functions, used before its declaration.
Code
Live in the wild
https://github.com/webpack/webpack/blob/8498fc091e5375c7c41630723e8fa7916fcc1511/lib/util/cachedMerge.js#L1
const mergeCache = new WeakMap();
function cachedMerge(first, ...args) {
if (args.length === 0) return first;
if (args.length > 1) {
return cachedMerge(first, cachedMerge(...args));
}
const second = args[0];
let innerCache = mergeCache.get(first);
if (innerCache === undefined) {
innerCache = new WeakMap();
mergeCache.set(first, innerCache);
}
const cachedMerge = innerCache.get(second);
if (cachedMerge !== undefined) return cachedMerge;
const newMerge = Object.assign({}, first, second);
innerCache.set(second, newMerge);
return newMerge;
};Expected behavior:
No Error
Actual behavior:
lib/util/cachedMerge.js:12:10 - error TS2448: Block-scoped variable 'cachedMerge' used before its declaration.
12 return cachedMerge(first, cachedMerge(...args));
~~~~~~~~~~~
lib/util/cachedMerge.js:12:29 - error TS2448: Block-scoped variable 'cachedMerge' used before its declaration.
12 return cachedMerge(first, cachedMerge(...args));
~~~~~~~~~~~
Related Issues:
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug