Skip to content

Commit

Permalink
fix(fast_check): emit named type in mapped types (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jun 25, 2024
1 parent 2505a3d commit 58298f5
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 26 deletions.
29 changes: 15 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ harness = false
anyhow = "1.0.43"
async-trait = "0.1.68"
data-url = "0.3.0"
deno_ast = { version = "0.39.0", features = ["dep_analysis", "emit"] }
deno_ast = { version = "0.39.2", features = ["dep_analysis", "emit"] }
deno_semver = "0.5.4"
deno_unsync = { version = "0.3.2", optional = true }
encoding_rs = "0.8.33"
Expand Down
9 changes: 7 additions & 2 deletions tests/specs/ecosystem/codehz/mutable_element/0_2_0.test
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,19 @@ TS2304 [ERROR]: Cannot find name 'Node'.
at file://<tmpdir>/src/types.ts:3:68

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration]?: string | boolean | null;
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:15

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:42

TS2304 [ERROR]: Cannot find name 'IdleDeadline'.
export function idle(): Reactor<IdleDeadline> {
~~~~~~~~~~~~
at file://<tmpdir>/src/utils.ts:55:33

Found 45 errors.
Found 46 errors.

9 changes: 7 additions & 2 deletions tests/specs/ecosystem/codehz/mutable_element/0_2_1.test
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,19 @@ TS2304 [ERROR]: Cannot find name 'Node'.
at file://<tmpdir>/src/types.ts:3:68

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration]?: string | boolean | null;
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:15

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:42

TS2304 [ERROR]: Cannot find name 'IdleDeadline'.
export function idle(): Reactor<IdleDeadline> {
~~~~~~~~~~~~
at file://<tmpdir>/src/utils.ts:55:33

Found 45 errors.
Found 46 errors.

9 changes: 7 additions & 2 deletions tests/specs/ecosystem/codehz/mutable_element/0_2_2.test
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,19 @@ TS2304 [ERROR]: Cannot find name 'Node'.
at file://<tmpdir>/src/types.ts:3:68

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration]?: string | boolean | null;
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:15

TS2304 [ERROR]: Cannot find name 'CSSStyleDeclaration'.
[K in keyof CSSStyleDeclaration as [K, CSSStyleDeclaration[K]] extends [string, string] ? K : never]?: string | boolean | null;
~~~~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/types.ts:33:42

TS2304 [ERROR]: Cannot find name 'IdleDeadline'.
export function idle(): Reactor<IdleDeadline> {
~~~~~~~~~~~~
at file://<tmpdir>/src/utils.ts:55:33

Found 46 errors.
Found 47 errors.

6 changes: 1 addition & 5 deletions tests/specs/ecosystem/ydcjeff/ruta/0_0_1.test
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,5 @@ TS1170 [ERROR]: A computed property name in a type literal must refer to an expr
~~~~~~~~~~~~~~~~
at file://<tmpdir>/src/ruta_core.ts:91:3

TS2322 [ERROR]: Type 'TChildren[number]' is not assignable to type 'string | number | symbol'.
Type 'RouteOptions<string, Record<string, never>, Record<string, never>, {}>' is not assignable to type 'string | number | symbol'.
at file://<tmpdir>/src/ruta_core.ts:128:11

Found 10 errors.
Found 9 errors.

146 changes: 146 additions & 0 deletions tests/specs/graph/fast_check/mapped_type.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# https://jsr.io/@scope/a/meta.json
{"versions": { "1.0.0": {} } }

# https://jsr.io/@scope/a/1.0.0_meta.json
{ "exports": { ".": "./mod.ts" } }

# https://jsr.io/@scope/a/1.0.0/mod.ts
export type NoTypeAnn = {
[value: string];
};
type Private1 = string;
type Private2 = number;
export type MappedTypeWithNamedType = {
[K in T as U & Private1]: Private2;
};
export type Partial<T> = {
[P in keyof T]?: T[P];
};
export type OptionalPlus<T> = {
[P in keyof T]+?: T[P];
};
export type OptionalMinus<T> = {
[P in keyof T]-?: T[P];
};
export type Flags<T> = {
[P in keyof T]: boolean;
};
export type ReadOnly<T> = {
readonly [P in keyof T]: T[P];
};
export type ReadOnlyPlus<T> = {
+readonly [P in keyof T]: T[P];
};
export type ReadOnlyMinus<T> = {
-readonly [P in keyof T]: T[P];
};

# mod.ts
import 'jsr:@scope/a'

# output
{
"roots": [
"file:///mod.ts"
],
"modules": [
{
"kind": "esm",
"dependencies": [
{
"specifier": "jsr:@scope/a",
"code": {
"specifier": "jsr:@scope/a",
"span": {
"start": {
"line": 0,
"character": 7
},
"end": {
"line": 0,
"character": 21
}
}
}
}
],
"size": 22,
"mediaType": "TypeScript",
"specifier": "file:///mod.ts"
},
{
"kind": "esm",
"size": 631,
"mediaType": "TypeScript",
"specifier": "https://jsr.io/@scope/a/1.0.0/mod.ts"
}
],
"redirects": {
"jsr:@scope/a": "https://jsr.io/@scope/a/1.0.0/mod.ts"
},
"packages": {
"@scope/a": "@scope/[email protected]"
}
}

Fast check https://jsr.io/@scope/a/1.0.0/mod.ts:
{}
export type NoTypeAnn = {
[value: string];
};
type Private1 = string;
type Private2 = number;
export type MappedTypeWithNamedType = {
[K in T as U & Private1]: Private2;
};
export type Partial<T> = {
[P in keyof T]?: T[P];
};
export type OptionalPlus<T> = {
[P in keyof T]+?: T[P];
};
export type OptionalMinus<T> = {
[P in keyof T]-?: T[P];
};
export type Flags<T> = {
[P in keyof T]: boolean;
};
export type ReadOnly<T> = {
readonly [P in keyof T]: T[P];
};
export type ReadOnlyPlus<T> = {
+readonly [P in keyof T]: T[P];
};
export type ReadOnlyMinus<T> = {
-readonly [P in keyof T]: T[P];
};
--- DTS ---
export type NoTypeAnn = {
[value: string];
};
type Private1 = string;
type Private2 = number;
export type MappedTypeWithNamedType = {
[K in T as U & Private1]: Private2;
};
export type Partial<T> = {
[P in keyof T]?: T[P];
};
export type OptionalPlus<T> = {
[P in keyof T]+?: T[P];
};
export type OptionalMinus<T> = {
[P in keyof T]-?: T[P];
};
export type Flags<T> = {
[P in keyof T]: boolean;
};
export type ReadOnly<T> = {
readonly [P in keyof T]: T[P];
};
export type ReadOnlyPlus<T> = {
+readonly [P in keyof T]: T[P];
};
export type ReadOnlyMinus<T> = {
-readonly [P in keyof T]: T[P];
};

0 comments on commit 58298f5

Please sign in to comment.