-
-
Notifications
You must be signed in to change notification settings - Fork 7k
typescript-jquery: Update to work with Typescript strict mode #3969
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
Conversation
f74aea4
to
e98a90e
Compare
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.
Thanks for the PR
*/ | ||
public addPet(body: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< | ||
public addPet(pet: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< |
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.
@janjongboom please run the https://github.com/OpenAPITools/openapi-generator/blob/master/bin/typescript-jquery-petstore-all.sh script, not the openapi3 version.
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.
Pushed.
@@ -39,7 +39,7 @@ export class PetApi { | |||
|
|||
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 { | |||
for (let key in objB) { | |||
if (objB.hasOwnProperty(key)) { | |||
if (objB[key]) { |
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.
where does this change come from?
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.
Hmm... That should not be there, something went wrong with rebasing. Will repush.
e98a90e
to
ff96892
Compare
@macjohnny Pushed changes as requested. |
@@ -0,0 +1,26 @@ | |||
/** | |||
* OpenAPI Petstore |
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.
Please delete this file
|
||
export interface InlineObject { | ||
/** | ||
* Updated name of the pet |
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.
Please delete this file
|
||
import * as models from './models'; | ||
|
||
export interface InlineObject1 { |
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.
Please delete this file
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.
@macjohnny Removed and re-pushed. However, these were generated by the tool, so interesting to see where they'd come from.
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.
these files are generated with the bin/openapi3/typescript-fetch-petstore-all.sh
command. the output is supposed to be the same as with bin/typescript-fetch-petstore-all.sh
, but it isn't, so it needs to be addressed in a separate issue.
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.
CI currently checks against the output of bin/typescript-fetch-petstore-all.sh
ff96892
to
06ec44b
Compare
06ec44b
to
c99fcd7
Compare
Rebased and pushed to restart tests. |
@@ -0,0 +1,26 @@ | |||
/** |
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.
please delete this file
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.
@macjohnny I'm not sure where these come from, but the file is referenced in https://github.com/OpenAPITools/openapi-generator/pull/3969/files/c99fcd7b5936800b4ef0d38e92ebd27dc86fadcb#diff-969fc1a4f92fd269b7aac842f2049bb7R15 as well. This is just the output of the build step.
*/ | ||
public async addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { |
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.
this is unrelated
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.
Similar to above. Apparently something was landed earlier but the samples weren't updated (generated by the build script). I'm happy to revert this file back to master but shouldn't samples always be reflective of the latest version of the tool?
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.
I will update your branch with the correct samples
@janjongboom I cleaned the samples in your branch. By the way: no need to re-base, PRs are squashed. |
@macjohnny OK, thanks! |
@janjongboom thanks for the PR, which has been included in v4.2.0 release: https://twitter.com/oas_generator/status/1189824932345069569 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir
Description of the PR
When compiling an API generated using the typescript-jquery generator against Typescript 3.6.2 in strict mode there are a number of issues with the generated code.
defaultExtraJQueryAjaxSettings
is of typeJQueryAjaxSettings | undefined
but is set tonull
(valid in normal mode, not valid in strict mode).extendObj
hasOwnProperty
is called onobjB
. ButobjB
is not guaranteed to be an object as it inherits from unknown typeT1
.Configuration
class are marked asstring
, but have no initializer, thus giving false safety when consuming this class (values could be undefined too).This PR adds some small guards around these issues.