Skip to content

Conversation

@maxpatiiuk
Copy link
Member

Related Issue: #10803

Summary

Subtly change the JSON type imports to encourage TypeScript to inline these in the final .d.ts files, rather than preserve them as .json imports.

Opened an issue 2047 in AWC to add a build-time error if any .json import appears in the public .d.ts file. We can extend that as needed

@maxpatiiuk maxpatiiuk requested a review from jcfranco November 20, 2024 01:45
@maxpatiiuk maxpatiiuk self-assigned this Nov 20, 2024
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Nov 20, 2024
@jcfranco jcfranco added the skip visual snapshots Pull requests that do not need visual regression testing. label Nov 20, 2024
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@jcfranco jcfranco merged commit 5ad6784 into dev Nov 20, 2024
12 checks passed
@jcfranco jcfranco deleted the max/10803 branch November 20, 2024 03:23
benelan pushed a commit that referenced this pull request Feb 8, 2025
**Related Issue:** #10803

## Summary

Subtly change the JSON type imports to encourage TypeScript to inline
these in the final .d.ts files, rather than preserve them as `.json`
imports.

Opened an issue 2047 in AWC to add a build-time error if any .json
import appears in the public .d.ts file. We can extend that as needed
@maxpatiiuk
Copy link
Member Author

maxpatiiuk commented Apr 25, 2025

For future reference: I found a consistent way to force typescript to inline the type of a type only json import:

import type T9nStrings from "./assets/t9n/messages.en.json";
const identity = <T>(value: T): T => value;
const messages = identity<typeof T9nStrings>;
type Messages = ReturnType<typeof messages>;

The ColorPicker["messages"] trick is simpler, but when it is not possible (because there is no such property available for use), the above is a workaround

Openned TypeScript issue: microsoft/TypeScript#61614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug reports for broken functionality. Issues should include a reproduction of the bug. skip visual snapshots Pull requests that do not need visual regression testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants