Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(package-json): make Imports object properties optional in PackageJson #551

Merged
merged 1 commit into from Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/package-json.d.ts
Expand Up @@ -240,7 +240,7 @@ declare namespace PackageJson {
Import map entries of a module, optionally with conditions.
*/
export type Imports = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
[key: `#${string}`]: string | {[key in ExportCondition]: Exports};
[key: `#${string}`]: string | {[key in ExportCondition]?: Exports};
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
Expand Down
6 changes: 6 additions & 0 deletions test-d/package-json.ts
Expand Up @@ -54,6 +54,12 @@ string
>>
>(packageJson.cpu);
expectAssignable<PackageJson.Imports>({'#unicorn': 'unicorn'});
expectAssignable<PackageJson.Imports>({
'#unicorn': {
import: {browser: 'unicorn', node: 'pony'},
default: 'horse',
},
});
expectNotAssignable<PackageJson.Imports>({unicorn: 'unicorn'});
expectType<boolean | undefined>(packageJson.preferGlobal);
expectType<boolean | undefined>(packageJson.private);
Expand Down