Skip to content

Commit

Permalink
More tests, use different regex class for pragma capture
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Feb 23, 2018
1 parent fa36640 commit 7a7f20e
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6189,7 +6189,7 @@ namespace ts {

function extractPragmas(text: string) {
const pragmas: { pragma: string, value: string | undefined }[] = [];
const pragmaRegEx = /@(\w+)(\W+(\w+)(\W+|$))?/gim;
const pragmaRegEx = /@(\S+)(\s+([\S]+)(\s+|$))?/gim;
let matchResult: RegExpMatchArray;
while (matchResult = pragmaRegEx.exec(text)) {
pragmas.push({ pragma: matchResult[1], value: matchResult[3] });
Expand Down
11 changes: 11 additions & 0 deletions tests/baselines/reference/inlineJsxFactoryDeclarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ declare global {
}
export function dom(): void;
export function otherdom(): void;
export function createElement(): void;
export { dom as default };
//// [otherreacty.tsx]
/** @jsx React.createElement */
import * as React from "./renderer";
<h></h>
//// [other.tsx]
/** @jsx h */
import { dom as h } from "./renderer"
Expand All @@ -32,6 +37,12 @@ export * from "./othernoalias";
export * from "./reacty";


//// [otherreacty.js]
"use strict";
exports.__esModule = true;
/** @jsx React.createElement */
var React = require("./renderer");
React.createElement("h", null);
//// [other.js]
"use strict";
exports.__esModule = true;
Expand Down
16 changes: 14 additions & 2 deletions tests/baselines/reference/inlineJsxFactoryDeclarations.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ export function dom(): void;
export function otherdom(): void;
>otherdom : Symbol(otherdom, Decl(renderer.d.ts, 7, 28))

export function createElement(): void;
>createElement : Symbol(createElement, Decl(renderer.d.ts, 8, 33))

export { dom as default };
>dom : Symbol(default, Decl(renderer.d.ts, 9, 8))
>default : Symbol(default, Decl(renderer.d.ts, 9, 8))
>dom : Symbol(default, Decl(renderer.d.ts, 10, 8))
>default : Symbol(default, Decl(renderer.d.ts, 10, 8))

=== tests/cases/conformance/jsx/inline/otherreacty.tsx ===
/** @jsx React.createElement */
import * as React from "./renderer";
>React : Symbol(React, Decl(otherreacty.tsx, 1, 6))

<h></h>
>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/other.tsx ===
/** @jsx h */
Expand Down
13 changes: 13 additions & 0 deletions tests/baselines/reference/inlineJsxFactoryDeclarations.types
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ export function dom(): void;
export function otherdom(): void;
>otherdom : () => void

export function createElement(): void;
>createElement : () => void

export { dom as default };
>dom : () => void
>default : () => void

=== tests/cases/conformance/jsx/inline/otherreacty.tsx ===
/** @jsx React.createElement */
import * as React from "./renderer";
>React : typeof React

<h></h>
><h></h> : any
>h : any
>h : any

=== tests/cases/conformance/jsx/inline/other.tsx ===
/** @jsx h */
import { dom as h } from "./renderer"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//// [tests/cases/conformance/jsx/inline/inlineJsxFactoryOverridesCompilerOption.tsx] ////

//// [renderer.d.ts]
declare global {
namespace JSX {
interface IntrinsicElements {
[e: string]: any;
}
}
}
export function dom(): void;
export { dom as p };
//// [reacty.tsx]
/** @jsx dom */
import {dom} from "./renderer";
<h></h>
//// [index.tsx]
import { p } from "./renderer";
<h></h>


//// [reacty.js]
"use strict";
exports.__esModule = true;
/** @jsx dom */
var renderer_1 = require("./renderer");
renderer_1.dom("h", null);
//// [index.js]
"use strict";
exports.__esModule = true;
var renderer_1 = require("./renderer");
renderer_1.p("h", null);
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=== 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 { dom as p };
>dom : Symbol(p, Decl(renderer.d.ts, 8, 8))
>p : Symbol(p, Decl(renderer.d.ts, 8, 8))

=== tests/cases/conformance/jsx/inline/reacty.tsx ===
/** @jsx dom */
import {dom} from "./renderer";
>dom : Symbol(dom, Decl(reacty.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))

=== tests/cases/conformance/jsx/inline/index.tsx ===
import { p } from "./renderer";
>p : Symbol(p, Decl(index.tsx, 0, 8))

<h></h>
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19))
>h : Symbol(JSX.IntrinsicElements, Decl(renderer.d.ts, 1, 19))

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
=== 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 { dom as p };
>dom : () => void
>p : () => void

=== tests/cases/conformance/jsx/inline/reacty.tsx ===
/** @jsx dom */
import {dom} from "./renderer";
>dom : () => void

<h></h>
><h></h> : any
>h : any
>h : any

=== tests/cases/conformance/jsx/inline/index.tsx ===
import { p } from "./renderer";
>p : () => void

<h></h>
><h></h> : any
>h : any
>h : any

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tests/cases/conformance/jsx/inline/index.tsx(3,1): error TS17017: JSX fragment is not supported when using an inline JSX factory pragma
tests/cases/conformance/jsx/inline/reacty.tsx(3,1): error TS17017: JSX fragment is not supported when using an inline JSX factory pragma


==== tests/cases/conformance/jsx/inline/renderer.d.ts (0 errors) ====
Expand All @@ -10,6 +11,13 @@ tests/cases/conformance/jsx/inline/index.tsx(3,1): error TS17017: JSX fragment i
}
}
export function dom(): void;
export function createElement(): void;
==== tests/cases/conformance/jsx/inline/reacty.tsx (1 errors) ====
/** @jsx React.createElement */
import * as React from "./renderer";
<><h></h></>
~~~~~~~~~~~~
!!! error TS17017: JSX fragment is not supported when using an inline JSX factory pragma
==== tests/cases/conformance/jsx/inline/index.tsx (1 errors) ====
/** @jsx dom */
import { dom } from "./renderer";
Expand Down
14 changes: 13 additions & 1 deletion tests/baselines/reference/inlineJsxFactoryWithFragmentIsError.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ declare global {
}
}
}
export function dom(): void;
export function dom(): void;
export function createElement(): void;
//// [reacty.tsx]
/** @jsx React.createElement */
import * as React from "./renderer";
<><h></h></>
//// [index.tsx]
/** @jsx dom */
import { dom } from "./renderer";
<><h></h></>

//// [reacty.js]
"use strict";
exports.__esModule = true;
/** @jsx React.createElement */
var React = require("./renderer");
React(React.Fragment, null,
React("h", null));
//// [index.js]
"use strict";
exports.__esModule = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ declare global {
export function dom(): void;
>dom : Symbol(dom, Decl(renderer.d.ts, 6, 1))

export function createElement(): void;
>createElement : Symbol(createElement, Decl(renderer.d.ts, 7, 28))

=== tests/cases/conformance/jsx/inline/reacty.tsx ===
/** @jsx React.createElement */
import * as React from "./renderer";
>React : Symbol(React, Decl(reacty.tsx, 1, 6))

<><h></h></>
>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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ declare global {
export function dom(): void;
>dom : () => void

export function createElement(): void;
>createElement : () => void

=== tests/cases/conformance/jsx/inline/reacty.tsx ===
/** @jsx React.createElement */
import * as React from "./renderer";
>React : typeof React

<><h></h></>
><><h></h></> : any
><h></h> : any
>h : any
>h : any

=== tests/cases/conformance/jsx/inline/index.tsx ===
/** @jsx dom */
import { dom } from "./renderer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ declare global {
}
export function dom(): void;
export function otherdom(): void;
export function createElement(): void;
export { dom as default };
// @filename: otherreacty.tsx
/** @jsx React.createElement */
import * as React from "./renderer";
<h></h>
// @filename: other.tsx
/** @jsx h */
import { dom as h } from "./renderer"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @jsx: react
// @jsxFactory: p
// @filename: renderer.d.ts
declare global {
namespace JSX {
interface IntrinsicElements {
[e: string]: any;
}
}
}
export function dom(): void;
export { dom as p };
// @filename: reacty.tsx
/** @jsx dom */
import {dom} from "./renderer";
<h></h>
// @filename: index.tsx
import { p } from "./renderer";
<h></h>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ declare global {
}
}
export function dom(): void;
export function createElement(): void;
// @filename: reacty.tsx
/** @jsx React.createElement */
import * as React from "./renderer";
<><h></h></>
// @filename: index.tsx
/** @jsx dom */
import { dom } from "./renderer";
Expand Down

0 comments on commit 7a7f20e

Please sign in to comment.