Path to TypeScript scripts source code, forgetting where they are

I keep forgetting where the TypeScript scripts source code is stored. I’m used to keeping scripts in a _Scripts folder in the Assets folder. Perhaps, when generating the C# source code, you can add in the comments of the C# file the path to where the original TypeScript source code is stored.

In the Needle Engine Samples project, the scripts used in the samples are stored in a separate folder from where we add our own scripts. (I’m just putting a comment with the path in a file in my usual _Scripts folder to keep reminding me where to find the TypeScript sources.)

There may be reasons not to add that to the C# source code as it might become out of date. But, I can’t imagine that happening very often.

Original Post on Discord

by user 581381221087445033

There’s two places where your code can be:

  • in the “src” folder in your Web Project → generated C# files are in Needle.Generated
  • in an NpmDef (recommended) → generated C# files are next to it

In either case, clicking on these blue labels with :arrow_upper_right: will open a workspace with that script file:

So from your C# components it should always be very easy to “go to the source”

Let me know if that helps - and also what we can make clearer about this in the docs! Thanks for the feedback about usability!

I didn’t know that. This helps a lot! Thank you for this instructional time.

Maybe put .ts on the end of the script link name. That would be a stronger hint I think.

If the script is in a .ts file with a different name, maybe put “(~.ts)” on the end of the script link name.

I’m sure whatever you decide will be better than my suggestions.

It’s my muscle memory to just right click the script component title bar and select “Edit Script” from the context menu. Which always takes me to the .cs file source code.

Maybe put “Edit TypeScript” in the context menu as well if others have that same muscle memory. But don’t bother if you don’t have the time.

Clicking your link is nicer and straight to the .ts source! Thank you.

by user 581381221087445033

Good idea to include the extension and the context menu entry. Thanks!