Skip to content

Commit 6ea77bb

Browse files
committed
Fix the ts-prune workarounds
I learned today that TypeScript treats everything in a .d.ts file as if it was exported, whether it says `export` or not, unless you add an `export {}` declaration somewhere in the file. See microsoft/TypeScript#57764 We had a bunch of ts-prune-ignore-next declarations in internaltypes.d.ts to work around this. Adding `export {}` allows ts-prune to work as expected without workarounds.
1 parent 82a2410 commit 6ea77bb

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

lib/internaltypes.d.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export type CalendarSlot = string | Temporal.CalendarProtocol;
5555
export type TimeZoneSlot = string | Temporal.TimeZoneProtocol;
5656

5757
// Used in AnyTemporalLikeType
58-
// ts-prune-ignore-next
5958
type AllTemporalLikeTypes = [
6059
Temporal.DurationLike,
6160
Temporal.PlainDateLike,
@@ -78,7 +77,6 @@ export type FieldKey = Exclude<AnyTemporalKey, Keys<Temporal.DurationLike>>;
7877
// `timeZone` and `calendar` are not on the list because they have special methods to set them.
7978

8079
// Used in PrimitiveFieldsOf
81-
// ts-prune-ignore-next
8280
type PrimitivePropertyNames =
8381
| 'year'
8482
| 'month'
@@ -126,16 +124,9 @@ export type UnitSmallerThanOrEqualTo<T extends Temporal.DateTimeUnit> = T extend
126124
? 'nanosecond'
127125
: never;
128126

129-
// ts-prune complains about the type definitions below, even though they're used
130-
// by exported types Not sure why and don't have time to investigate, so just
131-
// disabling the warnings for now.
132-
133-
// ts-prune-ignore-next
134127
type Method = (...args: any) => any;
135-
// ts-prune-ignore-next
136128
type NonObjectKeys<T> = Exclude<keyof T, 'toString' | 'toLocaleString' | 'prototype'>;
137129

138-
// ts-prune-ignore-next
139130
type MethodParams<Type extends new (...args: any) => any> = {
140131
// constructor parameters
141132
constructor: ConstructorParameters<Type>;
@@ -149,7 +140,6 @@ type MethodParams<Type extends new (...args: any) => any> = {
149140
: never;
150141
};
151142

152-
// ts-prune-ignore-next
153143
type MethodReturn<Type extends new (...args: any) => any> = {
154144
constructor: InstanceType<Type>;
155145
} & {
@@ -166,7 +156,6 @@ type InterfaceReturn<Type> = {
166156
};
167157
*/
168158

169-
// ts-prune-ignore-next
170159
type InterfaceParams<Type> = {
171160
[Key in keyof Type]: Type[Key] extends Method ? Parameters<Type[Key]> : never;
172161
};
@@ -209,11 +198,10 @@ export interface CalendarProtocolParams extends InterfaceParams<Temporal.Calenda
209198
export interface DateTimeFormatParams extends MethodParams<typeof Intl.DateTimeFormat> {}
210199
export interface DateTimeFormatReturn extends MethodReturn<typeof Intl.DateTimeFormat> {}
211200

212-
// ts-prune-ignore-next
213201
type OptionsAmenderFunction = (options: Intl.DateTimeFormatOptions) => globalThis.Intl.DateTimeFormatOptions;
214-
type FormatterOrAmender = globalThis.Intl.DateTimeFormat | OptionsAmenderFunction;
202+
export type FormatterOrAmender = globalThis.Intl.DateTimeFormat | OptionsAmenderFunction;
215203

216-
interface ISODateTime {
204+
export interface ISODateTime {
217205
year: number;
218206
month: number;
219207
day: number;
@@ -225,10 +213,13 @@ interface ISODateTime {
225213
nanosecond: number;
226214
}
227215

228-
interface InternalDuration {
216+
export interface InternalDuration {
229217
years: number;
230218
months: number;
231219
weeks: number;
232220
days: number;
233221
norm: TimeDuration;
234222
}
223+
224+
// Signal to TypeScript that not everything should be exported by default
225+
export {};

0 commit comments

Comments
 (0)