Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mscharley committed Nov 1, 2024
1 parent 7456d90 commit b4e5ef9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default [
...withStyles(),
...configs.license['MPL-2.0'](),
{
ignores: ['node_modules', 'dist', 'reports', 'eslint.config.js', 'generic-type-guard.*'],
ignores: ['node_modules', 'dist', 'reports', 'eslint.config.js', 'generic-type-guard.*', '.stryker-tmp'],
},
{
files: ['*.config.js'],
Expand Down
14 changes: 4 additions & 10 deletions etc/generic-type-guard.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const hasOnlyProperties: <V extends object>(props: MappedTypeGuard<V>) =>
export const hasOptionalProperties: <V extends object>(props: MappedTypeGuard<V>) => PartialTypeGuard<object, Partial<V>>;

// @public
export const hasOptionalProperty: <K extends string, V>(property: K, value: TypeGuard<V>) => PartialTypeGuard<object, { [prop in K]?: V; }>;
export const hasOptionalProperty: <K extends string, V>(property: K, value: TypeGuard<V>) => PartialTypeGuard<object, Partial<Record<K, V>>>;

// @public
export const hasProperties: <V extends object>(props: MappedTypeGuard<V>) => PartialTypeGuard<object, V>;
Expand All @@ -55,13 +55,9 @@ export interface InterfaceBuilder<T extends object> {
with: <V extends object>(ptv: PartialTypeGuard<object, V>) => InterfaceBuilder<T & V>;
withNumericIndexSignature: <V>(value: TypeGuard<V>, enforce?: boolean) => InterfaceBuilder<T & Record<number, V>>;
withOptionalProperties: <V extends object>(props: MappedTypeGuard<V>) => InterfaceBuilder<T & Partial<V>>;
withOptionalProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & {
[prop in K]?: V;
}>;
withOptionalProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & Partial<Record<K, V>>>;
withProperties: <V extends object>(props: MappedTypeGuard<V>) => InterfaceBuilder<T & V>;
withProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & {
[prop in K]: V;
}>;
withProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & Record<K, V>>;
withStringIndexSignature: <V>(value: TypeGuard<V>, enforce?: boolean) => InterfaceBuilder<T & Record<string, V>>;
}

Expand Down Expand Up @@ -116,9 +112,7 @@ export class IsInterface implements InterfaceBuilder<object> {
// (undocumented)
withOptionalProperties<V extends object>(props: MappedTypeGuard<V>): InterfaceBuilder<object & Partial<V>>;
// (undocumented)
withOptionalProperty<K extends string, V>(key: K, ptv: TypeGuard<V>): InterfaceBuilder<object & {
[prop in K]?: V;
}>;
withOptionalProperty<K extends string, V>(key: K, ptv: TypeGuard<V>): InterfaceBuilder<object & Partial<Record<K, V>>>;
// (undocumented)
withProperties<V extends object>(props: MappedTypeGuard<V>): InterfaceBuilder<object & V>;
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default {
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/__utils__/', '/examples/'],
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/__utils__/', '/examples/', '.stryker-tmp'],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down
8 changes: 4 additions & 4 deletions src/combinators/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export interface InterfaceBuilder<T extends object> {
* @param key - The string key of the property.
* @param ptv - The type guard for this property.
*/
withProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & { [prop in K]: V }>;
withProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & Record<K, V>>;

/**
* Add a single optional property to the interface.
*
* @param key - The string key of the property.
* @param ptv - The type guard for this property.
*/
withOptionalProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & { [prop in K]?: V }>;
withOptionalProperty: <K extends string, V>(key: K, ptv: TypeGuard<V>) => InterfaceBuilder<T & Partial<Record<K, V>>>;

/**
* Add a string index signature to the interface.
Expand Down Expand Up @@ -101,7 +101,7 @@ class InterfaceStep<T extends object> implements InterfaceBuilder<T> {
public withOptionalProperty<K extends string, V>(
key: K,
ptv: TypeGuard<V>,
): InterfaceBuilder<T & { [prop in K]?: V }> {
): InterfaceBuilder<T & Partial<Record<K, V>>> {
return new InterfaceStep(isIntersection(this.ptt, o.hasOptionalProperty(key, ptv)));
}

Expand Down Expand Up @@ -143,7 +143,7 @@ export class IsInterface implements InterfaceBuilder<object> {
public withOptionalProperty<K extends string, V>(
key: K,
ptv: TypeGuard<V>,
): InterfaceBuilder<object & { [prop in K]?: V }> {
): InterfaceBuilder<object & Partial<Record<K, V>>> {
return new InterfaceStep(o.hasOptionalProperty(key, ptv));
}

Expand Down
8 changes: 4 additions & 4 deletions src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isObject } from './primitives.js';
*/
export const hasProperty
= <K extends string, V>(property: K, value: TypeGuard<V>): PartialTypeGuard<object, Record<K, V>> =>
(o: object): o is { [prop in K]: V } =>
(o: object): o is Record<K, V> =>
// If the property exists and conforms to the value type guard.
value((o as Record<string, unknown>)[property]);

Expand All @@ -25,8 +25,8 @@ export const hasProperty
* @public
*/
export const hasOptionalProperty
= <K extends string, V>(property: K, value: TypeGuard<V>): PartialTypeGuard<object, { [prop in K]?: V }> =>
(o: object): o is { [prop in K]: V } =>
= <K extends string, V>(property: K, value: TypeGuard<V>): PartialTypeGuard<object, Partial<Record<K, V>>> =>
(o: object): o is Record<K, V> =>
!(property in o)
// If the property exists and conforms to the value type guard.
|| value((o as Record<string, unknown>)[property]);
Expand All @@ -40,7 +40,7 @@ export const hasOptionalProperty
*/
export const isRecord
= <K extends string, V>(property: K, value: TypeGuard<V>): TypeGuard<Record<K, V>> =>
(o: unknown): o is { [prop in K]: V } =>
(o: unknown): o is Record<K, V> =>
isObject(o) && hasProperty(property, value)(o);

/**
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://turbo.build/schema.json",
"globalPassThroughEnv": ["ASDF_*"],
"daemon": false,
"tasks": {
"build": {
"dependsOn": ["build:tsc", "build:api", "build:esbuild:cjs", "build:esbuild:esm"]
Expand Down

0 comments on commit b4e5ef9

Please sign in to comment.