You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a library that is written in Typescript but crosspiles to Python using jsii. While the Python API works, I would like the language server to behave nicely with the written Python code. In this specific instance, the problem can boiled down to this example that mimics the Python output code from jsii:
Then if I type the line:
The language server complains, because the return type of Base.foo is Base and so it doesn't recognize .bar as a valid method for the object.
Alternatively, if I write these class definitions without the explicit return type for self:
I get no red lines from the language server, in addition to getting the proper autocomplete options which show both classes' methods.
To reiterate, the code in the image works when I execute the file, I am looking to getting the resulting Python code to work nicely with the language server and show results intuitively to anyone using the library.
Is there a way for jsii to omit the return types for this scenario, for where the original TS code does not specify a return type as well?
guidanceQuestion that needs advice or information.needs-triageThis issue or PR still needs to be triaged.
1 participant
Converted from issue
This discussion was converted from issue #3330 on March 31, 2022 23:37.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
❓ Guidance
Affected Languages
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)Go
The Question
I'm using a library that is written in Typescript but crosspiles to Python using
jsii
. While the Python API works, I would like the language server to behave nicely with the written Python code. In this specific instance, the problem can boiled down to this example that mimics the Python output code fromjsii
:Then if I type the line:
The language server complains, because the return type of
Base.foo
isBase
and so it doesn't recognize.bar
as a valid method for the object.Alternatively, if I write these class definitions without the explicit return type for
self
:I get no red lines from the language server, in addition to getting the proper autocomplete options which show both classes' methods.
To reiterate, the code in the image works when I execute the file, I am looking to getting the resulting Python code to work nicely with the language server and show results intuitively to anyone using the library.
Is there a way for
jsii
to omit the return types for this scenario, for where the original TS code does not specify a return type as well?Beta Was this translation helpful? Give feedback.
All reactions