Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 10, 2025
1 parent 99178d7 commit 9048b0c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions release/core/publish/steps/generate-tarballs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,34 @@ async function convertTypesToModules(pkg: Package, subdir: 'unstable-preview-typ
}
}

function exposeTypes(pkg: Package, subdir: 'unstable-preview-types' | 'preview-types' | 'types') {
if (pkg.pkgData.exports) {
/**
* Allows tsconfig.json#compilerOptions#types to use import paths,
* rather than file paths (there are no file path guarantees for any given package manager)
*/
pkg.pkgData.exports[`./${subdir}`] = {
/**
* No default, import, or require here, because there are no actual modules to import.
*/
types: `./${subdir}/index.d.ts`,
};

/**
* For older tsconfig.json settings
*/
pkg.pkgData.typesVersions = {
// very loose TS version
'*': {
[subdir]: [`./${subdir}`],
},
};
}
}

async function makeTypesAlpha(pkg: Package) {
scrubTypesFromExports(pkg);
exposeTypes(pkg, 'unstable-preview-types');

// enforce that the correct types directory is present
const present = new Set(pkg.pkgData.files);
Expand All @@ -331,6 +357,7 @@ async function makeTypesAlpha(pkg: Package) {

async function makeTypesBeta(pkg: Package) {
scrubTypesFromExports(pkg);
exposeTypes(pkg, 'preview-types');

// enforce that the correct types directory is present
const present = new Set(pkg.pkgData.files);
Expand Down
1 change: 1 addition & 0 deletions release/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type PACKAGEJSON = {
scripts?: Record<string, string>;
files?: string[];
exports?: ExportConfig;
typesVersions?: { [tsVersion: string]: { [relativeImportPath: string]: string[] } };
'ember-addon'?: {
main?: 'addon-main.js';
type?: 'addon';
Expand Down

0 comments on commit 9048b0c

Please sign in to comment.