GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add support for transpiling per-file jsx pragmas by weswigham · Pull Request #21218 · microsoft/TypeScript Conversation
|
|
Ben Lichtman (@uniqueiniquity) A similar error is now present when a fragment is used alongside an inline jsx pragma. 🌞 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mohamed Hegazy (@mhegazy) Do you wanna give this a brief look-over before it's merged? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| export function dom(): void; | ||
| // @filename: index.tsx | ||
| /** @jsx dom */ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
add a test with ** @jsx React.createElement */
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const referencedFiles: FileReference[] = []; | ||
| const typeReferenceDirectives: FileReference[] = []; | ||
| const amdDependencies: { path: string; name: string }[] = []; | ||
| let pragmas: { pragma: string, value: string | undefined }[] = []; |
There was a problem 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..
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (file.localJsxNamespace) { | ||
| return file.localJsxNamespace; | ||
| } | ||
| const jsxPragma = file.pragmas.get("jsx"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
why is it jsx and not jsxNamespace like the compiler option?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Babel supports jsx and I figured we'd want to support the same thing - we can alias jsxNamespace, if you'd like?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
| export function dom(): void; | ||
| // @filename: index.tsx |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
also add a test with two files, and @jsxNamespace defined, and one of them with the new pragma.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
7a7f20e to
3abda0a
Compare
There was an error while loading. Please reload this page.
|
Mohamed Hegazy (@mhegazy) Sheetal Nandi (@sheetalkamat) I've unified all pragma-parsing infrastructure such that new pragmas can be added just by editing an object literal, alternate syntaxes enabled, etc - also this PR is much larger now. (And a bit off topic, which is why I wanted to do it later, but w/e, it's here now) Mohamed Hegazy (@mhegazy) Which old/new pragmas did you want to allow under which syntaxes (XML-like triple slash, singleline @-pragma or multiline @-pragma)? (So I can update their config and add tests of the alternate forms) I imagine we can be permissive and any ones we don't consider legacy we could allow under all the syntaxes we like, so users don't have to remember which syntax we actually parse. Sheetal Nandi (@sheetalkamat) I think now that I've unified the implementations, incremental is handled correctly - |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| const jsxPragma = file.pragmas.get("jsx"); | ||
| if (jsxPragma) { | ||
| const chosenpragma = isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
why not set this one in processPragmasIntoFields like the other ones, just for consistency.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It pretty much maps to localJsxFactory, its calculation is just deferred.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I could move the calculation (and make it eager) from the checker into the parser, if you'd like.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.