-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-generate shield()
calls using template literal types, #23
#25
Conversation
shield()
calls using template literal types, #23
Performance shouldn't be a problem, but let's have an idea of how long the transpilation is delayed by the new transformer. Worst case we only apply the transformer for prod building. Since the user's IDE already does the type checking job in dev. We can always make this an option. |
@brillout W.r.t performance I generated this file: https://gist.github.com/louwers/392db2e700f9f597d8eecc24b7836c1f Good news, transformer disabled:
Enabled:
Which is very good for such a complex types and so many functions. So I'd say we just keep it enabled for dev mode, but monitor real-world performance. Bad news: I found that the diagnostics I use for extracting the value of template literal types gets cut off:
so I have to find a better approach. The author of ts-morph is likely on it as well: dsherret/ts-morph#1266 |
👍 We may want to have development experience that is as fast as possible development, so yea let's monitor on real world apps.
Seems like it would happen only rarely and, more importantly, deterministically though. |
Btw. a potential solution for the problem of the emit info being truncated: I can see that the threshold for truncating to be some If that's the case then it's easy to change it to some big number We pin TypeScript and check if the patch still works when we use a newer TypeScript version. |
I'm using |
assertWarning(false, `Failed to generate shield() for telefunction '${teleFunName}'`) | ||
continue | ||
} | ||
const shieldStrWithAlias = shieldStr.replace(/t\./g, `${tAlias}.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function hello(name: 'some-t.string') {
}
I believe this would break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops.
Let me know when the problem |
Awesome! 🎉 I'll let you know. |
Made an additional fix to make sure single quotation marks are escaped. |
Released in |
As discussed, a Draft MR for #23 👍
Action points:
types.ts
for the test and inside the transformer in a clean way (i.e. without using__dirname
). (SeeFIXME
insidetransform.ts
andtransformer.spec.ts
).I realized that I didn't consider optional tuple elements, so they are currently broken. This is a problem for optional function arguments:[string, null]
. Right now this is unrepresentable withshield()
. Not such a big problem because who would want this. But it should just fail to generate ashield()
call at all if someone tries.