-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat: generate types for extern
declarations
#5967
Conversation
Thanks for opening this pull request! 🎉
|
Console preview environment is available at https://wing-console-pr-5967.fly.dev 🚀 Last Updated (UTC) 2024-03-17 20:32 |
BenchmarksComparison to Baseline 🟥🟥⬜⬜🟥⬜🟥⬜🟥⬜⬜🟥⬜
⬜ Within 1.5 standard deviations Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI. Results
Last Updated (UTC) 2024-03-17 20:37 |
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
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.
Cooooool
Thanks for contributing, @MarkMcCulloh! This PR will now be added to the merge queue, or immediately merged if |
Congrats! 🚀 This was released in Wing 0.61.13. |
@@ -4,7 +4,7 @@ class MyResource { | |||
api: cloud.Api; | |||
url: str; | |||
|
|||
extern "./url_utils.js" pub static inflight isValidUrl(url: str): bool; | |||
extern "./url_utils.ts" pub static inflight isValidUrl(url: str): bool; |
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.
@MarkMcCulloh Just checking, so we've decided to officially support *.ts files? Should we note this in the documentation or language spec somewhere? (I'm cool with the choice, just wanna check if we're tracking it somewhere :^))
pub fn is_extern_file(file: &Utf8PathBuf) -> bool { | ||
if let Some(ext) = file.extension() { | ||
match ext { | ||
"js" | "cjs" | "mjs" | "jsx" | "ts" | "cts" | "mts" | "tsx" => true, |
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.
Who woulda thunk a single language would result in so many file extensions / formats
Closes #5868 (except the static part, but that's not critical for the use-case)
Compiling a wing project will now generate .d.ts files for the contract between wing and extern files. These .d.ts files are fully self-contained.
The code for this looks similar to existing dtsification code, but there are couple important distinctions that made it feel useful to separate it:
Misc:
examples
externs into typescript (I would love to do the rest, but need Using ESM in external preflight function fails #3013)Note that this may be a breaking change: extern types must be consistent. So in one class you refer to an extern as returning a
str
and in another it returns a Json, that will now be a compiler error.By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.