#TypeScript & Isolation Layer

42 messages · Page 1 of 1 (latest)

south oracle
#

For Tauri isolation - just use a js file.

#

No reason to use typescript, and no reason to complicate it.

woven belfry
#

Unfortunately it's a requirement I use typescript for this project

south oracle
#

.... When is it ever a requirement? Typescript is just a Dev tool, no real reason to use it for isolation. It adds no value and just complicates matters. Check out Simon's YouTube video on the matter.

woven belfry
#

I understand if you dislike typescript. but unfortunately I have to use it for this project.

south oracle
#

I love typescript - I never said otherwise ...

woven belfry
#

I apologise for assuming you didn't like it

south oracle
#

I am going to make this very clear - the Tauri isolation layer is not designed or intended to be used with typescript. It's a proxy for intercepting calls to the backend. You don't need typescript for it, and it's better not to use typescript.

Please see this video for more details 🙂
https://youtu.be/6K1_LQV_Vb4

Today we'll be looking at the "Isolation Pattern" feature in Tauri. It's buried a bit deeper down in the documentation currently, but it's easy to add and you never really have a reason not to.
https://tauri.app/v1/references/architecture/inter-process-communication/isolation

❤️ Sponsor me ❤️
https://github.com/sponsors/simonhyll

▶ Play video
woven belfry
#

I've been asked to use typescript on this project

#

If you don't believe typescript is a good idea for me to use then that's okay

#

However, I'm looking for a response to the question I asked

south oracle
#

It has nothing to do with what I believe - I am telling you the answer to your question. There is no work around - typescript will only cause trouble in the isolation proxy.

woven belfry
#

Where specifically in this video are you referring to

south oracle
#

The whole thing, Simon discusses why typescript is not recommended, and why complicating the proxy is not a good idea.

woven belfry
#

I think I understand

#

Unfortunately it's not my decision

south oracle
#

A single js file is not allowed? That seems overly controlling

#

Typescript is transpiled to js anyways ...

#

At the end of the day - everything is JS

woven belfry
#

The proxy - even if it's good practice to not overcomplicate it - is going to be complicated in this project

#

I've been asked to use ts to reduce the risk of things biting us in the back later on down the line

#

Again, it's not my decision and it's not going to affect anything

#

I'm just looking for a solution to the question I asked

south oracle
#

Sure, that's your prerogative.

You've been given your solution.

#

The only way to solve your issue is to 1. Not use typescript in the isolation layer
2. Learn typescript better to understand why the error is occuring

#

I would bet that the error is only in the IDE, as it's a linting issue with the window object not having the polyfilled Tauri APIs on it.

woven belfry
#

I’m trying to accomplish the second one

south oracle
#

I just gave you the answer 😉

woven belfry
#

I’ve already found a solution

south oracle
#

Share it here then, so others can benefit from your solution.

woven belfry
#

I found a solution about 20 minutes ago that worked using typescript

#

I’m open to suggestions on other ways to solve the problem

south oracle
#

The only "solutions" are to use the array syntax, which will circumvent the null checks on the window object, or configure custom linter settings.

#

None of those are solutions, they just ignore the issue and remove the whole purpose of using typescript.

south oracle
woven belfry
#

How would that change anything

south oracle
#

because the window is an object, typescript is complaining that it can't find a member. So, use the array syntax to circumvent the null check.

#
window["__TAURI_ISOLATION_HOOK__"] = 
#

example:

#

That passes fine for me - no errors or issues.

woven belfry
#

thank you !! :)

glass river