Skip to content

Create JSX Text with factory #29425

Closed
Closed

Description

@Kingwl

Search Terms

Tsx, Factory

Suggestion

i'd like to create a tsx ast by factory, but i cann't make it easy

  1. JSXText Node have not the factory and there are not text hold in it
  2. JsxFragmentOpenning and JSXFragmentClose*** Node do not have the factory too
  • could we extend JSXText that such a JSXTextWithText?
  • could we writeup more factory (JsxFragmentOpenning )

Use Cases

Examples

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Activity

  1. added
    Needs Investigation
    on Jan 15, 2019
  2. RyanCavanaugh commented on Jan 15, 2019

    @RyanCavanaugh
    Member

    Wesley Wigham (@weswigham) thoughts? I haven't looked at this since we added fragment support so I'm not clear on the request

  3. weswigham commented on Jan 15, 2019

    @weswigham
    Member

    It's just an ask for public functions in our factory.ts file for creating/updating these node kinds. It's not a big deal and easy for us to do; we probably never added them since we didn't need them as our own jsx transform translates them to different kinds of AST nodes.

  4. ajafff commented on Jan 15, 2019

    @ajafff
    Contributor

    To correctly create synthesized JsxText Nodes, there needs to be a text property on JsxText. Currently there's no property with information about the content of this node.

    Adding such a property also requires changes in the parser.

  5. added
    Suggestion
    Domain: API
    and removed
    Needs Investigation
    on Jan 15, 2019
  6. Kingwl commented on Jan 16, 2019

    @Kingwl
    ContributorAuthor

    I'm not sure that why JSXText does not hold the text, does that any reason?

  7. weswigham commented on Jan 16, 2019

    @weswigham
    Member

    None of our nodes really contain their text - identifiers get a name set because it's checked so often, same with literals. JSX text just isn't as meaningful and so anytime it's needed it's just sliced out of the containing source file.

  8. weswigham commented on Jan 16, 2019

    @weswigham
    Member

    (It's probably correct to move JSX text into the category of literals and give it an updatable value member.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: APISuggestion

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions