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

Typescript Extensibility / Plugins #4876

Closed
nbellowe opened this issue Sep 19, 2015 · 9 comments
Closed

Typescript Extensibility / Plugins #4876

nbellowe opened this issue Sep 19, 2015 · 9 comments
Labels
Duplicate An existing issue was already created

Comments

@nbellowe
Copy link

I think typescript could benefit from some sort of plugin/extensibility system. This would allow for people to design language features that are helpful to their particular needs, without requiring a change in Typescript.

Here are a few examples of possible extensions:

  1. Add language support for defining properties with getters and setters.

    • Too big of a change, possibly not useful enough to warrant a change in Typescript, but it would be super cool if I could make a seperate npm package called typescript-properties, and anyone could pull that, and utilize it in there apps. This could maybe be an example that decorators could take care of, not sure.
    property hello:T
            compiles to
    _hello:T
    get hello():T { return this._hello }
    set hello(v:T){ this._hello = v }
    
  2. Add preprocessing to the code that doesn't break source mapping.

            #IF(DEBUG)
               expr;
            #ENDIF
    

    While this can be accomplished with external tools, it breaks source mapping. With a complex build, like:

    1. Original TS
    2. Post-pre-processed TS
    3. Compiled TS (Javascript) and sourcemaps to PPP-TS
    4. Single-file JS (may need to be ordered in optimal way) & source map to PPP-TS if the tool supports input source mapping.
    5. Minified Javascript & source map & source map to PPP-TS if the tool supports it.

    -- note(UglifyJS can optimize out constants, so defining a const DEBUG=true|false can optimize out debug code as well. if(DEBUG) expr;)

@RichiCoder1
Copy link

👍 A system that could allow plugins to perform their own passes during stages of analyization and compilation would be excellent. Babel is already proving the value of this.

@iam3yal
Copy link

iam3yal commented Sep 20, 2015

👍 Yup, this can be really awesome, there are many features that can turn into extensions and shouldn't or won't ever be part of the language but people still need/want them.

The question is how far is the compiler infrastructure from supporting such a story? I really hope that it's not that far but my guess is that if they will ever add it it's going to be after 2.0 :)

@kitsonk
Copy link
Contributor

kitsonk commented Sep 20, 2015

This is similar to #2900 and #3003. In particular #3003 discusses why a pluggable compiler/analyzer is a challenge for TypeScript at the moment.

@RichiCoder1
Copy link

Definetly agree that analyzers or things that have to plug into typescript in a high fidelity way are unlikely. But this that simply operate over the raw text would still be useful.

@tinganho
Copy link
Contributor

If there can't be super high fidelity. I don't think people mind creating analyzers based on low fidelity?

@kitsonk
Copy link
Contributor

kitsonk commented Sep 20, 2015

@RichiCoder1 then you don't need that integrated to TypeScript... This seem to be asking for some level of integration to change what is emitted at certain points as the code is processed. If all you needed to do was run over the raw text, why would you need that integrated into TypeScript? You would just use a pre-processor or a post-processor, which a lot of people do already.

@jbondc
Copy link
Contributor

jbondc commented Sep 21, 2015

Ya my interest in this is deep integration with the language service. So you could re-write/wrap any object in the compiler or language service by wrapping a proxy around it. Maybe something like this: a2f4062

There's lot of parts of TypeScript that could go in the 'extendable' scope.

@danquirk
Copy link
Member

I think #3003 covers this topic well enough. Let's just discuss it over there. A large proposal of some particular design/implementation might warrant a new issue but we already have a place to +1 this idea and chat about it.

@danquirk danquirk added the Duplicate An existing issue was already created label Sep 21, 2015
@nbellowe
Copy link
Author

Thanks!

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

7 participants