create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D, VRML, glTF and other 3D sources in HTML.
https://create3000.github.io/x_ite/
Other
67 stars 15 forks source link

Example to make .d.ts work, Typescript 5.6.4 #182

Closed krisutofu closed 1 month ago

krisutofu commented 1 month ago

Using Typescript 5.6.2, VSCode 1.93.1

These are the changes that I made to make the definitions work as I think they are intended. The only difference is, the interface has been replaced with a namespace that contains the interface instance properties and all type definitions.

Issue: #181

changes:

I had to edit also the autogenerated code. It is an example and therefore I made this a draft.

create3000 commented 1 month ago

An additional export = X3D; at the beginning would be important to make the definitions work with require.

// Handle both importing via UMD and modules:
export default X3D;
export = X3D;

When I test this with vscode all is fine in both TS, ES, require.

create3000 commented 1 month ago

Thank you for providing these changes.

Because a lot of .d.ts is automatically generated I updated /build/bin/ts.js and /src/X3DUOM.xml in branch types.

create3000 commented 1 month ago

I created a test TS project and tested your changes with your TS config, and it seems to work. Link to branch https://github.com/create3000/x_ite/tree/types. Could you please confirm that this is now working.

create3000 commented 1 month ago

This PR is already manually merged, so I will close it.

krisutofu commented 1 month ago

Great, thank you for your work!