<div dir="ltr">I haven't figured out how to do imports in TypeScript yet.   Contributions for setter and constructor validation code welcome!<div>Here's what I've got so far:</div><div><br></div><div>John</div><div><br></div><div>    def settervalidate(self, field, name):<br>        fld = self.getField(name)<br>        str = ""<br>        rel = { 'minInclusive':" < ",<br>                 'maxInclusive':" > ",<br>                 'minExclusive':" <= ",<br>                 'maxExclusive':" >= "}<br>        for k,v in rel.items():<br>            try:<br>                if field.get('type').startswith("MF") or field.get('type') == "SFColor" or field.get('type') == "SFVec2f" or field.get('type') == "SFVec3f":<br>                    str += "        if ("+fld+" == null || "+fld+".length <= 0 || Math."+k[0:3] +"("+fld+") " + v + " " + field.get(k) + ") {\n"<br>                    str += "            return undefined;\n\t}\n"<br>                else:<br>                    str += "        if ("+fld+" == null || "+fld+" " + v + " " + field.get(k) + ") {\n"<br>                    str += "            return undefined;\n\t}\n"<br>            <br>            except:<br>                pass<br><br>        try:<br>            if field.get('additionalEnumerationValuesAllowed') != "true":<br>                enumerations = field.iter("enumeration")<br>                efound = 0<br>                for enum in enumerations:<br>                    if efound == 0:<br>                        str += "        if (" + "'"+enum.get('value')+"'" + ' === '+fld+') {\n'<br>                        efound = 1<br>                    else:<br>                        str += "        } else if (" + "'"+enum.get('value')+"'" + ' === '+fld+') {\n'<br>                if efound == 1:<br>                    if enum.get('use') == 'required':<br>                        str +=     "        } else if (" + "'"+enum.get('use')+"'" +" === 'required') {\n"<br>                        str +=     "            console.error('"+field.get('name')+" required, but does not have legal value (undefined?)');\n"<br>                        str +=     "            return undefined;\n"<br>                    str +=     "        }\n"<br>        except KeyError:<br>            pass<br>#        if field.get('type') == 'SFVec2d':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 2 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFVec2f':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 2 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFVec3d':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 3 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFVec3f':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 3 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFColor':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 3 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFRotation':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 4 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'SFColorRGBA':<br>#                    str += "        if ("+fld+" == null || "+fld+".length !== 4 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'MFVec2d':<br>#                    str += "        if ("+fld+" == null || "+fld+".length % 2 !== 0 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'MFVec2f':<br>#                    str += "        if ("+fld+" == null || "+fld+".length % 2 !== 0 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'MFVec3d':<br>#                    str += "        if ("+fld+" == null || "+fld+".length % 3 !== 3 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>#        elif field.get('type') == 'MFVec3f':<br>#                    str += "        if ("+fld+" == null || "+fld+".length % 3 !== 3 ) {\n"<br>#                    str += "            return undefined;\n"<br>#                    str += "        }\n"<br>        return str<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 16, 2020 at 6:18 PM Cecile Muller <<a href="mailto:contact@wildpeaks.fr">contact@wildpeaks.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Good evening,</div><div dir="ltr"><br><div><br></div><div>As a data point, I would highly recommend Typescript: it has solid tooling and, for example, saves a lot of time<br>by providing immediate feedback while you're typing (in editors with intellisense).<br><br>And if you worry about adding a transpilation step, know that you can also run it directly using "ts-node" package:</div><div><a href="https://www.npmjs.com/package/ts-node" target="_blank">https://www.npmjs.com/package/ts-node</a></div><div><br></div><div>Example:</div><div>  node -r ts-node/register/transpile-only src/script.ts<br><br><br>See you,</div><div>Cecile</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 16, 2020 at 5:16 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am checking parameters for range, enum, length, not type(s) yet, ... what else is there for setter and constructor parameter checking?<div><br></div><div>My first gulp would be to give parameters to their types, ala TypeScript.  That would be one way to solve the parameter type problem. Is it OK to convert my ES6 x3d.mjs module to TypeScript? Those who are against the coffee languages might approve.</div><div><br></div><div>I can see that the X3DUOM supports multiple types for parameters. It looks like TypeScript allows overloading as well.</div><div><br></div><div>Thanks,</div><div><br></div><div>John</div></div>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div>