Skip to content
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

TS Intellisense Generation doesn't support inheritance #495

Closed
craigktreasure opened this issue Jan 15, 2014 · 13 comments
Closed

TS Intellisense Generation doesn't support inheritance #495

craigktreasure opened this issue Jan 15, 2014 · 13 comments

Comments

@craigktreasure
Copy link

In the case of the following two classes where the two classes are in two different files:

public class BaseClass {
    public string Title { get; set; }
}
public class Model: BaseClass {
    public string SomeProp { get; set; }
}

It would be nice if the Intellisense file added an "extends BaseClass". It doesn't currently, which means you lose the properties in BaseClass.

@SLaks
Copy link
Collaborator

SLaks commented Jan 15, 2014

Emitting this in JS would be more complicated; we'd need to pick an inheritance paradigm. (probably http://blog.slaks.net/2013-09-03/traditional-inheritance-in-javascript/)

@DerAlbertCom
Copy link
Contributor

In TS it would be not so hard. But first we should do a Bundle or per Folder generation of multiple TS/JS Files files.
The JS/Files are only for Intellisens so that we can simply pick one which is understood by Visual Studio. We can simple generate a JS Function with all the properties and no inheritence.

@SLaks
Copy link
Collaborator

SLaks commented Jan 15, 2014

The JS files are not only used by VS; if you write new SomeType(), that will only work at runtime if the generated JS file is included.

@DerAlbertCom
Copy link
Contributor

Then we must support several inheritance styles 🌵

@nicholashead
Copy link

This is literally the only thing holding us back from using the auto-generated TypeScript feature. Forgive me, but can't this just be implemented for TypeScript for now (using the "extends" keyword) and leave it out of the JS definition files? It doesn't seem to make sense to hold back half of this feature.

@craigktreasure
Copy link
Author

Couldn't agree more. I'm getting tired of having to edit the generated file every time i touch a class.

@DerAlbertCom
Copy link
Contributor

@nicholashead @craigktreasure the power of open source, simple add it (don't forgert the unit tests) ;)

If nobody take this, i will do it, next week.

@nicholashead
Copy link

@DerAlbertCom - yep, for sure. I'm not demanding it or anything! Just adding a +1 to the idea of someday supporting it in TypeScript.

@am11
Copy link
Contributor

am11 commented Apr 21, 2014

In IntellisenseParser.ProcessClass(_, __), we can use something like:

IEnumerable<CodeClass> baseClasses = cc.Bases.Cast<CodeClass>()
                                       .Where(c => c.FullName != "System.Object");

to collect base classes.

Couple of questions:

  • Should we generate a separate intellisense file for each base class, same as the current class?
    • Should we generate intellisense for the entire base-class file or just the base class element (in situations where base class is in a file with multiple classes)?
  • Should we stop at immediate ancestor or keep collecting parents until it hits System.Object?
  • Should we consider interfaces / abstract classes or ignore them?
    • What will happen in multiple interface inheritance scenario?
    • What is the expected behavior for virtual and override properties?

am11 added a commit to am11/WebEssentials2013 that referenced this issue Apr 24, 2014
* New feature added.
* Works for both TypeScript and JavaScript.
@am11
Copy link
Contributor

am11 commented Apr 24, 2014

This is implemented by 73da2b1.

Please test with this build http://1drv.ms/1fv87dl.

madskristensen added a commit that referenced this issue Apr 24, 2014
CodeGeneration: Added inheritance support for intellisense (#495)
am11 added a commit to am11/WebEssentials2013 that referenced this issue Apr 24, 2014
* New feature added.
* Works for both TypeScript and JavaScript.
@am11
Copy link
Contributor

am11 commented Apr 25, 2014

@madskristensen, this is fixed. Please release a nightly, so peeps can test it. :)


@craigktreasure, @DerAlbertCom, @nicholashead, @MissFishie, @gcastre: Please test this feature in (upcoming) nightly. We need to fix as many bugs as possible before the next stable release.

Also, please contribute adding the test cases (especially the tricky ones, recursive file reference, with multiple classes etc.) and other OOP scenarios where it could choke. I handled some which I could think of. But I suspect there must be some crafty ways to bring it down to its knees. ⬇️

TIA.

@madskristensen
Copy link
Owner

I just released 2.0.9. Thanks

@am11
Copy link
Contributor

am11 commented Apr 26, 2014

Great! Thanks.

Sent from my Windows Phone


From: Mads Kristensenmailto:[email protected]
Sent: ‎4/‎26/‎2014 3:16 AM
To: madskristensen/WebEssentials2013mailto:[email protected]
Cc: Adeel Mujahidmailto:[email protected]
Subject: Re: [WebEssentials2013] TS Intellisense Generation doesn't support inheritance (#495)

I just released 2.0.9. Thanks


Reply to this email directly or view it on GitHub:
#495 (comment)

SLaks pushed a commit to SLaks/WebEssentials2013 that referenced this issue May 13, 2014
* New feature added.
* Works for both TypeScript and JavaScript.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants