-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support for generic functions (#2159)
Co-authored-by: Dominik Moritz <[email protected]>
- Loading branch information
1 parent
6ad76cf
commit c8ea3ed
Showing
13 changed files
with
263 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ | |
"vega": "^5.31.0", | ||
"vega-lite": "^5.23.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { BaseType } from "./BaseType.js"; | ||
|
||
export class UnknownType extends BaseType { | ||
constructor() { | ||
constructor( | ||
/** | ||
* If the source for this UnknownType was from a failed operation than to an actual `unknown` type present in the source code. | ||
*/ | ||
readonly erroredSource: boolean, | ||
) { | ||
super(); | ||
} | ||
|
||
public getId(): string { | ||
return "unknown"; | ||
} | ||
} | ||
|
||
/** | ||
* Checks for an UnknownType with an errored source. | ||
*/ | ||
export function isErroredUnknownType(type: BaseType): type is UnknownType { | ||
return type instanceof UnknownType && type.erroredSource; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function fn<A, B, C>(a: A, b: B, c: C, any: A | B | C) { | ||
return { a, b, c, any }; | ||
} | ||
|
||
const value = { | ||
litNum: fn(1, "2", true, 1), | ||
litStr: fn("1", 2, true, "2"), | ||
litBool: fn(true, 2, "3", true), | ||
obj: fn({ a: 1 }, { b: "2" }, { c: true }, { a: 1 }), | ||
}; | ||
|
||
export type MyType = typeof value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
{ | ||
"$ref": "#/definitions/MyType", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"MyType": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"litBool": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"type": "boolean" | ||
}, | ||
"any": { | ||
"type": [ | ||
"string", | ||
"number", | ||
"boolean" | ||
] | ||
}, | ||
"b": { | ||
"type": "number" | ||
}, | ||
"c": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"a", | ||
"b", | ||
"c", | ||
"any" | ||
], | ||
"type": "object" | ||
}, | ||
"litNum": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"type": "number" | ||
}, | ||
"any": { | ||
"type": [ | ||
"string", | ||
"number", | ||
"boolean" | ||
] | ||
}, | ||
"b": { | ||
"type": "string" | ||
}, | ||
"c": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"a", | ||
"b", | ||
"c", | ||
"any" | ||
], | ||
"type": "object" | ||
}, | ||
"litStr": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"type": "string" | ||
}, | ||
"any": { | ||
"type": [ | ||
"string", | ||
"number", | ||
"boolean" | ||
] | ||
}, | ||
"b": { | ||
"type": "number" | ||
}, | ||
"c": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"a", | ||
"b", | ||
"c", | ||
"any" | ||
], | ||
"type": "object" | ||
}, | ||
"obj": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": [ | ||
"a" | ||
], | ||
"type": "object" | ||
}, | ||
"any": { | ||
"anyOf": [ | ||
{ | ||
"additionalProperties": false, | ||
"properties": { | ||
"a": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": [ | ||
"a" | ||
], | ||
"type": "object" | ||
}, | ||
{ | ||
"additionalProperties": false, | ||
"properties": { | ||
"b": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"b" | ||
], | ||
"type": "object" | ||
}, | ||
{ | ||
"additionalProperties": false, | ||
"properties": { | ||
"c": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"c" | ||
], | ||
"type": "object" | ||
} | ||
] | ||
}, | ||
"b": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"b": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"b" | ||
], | ||
"type": "object" | ||
}, | ||
"c": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"c": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"c" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"a", | ||
"b", | ||
"c", | ||
"any" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"litNum", | ||
"litStr", | ||
"litBool", | ||
"obj" | ||
], | ||
"type": "object" | ||
} | ||
} | ||
} |
Oops, something went wrong.