[x3d-public] typescript?

John Carlson yottzumm at gmail.com
Sat Mar 8 21:26:12 PST 2025


Here’s what I’ve concluded as an observer:

Note that angle brackets <> classes (generics) and things like “any” are
specific to TypeScript,  but most “TypeScript class” stuff has JavaScript
classes or functions which create instances at the core.  All TypeScript
classes are representable in JavaScript, but without type safety.   Type
annotations are erased during transpilation.   AFAIK, with JSdoc, nothing
is erased, there’s no transpilation step.

We should focus on complete, portable implementation of existing JavaScript
SAI before piling on more.  Like being able to import X_ITE SAI and/or
X3DOM SAI into a variable, and the rest of the code would just work using
that variable.  No difference between external and internal SAI.

It might be worth adding generics to X3D SAI, like the C++ SAI.  I’d say
tackle that language first, if not done elsewhere.  AFAIK, the architecture
standard already includes that with type and acceptableTypes (see X3DUOM).

But any SAI work is next year.  I’m hoping to see changes in SAI such that
setter and adders return self/this.  This hopefully will affect Castle
which will allow X3D JSON to Pascal conversion without a huge variant
type.  I’ve also got in the back of my mind to load X3D JSON into Pascal,
which would be less disruptive.

I’ve added basic TypeScript type annotations to X3DJSONLD.ts, but I didn’t
see much benefit.  But I only used the most basic types.

Adding types after the fact is a big pain in the neck.  Adding JSDoc after
the fact is just plain better and doesn’t mean you have to mess with
existing, working functions, one just adds comments.

Otherwise wholesale generation of an API, at least the skin with JavaScript
and JSDoc and not TypeScript is possible, but I’d rather focus on adding
rendering to X3DJSAIL.

John

On Sat, Mar 8, 2025 at 6:45 PM Brutzman, Donald (Don) (CIV) <
brutzman at nps.edu> wrote:

> Thanks for asking Joe.  John Carlson (copied above) has presented a good
> case for TypeScript as well.  Two answers:
>
> If specialization is wanted, Sure Why Not.
>
>    - The X in X3D is extensible.  Have fun with extensibility!
>    - There are multiple open-source browser solutions out there.
>    Somebody could add TypeScript to an implementation for testing.
>    - Somebody could add Typescript classes matching the SAI and X3DUOM
>    (perhaps similar to X3DJSAIL and X3DPSAIL x3d.py).  Though I'd think we
>    need to get that done for EcmaScript/JavaScript first, or versionitis might
>    result.
>    - Appears possible to author in TypeScript and convert to
>    EcmaScript/JavaScript.  From https://www.typescriptlang.org
>    - "TypeScript code converts to JavaScript, which *runs anywhere
>       JavaScript runs*: In a browser, on Node.js, Deno, Bun and in your
>       apps."
>
>
> If standardization is wanted, Not Anytime Soon.
>
>    - Dick Puk and I have our hands full upgrading all existing specs to
>    match X3D 4.0, thank you.
>    - X3D Standards Progress https://www.web3d.org/x3d/progress
>    - *Stable repeatable progress *for users, modelers, and software
>       developers requires the steady evolution of the X3D Graphics and Humanoid
>       Animation (HAnim) International Standards.  Web3D Consortium members
>       produce well-written, well-tested specification documents that define and
>       refine the X3D and HAnim standards as they continue to improve.  Onward we
>       go!
>       - Our strategy for consolidation of all X3D Specifications to match
>       X3D Architecture version 4.0 is simple:
>       - update all file encodings in 2025, and
>          - update all programming-language bindings in 2026.
>
>
> Wishing best progress.  Faithfully yours.
>
>
> all the best, Don
>
> --
>
> Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
>
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA
> +1.831.656.2149
>
> X3D graphics, virtual worlds, navy robotics
> https://faculty.nps.edu/brutzman
>
>
>
> ------------------------------
> *From:* x3d-public <x3d-public-bounces at web3d.org> on behalf of Joe D
> Williams via x3d-public <x3d-public at web3d.org>
> *Sent:* Friday, March 7, 2025 8:45 PM
> *To:* x3d-public at web3d.org <x3d-public at web3d.org>
> *Cc:* Joe D Williams <joedwil at earthlink.net>
> *Subject:* [x3d-public] typescript?
>
> "TypeScript is a strongly typed programming language that builds on
> JavaScript, offering features like static typing, classes, and interfaces. "
>
> Is this typescript a tool for X3D?
>
> Thanks,
> Joe
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20250308/85186e63/attachment-0001.html>


More information about the x3d-public mailing list