Skip to content

Commit 8766bdd

Browse files
fix(ts): Publish downleveled TS3.8 types, fix types path (#8954)
1 parent 6643671 commit 8766bdd

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
!/cjs/**/*
77
!/esm/**/*
88
!/types/**/*
9+
!/types-ts3.8/**/*

packages/gatsby/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
!/cjs/**/*
77
!/esm/**/*
88
!/types/**/*
9+
!/types-ts3.8/**/*
910

1011
# Gatsby specific
1112
!gatsby-browser.js

scripts/prepack.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ const buildDir = packageWithBundles ? NPM_BUILD_DIR : BUILD_DIR;
2323

2424
type PackageJsonEntryPoints = Record<typeof ENTRY_POINTS[number], string>;
2525

26+
interface TypeVersions {
27+
[key: string]: {
28+
[key: string]: string[];
29+
};
30+
};
31+
2632
interface PackageJson extends Record<string, unknown>, PackageJsonEntryPoints {
2733
[EXPORT_MAP_ENTRY_POINT]: {
2834
[key: string]: {
@@ -31,11 +37,7 @@ interface PackageJson extends Record<string, unknown>, PackageJsonEntryPoints {
3137
types: string;
3238
};
3339
};
34-
[TYPES_VERSIONS_ENTRY_POINT]: {
35-
[key: string]: {
36-
[key: string]: string[];
37-
};
38-
};
40+
[TYPES_VERSIONS_ENTRY_POINT]: TypeVersions;
3941
}
4042

4143
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -81,7 +83,8 @@ if (newPkgJson[EXPORT_MAP_ENTRY_POINT]) {
8183
if (newPkgJson[TYPES_VERSIONS_ENTRY_POINT]) {
8284
Object.entries(newPkgJson[TYPES_VERSIONS_ENTRY_POINT]).forEach(([key, val]) => {
8385
newPkgJson[TYPES_VERSIONS_ENTRY_POINT][key] = Object.entries(val).reduce((acc, [key, val]) => {
84-
return { ...acc, [key]: val.map(v => v.replace(`${buildDir}/`, '')) };
86+
const newKey = key.replace(`${buildDir}/`, '');
87+
return { ...acc, [newKey]: val.map(v => v.replace(`${buildDir}/`, '')) };
8588
}, {});
8689
});
8790
}

0 commit comments

Comments
 (0)