Skip to content

Commit 5b7fb06

Browse files
author
nicosammito
committed
feat: update type declarations and improve type handling in utility functions
1 parent 2ce5383 commit 5b7fb06

4 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ export const DEFAULT_COMPILER_OPTIONS: ts.CompilerOptions = {
7878
/**
7979
* Extracts and returns common type and generic declarations from DATA_TYPES.
8080
*/
81-
export function getSharedTypeDeclarations(dataTypes?: DataType[]): string {
81+
export function getSharedTypeDeclarations(dataTypes?: DataType[], genericType: string = "any"): string {
8282
const genericDeclarations = Array.from(new Set(dataTypes?.flatMap(dt => dt.genericKeys || [])))
83-
.map(g => `type ${g} = unknown;`)
83+
.map(g => `type ${g} = ${genericType};`)
8484
.join("\n");
8585

8686
const typeAliasDeclarations = dataTypes?.map(dt =>

test/data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export const DATA_TYPES: DataType[] = [
279279
"genericKeys": [
280280
"T"
281281
],
282-
"type": "T & {}",
282+
"type": "{ [K in keyof T]: T[K] }",
283283
"name": [
284284
{
285285
"__typename": "Translation",
@@ -7702,7 +7702,7 @@ export const FUNCTION_SIGNATURES: FunctionDefinition[] = [
77027702
"id": "gid://sagittarius/FunctionDefinition/69",
77037703
"createdAt": "2026-03-15T16:27:29Z",
77047704
"updatedAt": "2026-03-15T16:27:29Z",
7705-
"signature": "<T, K extends TEXT, V>(object: OBJECT<T>, key: K, value: V): OBJECT<T & Record<K, V>>",
7705+
"signature": "<T, K extends TEXT, V>(object: OBJECT<T>, key: K, value: V): OBJECT<T & { [P in K]: V }>",
77067706
"linkedDataTypes": {
77077707
"count": 2,
77087708
"nodes": [

test/getTypeVariant.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('getTypeVariant', () => {
1818
it('sollte OBJECT für Interfaces oder Objekte mit Properties zurückgeben', () => {
1919
expect(getTypeVariant("{ name: string }", DATA_TYPES)).toBe(DataTypeVariant.OBJECT);
2020
expect(getTypeVariant("{}", DATA_TYPES)).toBe(DataTypeVariant.OBJECT);
21-
expect(getTypeVariant("OBJECT<T>", DATA_TYPES)).toBe(DataTypeVariant.OBJECT);
21+
expect(getTypeVariant("OBJECT<any>", DATA_TYPES)).toBe(DataTypeVariant.OBJECT);
2222
});
2323

2424
it('sollte TYPE für einfache Type-Aliase oder void zurückgeben', () => {

test/nodeSuggestion.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe("getNodeSuggestions", () => {
2020
'std::list::find',
2121
'std::number::as_text',
2222
'std::object::get',
23-
'std::object::set',
2423
'std::boolean::as_text',
2524
'std::text::decode',
2625
'std::text::trim',
@@ -70,7 +69,6 @@ describe("getNodeSuggestions", () => {
7069
'std::number::is_less',
7170
'std::object::contains_key',
7271
'std::object::get',
73-
'std::object::set',
7472
'std::boolean::from_number',
7573
'std::boolean::is_equal',
7674
'std::boolean::from_text',

0 commit comments

Comments
 (0)