-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add support for transpiling per-file jsx pragmas #21218
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4d3143
Add support for per-file jsx pragmas
weswigham 52a6f22
Add error for using jsx factory pragma with fragments
weswigham fa36640
Merge branch 'master' into multiple-jsx-factories
weswigham 3abda0a
More tests, use different regex class for pragma capture
weswigham 8d5c733
Unify all pragma parsing machinery
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//// [tests/cases/conformance/jsx/inline/inlineJsxFactoryDeclarations.tsx] //// | ||
|
||
//// [renderer.d.ts] | ||
declare global { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
[e: string]: any; | ||
} | ||
} | ||
} | ||
export function dom(): void; | ||
export function otherdom(): void; | ||
export { dom as default }; | ||
//// [other.tsx] | ||
/** @jsx h */ | ||
import { dom as h } from "./renderer" | ||
export const prerendered = <h></h>; | ||
//// [othernoalias.tsx] | ||
/** @jsx otherdom */ | ||
import { otherdom } from "./renderer" | ||
export const prerendered2 = <h></h>; | ||
//// [reacty.tsx] | ||
import React from "./renderer" | ||
export const prerendered3 = <h></h>; | ||
|
||
//// [index.tsx] | ||
/** @jsx dom */ | ||
import { dom } from "./renderer" | ||
<h></h> | ||
export * from "./other"; | ||
export * from "./othernoalias"; | ||
export * from "./reacty"; | ||
|
||
|
||
//// [other.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
/** @jsx h */ | ||
var renderer_1 = require("./renderer"); | ||
exports.prerendered = renderer_1.dom("h", null); | ||
//// [othernoalias.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
/** @jsx otherdom */ | ||
var renderer_1 = require("./renderer"); | ||
exports.prerendered2 = renderer_1.otherdom("h", null); | ||
//// [reacty.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var renderer_1 = require("./renderer"); | ||
exports.prerendered3 = renderer_1["default"].createElement("h", null); | ||
//// [index.js] | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
exports.__esModule = true; | ||
/** @jsx dom */ | ||
var renderer_1 = require("./renderer"); | ||
renderer_1.dom("h", null); | ||
__export(require("./other")); | ||
__export(require("./othernoalias")); | ||
__export(require("./reacty")); |
68 changes: 68 additions & 0 deletions
68
tests/baselines/reference/inlineJsxFactoryDeclarations.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
=== tests/cases/conformance/jsx/inline/renderer.d.ts === | ||
declare global { | ||
>global : Symbol(global, Decl(renderer.d.ts, 0, 0)) | ||
|
||
namespace JSX { | ||
>JSX : Symbol(JSX, Decl(renderer.d.ts, 0, 16)) | ||
|
||
interface IntrinsicElements { | ||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
|
||
[e: string]: any; | ||
>e : Symbol(e, Decl(renderer.d.ts, 3, 13)) | ||
} | ||
} | ||
} | ||
export function dom(): void; | ||
>dom : Symbol(dom, Decl(renderer.d.ts, 6, 1)) | ||
|
||
export function otherdom(): void; | ||
>otherdom : Symbol(otherdom, Decl(renderer.d.ts, 7, 28)) | ||
|
||
export { dom as default }; | ||
>dom : Symbol(default, Decl(renderer.d.ts, 9, 8)) | ||
>default : Symbol(default, Decl(renderer.d.ts, 9, 8)) | ||
|
||
=== tests/cases/conformance/jsx/inline/other.tsx === | ||
/** @jsx h */ | ||
import { dom as h } from "./renderer" | ||
>dom : Symbol(h, Decl(other.tsx, 1, 8)) | ||
>h : Symbol(h, Decl(other.tsx, 1, 8)) | ||
|
||
export const prerendered = <h></h>; | ||
>prerendered : Symbol(prerendered, Decl(other.tsx, 2, 12)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
|
||
=== tests/cases/conformance/jsx/inline/othernoalias.tsx === | ||
/** @jsx otherdom */ | ||
import { otherdom } from "./renderer" | ||
>otherdom : Symbol(otherdom, Decl(othernoalias.tsx, 1, 8)) | ||
|
||
export const prerendered2 = <h></h>; | ||
>prerendered2 : Symbol(prerendered2, Decl(othernoalias.tsx, 2, 12)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
|
||
=== tests/cases/conformance/jsx/inline/reacty.tsx === | ||
import React from "./renderer" | ||
>React : Symbol(React, Decl(reacty.tsx, 0, 6)) | ||
|
||
export const prerendered3 = <h></h>; | ||
>prerendered3 : Symbol(prerendered3, Decl(reacty.tsx, 1, 12)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
|
||
=== tests/cases/conformance/jsx/inline/index.tsx === | ||
/** @jsx dom */ | ||
import { dom } from "./renderer" | ||
>dom : Symbol(dom, Decl(index.tsx, 1, 8)) | ||
|
||
<h></h> | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19)) | ||
|
||
export * from "./other"; | ||
export * from "./othernoalias"; | ||
export * from "./reacty"; | ||
|
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/inlineJsxFactoryDeclarations.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
=== tests/cases/conformance/jsx/inline/renderer.d.ts === | ||
declare global { | ||
>global : any | ||
|
||
namespace JSX { | ||
>JSX : any | ||
|
||
interface IntrinsicElements { | ||
>IntrinsicElements : IntrinsicElements | ||
|
||
[e: string]: any; | ||
>e : string | ||
} | ||
} | ||
} | ||
export function dom(): void; | ||
>dom : () => void | ||
|
||
export function otherdom(): void; | ||
>otherdom : () => void | ||
|
||
export { dom as default }; | ||
>dom : () => void | ||
>default : () => void | ||
|
||
=== tests/cases/conformance/jsx/inline/other.tsx === | ||
/** @jsx h */ | ||
import { dom as h } from "./renderer" | ||
>dom : () => void | ||
>h : () => void | ||
|
||
export const prerendered = <h></h>; | ||
>prerendered : any | ||
><h></h> : any | ||
>h : () => void | ||
>h : () => void | ||
|
||
=== tests/cases/conformance/jsx/inline/othernoalias.tsx === | ||
/** @jsx otherdom */ | ||
import { otherdom } from "./renderer" | ||
>otherdom : () => void | ||
|
||
export const prerendered2 = <h></h>; | ||
>prerendered2 : any | ||
><h></h> : any | ||
>h : any | ||
>h : any | ||
|
||
=== tests/cases/conformance/jsx/inline/reacty.tsx === | ||
import React from "./renderer" | ||
>React : () => void | ||
|
||
export const prerendered3 = <h></h>; | ||
>prerendered3 : any | ||
><h></h> : any | ||
>h : any | ||
>h : any | ||
|
||
=== tests/cases/conformance/jsx/inline/index.tsx === | ||
/** @jsx dom */ | ||
import { dom } from "./renderer" | ||
>dom : () => void | ||
|
||
<h></h> | ||
><h></h> : any | ||
>h : any | ||
>h : any | ||
|
||
export * from "./other"; | ||
export * from "./othernoalias"; | ||
export * from "./reacty"; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we gonna add a new concept, then we should consolidate the other ones under pargma.. and we should allow
///
as well as multi-line comments.I would also have helper functions for getting all of these like amdDependecies, amdModuleNAme, checkJs, etc..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I wanted to consolidate them, anyway, just didn't think this PR was appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to ensure this works well when doing incremental parsing as well and need test for the same.