#TypeScript & Isolation Layer
42 messages · Page 1 of 1 (latest)
Unfortunately it's a requirement I use typescript for this project
.... 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.
I understand if you dislike typescript. but unfortunately I have to use it for this project.
I love typescript - I never said otherwise ...
I apologise for assuming you didn't like it
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
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
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.
Where specifically in this video are you referring to
The whole thing, Simon discusses why typescript is not recommended, and why complicating the proxy is not a good idea.
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
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
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.
I’m trying to accomplish the second one
I just gave you the answer 😉
I’ve already found a solution
Share it here then, so others can benefit from your solution.
I found a solution about 20 minutes ago that worked using typescript
I’m open to suggestions on other ways to solve the problem
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.
First I have to see how you solved it.
How would that change anything
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.
thank you !! :)
for anyone else other than OP stumbling upon this thread and considering to add any dependencies to their isolation layer, here's the tldr on why we do not recommend this: https://tauri.app/v1/references/architecture/inter-process-communication/isolation#recommendations