Skip to content

Commit 434d98a

Browse files
authored
Improves type exports (#35)
* Improves type exports * Removes unrelated change * remove unused imports
1 parent 1432da7 commit 434d98a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/lib/convertAasTypes.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import type {
1+
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
2+
import {
23
AssetAdministrationShell as CoreAssetAdministrationShell,
34
AssetInformation as CoreAssetInformation,
45
Reference as CoreReference,
56
} from '@aas-core-works/aas-core3.0-typescript/types';
6-
import type {
7+
import {
78
AssetAdministrationShell as ApiAssetAdministrationShell,
89
AssetInformation as ApiAssetInformation,
910
Reference as ApiReference,
1011
} from '../generated/types.gen';
11-
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
1212

1313
/**
1414
* Convert an API AssetAdministrationShell to a Core Works AssetAdministrationShell
@@ -27,7 +27,10 @@ export function convertApiAasToCoreAas(aas: ApiAssetAdministrationShell): CoreAs
2727
if (instanceOrError.error !== null) {
2828
throw instanceOrError.error;
2929
}
30-
return instanceOrError.mustValue();
30+
const instance = instanceOrError.mustValue();
31+
// set the prototype
32+
Object.setPrototypeOf(instance, CoreAssetAdministrationShell.prototype);
33+
return instance;
3134
}
3235

3336
/**
@@ -65,7 +68,10 @@ export function convertApiAssetInformationToCoreAssetInformation(
6568
if (instanceOrError.error !== null) {
6669
throw instanceOrError.error;
6770
}
68-
return instanceOrError.mustValue();
71+
const instance = instanceOrError.mustValue();
72+
// set the prototype
73+
Object.setPrototypeOf(instance, CoreAssetInformation.prototype);
74+
return instance;
6975
}
7076

7177
/**
@@ -103,7 +109,10 @@ export function convertApiReferenceToCoreReference(reference: ApiReference): Cor
103109
if (instanceOrError.error !== null) {
104110
throw instanceOrError.error;
105111
}
106-
return instanceOrError.mustValue();
112+
const instance = instanceOrError.mustValue();
113+
// set the prototype
114+
Object.setPrototypeOf(instance, CoreReference.prototype);
115+
return instance;
107116
}
108117

109118
/**

0 commit comments

Comments
 (0)