I’ve noticed that when I refactor my PG snippets, I often lose intellisense in extracted methods and the like. When I add standard TS type notations e.x:
function(engine: BABYLON.Engine), I get working intellisense as expected, but I then of course start getting JS console errors:
Uncaught SyntaxError: Unexpected identifier
I’m wondering: what is the best way to provide type hints encapsulated code in JS snippets, given that the syntax errors logged to the console do not appear to interfere with the overall scene. Here’s a PG example of using the TS hints to get intellisense - I used the latest version of Edge:
Revision #0UYAPE#1 lacks those type hints - in the constructor for AppStartScene intellisense is unable to provide meaningful results.
it appears that if I refresh my browser I now get the whole i.initFunction is not a function error you get when you try to TS in JS.
Well JS does not support types so you cannot have stuff like “scene: BABYLON.Scene” unfortunately
When running in JS mode, the playground can iterate types by looking at the new operators only (or by looking at the types returned by a function call)
Yeah, that is about what I would expect, and that makes sense. I guess I’m wondering if I’m doing something wrong when something like this doesn’t subsequently provide intellisense:
this.scene = new BABYLON.Scene(engine);
this.scene /./ no type inferred
THis should work can you share a PG where it does not?
The snippet is linked in the image
This is because of the class. It forces the scene to be declared as any
Ugh, I was hoping you wouldn’t say that
Since the intellisense is a TS service, could the tsconfig maybe be modified to output in es6?
I’ve been exploring the intellisense limitations a bit more. I’ve found that intellisense seems not to be able to resolve any types that are not declared via
let statement - no matter the closure context - as seen in the image, the scope is a local function.
Is this expected behavior? My intuition says that intellisense should be able to track a known type being assigned to an object field, but is there something I am missing that invalidates this assumption?
We are not writing the intelisense code (It is coming from project Monaco)