(moduleSpecifier, importKind, useRequire, addAsTypeOnly)
| 152994 | return Math.max(prevValue !== null && prevValue !== void 0 ? prevValue : 0, newValue); |
| 152995 | } |
| 152996 | function getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly) { |
| 152997 | // A default import that requires type-only makes the whole import type-only. |
| 152998 | // (We could add `default` as a named import, but that style seems undesirable.) |
| 152999 | // Under `--preserveValueImports` and `--importsNotUsedAsValues=error`, if a |
| 153000 | // module default-exports a type but named-exports some values (weird), you would |
| 153001 | // have to use a type-only default import and non-type-only named imports. These |
| 153002 | // require two separate import declarations, so we build this into the map key. |
| 153003 | var typeOnlyKey = newImportsKey(moduleSpecifier, /*topLevelTypeOnly*/ true); |
| 153004 | var nonTypeOnlyKey = newImportsKey(moduleSpecifier, /*topLevelTypeOnly*/ false); |
| 153005 | var typeOnlyEntry = newImports.get(typeOnlyKey); |
| 153006 | var nonTypeOnlyEntry = newImports.get(nonTypeOnlyKey); |
| 153007 | var newEntry = { |
| 153008 | defaultImport: undefined, |
| 153009 | namedImports: undefined, |
| 153010 | namespaceLikeImport: undefined, |
| 153011 | useRequire: useRequire |
| 153012 | }; |
| 153013 | if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { |
| 153014 | if (typeOnlyEntry) |
| 153015 | return typeOnlyEntry; |
| 153016 | newImports.set(typeOnlyKey, newEntry); |
| 153017 | return newEntry; |
| 153018 | } |
| 153019 | if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { |
| 153020 | return (typeOnlyEntry || nonTypeOnlyEntry); |
| 153021 | } |
| 153022 | if (nonTypeOnlyEntry) { |
| 153023 | return nonTypeOnlyEntry; |
| 153024 | } |
| 153025 | newImports.set(nonTypeOnlyKey, newEntry); |
| 153026 | return newEntry; |
| 153027 | } |
| 153028 | function newImportsKey(moduleSpecifier, topLevelTypeOnly) { |
| 153029 | return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); |
| 153030 | } |
no test coverage detected