Skip to content

Commit 7492b7a

Browse files
authored
Merge branch 'main' into is-literal
2 parents 1adbf5b + 3436855 commit 7492b7a

24 files changed

+84
-60
lines changed

package.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,35 @@
8484
},
8585
"overrides": [
8686
{
87-
"files": "**/*.d.ts",
87+
"files": "source/**/*.d.ts",
8888
"rules": {
8989
"no-restricted-imports": [
9090
"error",
91-
"tsd",
92-
"expect-type"
91+
{
92+
"paths": ["tsd", "expect-type"],
93+
"patterns": [
94+
{
95+
"group": ["*.js", "*.ts", "!*.d.ts"],
96+
"message": "Use `.d.ts` extension."
97+
}
98+
]
99+
}
100+
]
101+
}
102+
},
103+
{
104+
"files": "test-d/**/*.ts",
105+
"rules": {
106+
"no-restricted-imports": [
107+
"error",
108+
{
109+
"patterns": [
110+
{
111+
"group": ["*.js", "*.ts", "!*.d.ts"],
112+
"message": "Use `.d.ts` extension."
113+
}
114+
]
115+
}
93116
]
94117
}
95118
}

source/array-tail.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {If} from './if.js';
1+
import type {If} from './if.d.ts';
22
import type {ApplyDefaultOptions, IsArrayReadonly} from './internal/index.d.ts';
33
import type {UnknownArray} from './unknown-array.d.ts';
44

source/conditional-keys.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {If} from './if.js';
2-
import type {IsNever} from './is-never.js';
1+
import type {If} from './if.d.ts';
2+
import type {IsNever} from './is-never.d.ts';
33

44
/**
55
Extract the keys from a type where the value type of the key extends the given `Condition`.

source/if.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {IsNever} from './is-never.js';
1+
import type {IsNever} from './is-never.d.ts';
22

33
/**
44
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.

source/internal/array.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {If} from '../if.js';
2-
import type {IsNever} from '../is-never.js';
1+
import type {If} from '../if.d.ts';
2+
import type {IsNever} from '../is-never.d.ts';
33
import type {UnknownArray} from '../unknown-array.d.ts';
44

55
/**

source/internal/object.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import type {KeysOfUnion} from '../keys-of-union.d.ts';
55
import type {RequiredKeysOf} from '../required-keys-of.d.ts';
66
import type {Merge} from '../merge.d.ts';
77
import type {OptionalKeysOf} from '../optional-keys-of.d.ts';
8-
import type {IsAny} from '../is-any.js';
9-
import type {If} from '../if.js';
10-
import type {IsNever} from '../is-never.js';
8+
import type {IsAny} from '../is-any.d.ts';
9+
import type {If} from '../if.d.ts';
10+
import type {IsNever} from '../is-never.d.ts';
1111
import type {FilterDefinedKeys, FilterOptionalKeys} from './keys.d.ts';
1212
import type {NonRecursiveType} from './type.d.ts';
1313
import type {ToString} from './string.d.ts';

source/internal/type.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {Primitive} from '../primitive.d.ts';
22
import type {IsNever} from '../is-never.d.ts';
33
import type {IsAny} from '../is-any.d.ts';
4-
import type {And} from '../and.js';
5-
import type {If} from '../if.js';
4+
import type {And} from '../and.d.ts';
5+
import type {If} from '../if.d.ts';
66

77
/**
88
Matches any primitive, `void`, `Date`, or `RegExp` value.
@@ -25,8 +25,8 @@ export type Extends<Left, Right> = IsNever<Left> extends true ? IsNever<Right> :
2525
Returns a boolean for whether the two given types extends the base type.
2626
*/
2727
export type IsBothExtends<BaseType, FirstType, SecondType> = And<
28-
Extends<FirstType, BaseType>,
29-
Extends<SecondType, BaseType>
28+
Extends<FirstType, BaseType>,
29+
Extends<SecondType, BaseType>
3030
>;
3131

3232
/**

source/is-literal.d.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import type {ApplyDefaultOptions, CollapseLiterals} from './internal/object.d.ts';
22
import type {Extends, IsNotFalse, IsTrue, Not} from './internal/type.d.ts';
3-
import type {TagContainer, UnwrapTagged} from './tagged.js';
3+
import type {TagContainer, UnwrapTagged} from './tagged.d.ds';
44
import type {Primitive} from './primitive.d.ts';
55
import type {IsNever} from './is-never.d.ts';
66
import type {Numeric} from './numeric.d.ts';
7-
import type {IsAny} from './is-any.js';
8-
import type {And} from './and.js';
7+
import type {IsAny} from './is-any.d.ts';
8+
import type {And} from './and.d.ts';
99

1010
/**
1111
@see {@link IsLiteral}
1212
*/
1313
type IsLiteralOptions = {
14-
strict?: boolean
15-
}
14+
strict?: boolean
15+
};
1616

1717
type DefaultIsLiteralOptions = {
18-
strict: true
19-
}
18+
strict: true
19+
};
2020

2121
/**
2222
Returns a boolean for whether the given type `T` is the specified `LiteralType`.
@@ -66,9 +66,9 @@ type LiteralChecks<T, LiteralUnionType> = (
6666
// If `T` is none of the literal types in the union `LiteralUnionType`, then `LiteralCheck<T, LiteralType>` will evaluate to `false` for the whole union.
6767
// If `T` is one of the literal types in the union, it will evaluate to `boolean` (i.e. `true | false`)
6868
IsNotFalse<
69-
LiteralUnionType extends Primitive
70-
? LiteralCheck<T, LiteralUnionType>
71-
: never
69+
LiteralUnionType extends Primitive
70+
? LiteralCheck<T, LiteralUnionType>
71+
: never
7272
>
7373
);
7474

@@ -129,7 +129,7 @@ type L2 = Length<`${number}`>;
129129
@category Type Guard
130130
@category Utilities
131131
*/
132-
export type IsStringLiteral<T, Options extends IsLiteralOptions = {}> =
132+
export type IsStringLiteral<T, Options extends IsLiteralOptions = {}> = (
133133
ApplyDefaultOptions<IsLiteralOptions, DefaultIsLiteralOptions, Options> extends infer ResolvedOptions extends Required<IsLiteralOptions>
134134
? IsNever<T> extends false
135135
? CollapseLiterals<T extends TagContainer<any> ? UnwrapTagged<T> : T> extends infer Type
@@ -139,6 +139,7 @@ export type IsStringLiteral<T, Options extends IsLiteralOptions = {}> =
139139
: never
140140
: false
141141
: never
142+
);
142143

143144
type _IsStringLiteral<S> = (
144145
// If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,

source/is-lowercase.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Every} from './internal/array.js';
1+
import type {Every} from './internal/array.d.ts';
22

33
/**
44
Returns a boolean for whether the given string literal is lowercase.

source/is-tuple.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type {If} from './if.js';
1+
import type {If} from './if.d.ts';
22
import type {ApplyDefaultOptions} from './internal/index.d.ts';
3-
import type {IsAny} from './is-any.js';
4-
import type {IsNever} from './is-never.js';
3+
import type {IsAny} from './is-any.d.ts';
4+
import type {IsNever} from './is-never.d.ts';
55
import type {UnknownArray} from './unknown-array.d.ts';
66

77
/**

0 commit comments

Comments
 (0)