winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.59k stars 180 forks source link

fix: unable to import JSII classes with embedded types #6362

Closed MarkMcCulloh closed 2 weeks ago

MarkMcCulloh commented 2 weeks ago

Fixes #6285 Fixes #5507

JSII allows types to be defined in classes (kinda, moreso that a class can also be a namespace), i.e assembly.class.interface. Wing does not support defining or directly referencing types like this. Previously, the JSII importer would not import these types and also would fail to import any types that come after these types in a given namespace. Some JSII libs, like aws-cdk-lib, make extensive use of these so a lot of types were not available.

Now, the JSII importer supports importing these types and other JSII types that reference them. Wing still cannot directly reference them in type annotations, but there are cases where it is used and type checked (e.g. implicit structs).

In addition, language server completion requests do a better job of eagerly importing JSII types that aren't referenced in the rest of the file

Before

image

After

image

Misc:

github-actions[bot] commented 2 weeks ago

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Slack.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon
monadabot commented 2 weeks ago

Console preview environment is available at https://wing-console-pr-6362.fly.dev :rocket:

Last Updated (UTC) 2024-04-28 14:00
monadabot commented 2 weeks ago

Benchmarks

Comparison to Baseline ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 57ms±0.56 | 58ms±0.56 | +1ms (+1.96%)⬜ | | functions_1.test.w -t sim | 411ms±22.72 | 402ms±3.67 | -8ms (-2.03%)⬜ | | functions_1.test.w -t tf-aws | 813ms±9.23 | 827ms±6.08 | +14ms (+1.76%)⬜ | | jsii_big.test.w -t sim | 2805ms±10.42 | 2807ms±14.21 | +3ms (+0.09%)⬜ | | jsii_big.test.w -t tf-aws | 3020ms±12.72 | 3014ms±10.17 | -5ms (-0.17%)⬜ | | functions_10.test.w -t sim | 492ms±11.7 | 486ms±11.72 | -6ms (-1.16%)⬜ | | functions_10.test.w -t tf-aws | 2036ms±9.82 | 2030ms±9.92 | -7ms (-0.32%)⬜ | | jsii_small.test.w -t sim | 372ms±2.97 | 372ms±4.83 | 0ms (-0.01%)⬜ | | jsii_small.test.w -t tf-aws | 608ms±3.74 | 618ms±7.27 | +10ms (+1.66%)⬜ | | empty.test.w -t sim | 361ms±3.14 | 357ms±3.99 | -4ms (-1.12%)⬜ | | empty.test.w -t tf-aws | 598ms±5.21 | 595ms±5.11 | -3ms (-0.43%)⬜ | | hello_world.test.w -t sim | 397ms±4 | 399ms±6.18 | +2ms (+0.5%)⬜ | | hello_world.test.w -t tf-aws | 1520ms±6.2 | 1514ms±6.2 | -5ms (-0.33%)⬜ | ⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations _Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI._
Results |name|mean|min|max|moe|sd| |----|----|----|----|----|----| |version|58ms|57ms|60ms|1ms|1ms| |functions_1.test.w -t sim|402ms|394ms|409ms|4ms|5ms| |functions_1.test.w -t tf-aws|827ms|814ms|840ms|6ms|8ms| |jsii_big.test.w -t sim|2807ms|2778ms|2833ms|14ms|20ms| |jsii_big.test.w -t tf-aws|3014ms|2990ms|3034ms|10ms|14ms| |functions_10.test.w -t sim|486ms|444ms|504ms|12ms|16ms| |functions_10.test.w -t tf-aws|2030ms|2007ms|2047ms|10ms|14ms| |jsii_small.test.w -t sim|372ms|362ms|381ms|5ms|7ms| |jsii_small.test.w -t tf-aws|618ms|600ms|640ms|7ms|10ms| |empty.test.w -t sim|357ms|348ms|364ms|4ms|6ms| |empty.test.w -t tf-aws|595ms|584ms|607ms|5ms|7ms| |hello_world.test.w -t sim|399ms|387ms|412ms|6ms|9ms| |hello_world.test.w -t tf-aws|1514ms|1500ms|1527ms|6ms|9ms|
Last Updated (UTC) 2024-04-28 14:05
mergify[bot] commented 2 weeks ago

Thanks for contributing, @MarkMcCulloh! This PR will now be added to the merge queue, or immediately merged if mark/jsii-fix-type-on-class is up-to-date with main and the queue is empty.

monadabot commented 2 weeks ago

Congrats! :rocket: This was released in Wing 0.73.9.