-
Notifications
You must be signed in to change notification settings - Fork 11
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
Inheritance class becomes TypeError in load order. #27
Comments
Can you please put the code that is wrong in the GitHub issue? Please provide a simple test case. |
@grant thank you for confirmation. I'm not good at English, so it is difficult to explain. So I decided to show the source code. My explanation may not have been enough. This sample presented by me is a simple test case. Please also check the README. If you want to build a project from scratch, please create the following class configuration. Create a normal projectAClass.ts export class AClass {
// (omission)
} BClass.ts import { AClass } from './AClass';
export class BClass extends AClass {
// (omission)
} Create a abnormal projectSwap class names(file names). Specifically, it is as follows. The difference is only to reverse the parent-child relationship. AClass.ts import { BClass } from './BClass';
export class AClass extends BClass {
// (omission)
} BClass.ts export class BClass {
// (omission)
} Perhaps we need a function to automatically determine load order by parsing import. I currently avoid the problem by devising the class name, but I strongly hope that loading order will be improved. |
I cannot debug your project's code. Please tell me the exact problem with |
There seems to be a misunderstanding, but I created a sample repository just to report you this issue. I know that filePushOrder exists in the config. It is actually specified in this sample, but it does not seem to work effectively. Also, when the number of files increases, manual priority setting is very troublesome.(I know I don't have to specify all the files) It looks like it is loaded in alphabetical order at runtime on GAS, regardless of the order in which Clasp pushes. In other words, class A is always load before class B. This is the issue. |
@jakenjarvis can you please share a link to the gas project that I can inspect? Also I need to ask you, why do you use If the purpose is to organise your gas code in separate namespaces, I would advise on using the |
@PopGoesTheWza Thank you for your reply.
I forgot the details, but I couldn't get it to work that way. Maybe my understanding was lacking, but the namespace statements were different from those of C# I had imagined. The main reason I would like to use TypeScript is to do object-oriented programming. Managing files separately for each class is a common form. |
@jakenjarvis my knowledge of TypeScript for Google Apps Script is still empirical. Still, from my experience, With a "standard" gas project with multiple To illustrate https://github.com/PopGoesTheWza/swgoh-help-api To illustrate https://github.com/PopGoesTheWza/swgoh-tb-sheets All the above may or may not address your original issue. I will try to give a closer look later on. |
Hi, @PopGoesTheWza
Using a namespace statement will probably not improve the issue.
I have long been familiar with object-oriented programming in other programming languages, and most of my source code is class definitions and Interface definitions. Even when all script files are added to the global namespace, code containment has already been achieved. So I'm not very worried about it. I know this is changing the subject, I read the source code of your project lightly. There are many things to learn and it was very helpful. Thank you. var client = new swgohhelpapi.module.exports.Client(settings); I was a little surprised that I could access it this way, because I was not consciously reading at the source code after transpile. I did not think about this deeply. var exports = exports || {};
var module = module || { exports: exports }; For me, this existed without thinking. XD |
Hi, @PopGoesTheWza @grant I tried a sample that uses namespace statements, but still this issue is not solved. And I tried a couple of different ways of writing, but they all had the same issue. This proves that there is no problem in the way of writing. Issue01This is the first sample I posted.export class AClass {
// (omission)
} import { AClass } from './AClass';
export class BClass extends AClass {
// (omission)
}
Issue01-2Created a project excluding import and export.class AClass {
// (omission)
} class BClass extends AClass {
// (omission)
}
Issue01-3Created a project each was used with a separate namespace statement.namespace nameA {
export class AClass {
// (omission)
}
} namespace nameB {
export class BClass extends nameA.AClass {
// (omission)
}
}
Issue01-4Created a project each was used with a same namespace statement.namespace nameAB {
export class AClass {
// (omission)
}
} namespace nameAB {
export class BClass extends nameAB.AClass {
// (omission)
}
}
|
Hello @jakenjarvis
"filePushOrder": ["src/BClass.ts", "src/AClass.ts", "src/code.ts"]
Thus my conclusion is:
@grant please review the above and advise. My opinion would be to open a |
@PopGoesTheWza Thank you for your code review. I felt the issue was finally reported to you.
Yes I know it. So I pointed out that the loading order is the issue.
I did not look at it carefully.
Currently this issue status is closed but it should be reopened. |
Thanks @jakenjarvis |
Thanks @PopGoesTheWza |
Just because the inherited class has a different loading order(alphabetical), it becomes "TypeError: Cannot read property 'prototype' of undefined". Screen shot
I created a sample project to convey this.
Expected Behavior
case OK:
https://github.com/jakenjarvis/clasp-ts-sample/tree/master/IssueSample/Issue01/ProjectNormal
Actual Behavior
case NG:
https://github.com/jakenjarvis/clasp-ts-sample/tree/master/IssueSample/Issue01/ProjectAbnormal
TypeError: Cannot read property 'prototype' of undefined (line 14, file "AClass")
Steps to Reproduce the Problem
Specifications
I posted the same issue here(Clasp#527). I was urged to instead Issue to ts2gas.
The text was updated successfully, but these errors were encountered: