diff --git a/.npmignore b/.npmignore index cb864514088e..6cf3cd53d7e6 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,4 @@ !/cjs/**/* !/esm/**/* !/types/**/* +!/types-ts3.8/**/* diff --git a/packages/gatsby/.npmignore b/packages/gatsby/.npmignore index 35348e6a718d..05a81b2542dd 100644 --- a/packages/gatsby/.npmignore +++ b/packages/gatsby/.npmignore @@ -6,6 +6,7 @@ !/cjs/**/* !/esm/**/* !/types/**/* +!/types-ts3.8/**/* # Gatsby specific !gatsby-browser.js diff --git a/scripts/prepack.ts b/scripts/prepack.ts index bcad9dee0ef8..0c810f3e9030 100644 --- a/scripts/prepack.ts +++ b/scripts/prepack.ts @@ -23,6 +23,12 @@ const buildDir = packageWithBundles ? NPM_BUILD_DIR : BUILD_DIR; type PackageJsonEntryPoints = Record; +interface TypeVersions { + [key: string]: { + [key: string]: string[]; + }; +}; + interface PackageJson extends Record, PackageJsonEntryPoints { [EXPORT_MAP_ENTRY_POINT]: { [key: string]: { @@ -31,11 +37,7 @@ interface PackageJson extends Record, PackageJsonEntryPoints { types: string; }; }; - [TYPES_VERSIONS_ENTRY_POINT]: { - [key: string]: { - [key: string]: string[]; - }; - }; + [TYPES_VERSIONS_ENTRY_POINT]: TypeVersions; } // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -81,7 +83,8 @@ if (newPkgJson[EXPORT_MAP_ENTRY_POINT]) { if (newPkgJson[TYPES_VERSIONS_ENTRY_POINT]) { Object.entries(newPkgJson[TYPES_VERSIONS_ENTRY_POINT]).forEach(([key, val]) => { newPkgJson[TYPES_VERSIONS_ENTRY_POINT][key] = Object.entries(val).reduce((acc, [key, val]) => { - return { ...acc, [key]: val.map(v => v.replace(`${buildDir}/`, '')) }; + const newKey = key.replace(`${buildDir}/`, ''); + return { ...acc, [newKey]: val.map(v => v.replace(`${buildDir}/`, '')) }; }, {}); }); }