Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add jsxFactory compiler option. #11267

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

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactor factory:jsxFactory to create granular nodes for entity name.
  • Loading branch information
bradleyayers committed Oct 2, 2016
commit 49ee64d9c6230968b0a7b16fd9f2633511b5078b
23 changes: 19 additions & 4 deletions 23 src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1618,10 +1618,25 @@ namespace ts {
);
}

export function createEntityName(entityName: string) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm skeptical the implementation of this is ideal, open to suggestions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahejlsberg thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a parseIsolatedEntityName could set a flag in the parser to have it treat the source as synthetic.

const { entityName: node } = parseIsolatedEntityName(entityName);

// Parsing occurred in an isolated context, so nodes need to be synthesized
// and positions erased for correct positioning in emit.
const synthesize = (node: Node) => {
node.pos = -1;
node.end = -1;
node.flags |= NodeFlags.Synthesized;
forEachChild(node, synthesize);
};
synthesize(node);

return node;
}

export function createJsxFactory(jsxFactory: string) {
// No explicit validation of this parameter is required. Users are
// assumed to have provided a correct string.
return createIdentifier(jsxFactory);
const entityName = createEntityName(jsxFactory);
return createExpressionFromEntityName(entityName);
}

export function createReactCreateElement(reactNamespace: string | undefined, parentElement: JsxOpeningLikeElement) {
Expand All @@ -1634,7 +1649,7 @@ namespace ts {
return createPropertyAccess(react, "createElement");
}

export function createJsxFactoryCall(jsxFactory: Identifier | PropertyAccessExpression, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
export function createJsxFactoryCall(jsxFactory: Expression, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
const argumentsList = [tagName];
if (props) {
argumentsList.push(props);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.