Merge pull request #12135 from Microsoft/jsxFactory
Support for --jsxFactory option
This commit is contained in:
commit
c458576553
|
@ -335,6 +335,9 @@ namespace ts {
|
|||
});
|
||||
|
||||
let jsxElementType: Type;
|
||||
let _jsxNamespace: string;
|
||||
let _jsxFactoryEntity: EntityName;
|
||||
|
||||
/** Things we lazy load from the JSX namespace */
|
||||
const jsxTypes = createMap<Type>();
|
||||
const JsxNames = {
|
||||
|
@ -372,6 +375,22 @@ namespace ts {
|
|||
|
||||
return checker;
|
||||
|
||||
function getJsxNamespace(): string {
|
||||
if (_jsxNamespace === undefined) {
|
||||
_jsxNamespace = "React";
|
||||
if (compilerOptions.jsxFactory) {
|
||||
_jsxFactoryEntity = parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
|
||||
if (_jsxFactoryEntity) {
|
||||
_jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text;
|
||||
}
|
||||
}
|
||||
else if (compilerOptions.reactNamespace) {
|
||||
_jsxNamespace = compilerOptions.reactNamespace;
|
||||
}
|
||||
}
|
||||
return _jsxNamespace;
|
||||
}
|
||||
|
||||
function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) {
|
||||
// Ensure we have all the type information in place for this file so that all the
|
||||
// emitter questions of this resolver will return the right information.
|
||||
|
@ -11468,10 +11487,10 @@ namespace ts {
|
|||
function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) {
|
||||
checkGrammarJsxElement(node);
|
||||
checkJsxPreconditions(node);
|
||||
// The reactNamespace symbol should be marked as 'used' so we don't incorrectly elide its import. And if there
|
||||
// is no reactNamespace symbol in scope when targeting React emit, we should issue an error.
|
||||
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
|
||||
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
|
||||
const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
|
||||
const reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React";
|
||||
const reactNamespace = getJsxNamespace();
|
||||
const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace);
|
||||
if (reactSym) {
|
||||
// Mark local symbol as referenced here because it might not have been marked
|
||||
|
@ -19738,7 +19757,8 @@ namespace ts {
|
|||
getTypeReferenceDirectivesForEntityName,
|
||||
getTypeReferenceDirectivesForSymbol,
|
||||
isLiteralConstDeclaration,
|
||||
writeLiteralConstValue
|
||||
writeLiteralConstValue,
|
||||
getJsxFactoryEntity: () => _jsxFactoryEntity
|
||||
};
|
||||
|
||||
// defined here to avoid outer scope pollution
|
||||
|
|
|
@ -77,6 +77,11 @@ namespace ts {
|
|||
type: "string",
|
||||
description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit
|
||||
},
|
||||
{
|
||||
name: "jsxFactory",
|
||||
type: "string",
|
||||
description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
|
||||
},
|
||||
{
|
||||
name: "listFiles",
|
||||
type: "boolean",
|
||||
|
|
|
@ -2389,6 +2389,10 @@
|
|||
"category": "Error",
|
||||
"code": 5066
|
||||
},
|
||||
"Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name.": {
|
||||
"category": "Error",
|
||||
"code": 5067
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
|
@ -2905,6 +2909,10 @@
|
|||
"category": "Message",
|
||||
"code": 6145
|
||||
},
|
||||
"Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.": {
|
||||
"category": "Message",
|
||||
"code": 6146
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
|
|
@ -1641,7 +1641,34 @@ namespace ts {
|
|||
return react;
|
||||
}
|
||||
|
||||
export function createReactCreateElement(reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
|
||||
function createJsxFactoryExpressionFromEntityName(jsxFactory: EntityName, parent: JsxOpeningLikeElement): Expression {
|
||||
if (isQualifiedName(jsxFactory)) {
|
||||
return createPropertyAccess(
|
||||
createJsxFactoryExpressionFromEntityName(
|
||||
jsxFactory.left,
|
||||
parent
|
||||
),
|
||||
setEmitFlags(
|
||||
getMutableClone(jsxFactory.right),
|
||||
EmitFlags.NoSourceMap
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createReactNamespace(jsxFactory.text, parent);
|
||||
}
|
||||
}
|
||||
|
||||
function createJsxFactoryExpression(jsxFactoryEntity: EntityName, reactNamespace: string, parent: JsxOpeningLikeElement): Expression {
|
||||
return jsxFactoryEntity ?
|
||||
createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) :
|
||||
createPropertyAccess(
|
||||
createReactNamespace(reactNamespace, parent),
|
||||
"createElement"
|
||||
);
|
||||
}
|
||||
|
||||
export function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
|
||||
const argumentsList = [tagName];
|
||||
if (props) {
|
||||
argumentsList.push(props);
|
||||
|
@ -1664,10 +1691,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
return createCall(
|
||||
createPropertyAccess(
|
||||
createReactNamespace(reactNamespace, parentElement),
|
||||
"createElement"
|
||||
),
|
||||
createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement),
|
||||
/*typeArguments*/ undefined,
|
||||
argumentsList,
|
||||
location
|
||||
|
|
|
@ -440,6 +440,10 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName {
|
||||
return Parser.parseIsolatedEntityName(text, languageVersion);
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
@ -591,6 +595,16 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
export function parseIsolatedEntityName(content: string, languageVersion: ScriptTarget): EntityName {
|
||||
initializeState(content, languageVersion, /*syntaxCursor*/ undefined, ScriptKind.JS);
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
const entityName = parseEntityName(/*allowReservedWords*/ true);
|
||||
const isInvalid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length;
|
||||
clearState();
|
||||
return isInvalid ? entityName : undefined;
|
||||
}
|
||||
|
||||
function getLanguageVariant(scriptKind: ScriptKind) {
|
||||
// .tsx and .jsx files are treated as jsx language variant.
|
||||
return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
|
|
|
@ -1670,7 +1670,15 @@ namespace ts {
|
|||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
|
||||
}
|
||||
|
||||
if (options.reactNamespace && !isIdentifierText(options.reactNamespace, languageVersion)) {
|
||||
if (options.jsxFactory) {
|
||||
if (options.reactNamespace) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"));
|
||||
}
|
||||
if (!parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory));
|
||||
}
|
||||
}
|
||||
else if (options.reactNamespace && !isIdentifierText(options.reactNamespace, languageVersion)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace));
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ namespace ts {
|
|||
|| createAssignHelper(currentSourceFile.externalHelpersModuleName, segments);
|
||||
}
|
||||
|
||||
const element = createReactCreateElement(
|
||||
const element = createExpressionForJsxElement(
|
||||
context.getEmitResolver().getJsxFactoryEntity(),
|
||||
compilerOptions.reactNamespace,
|
||||
tagName,
|
||||
objectProperties,
|
||||
|
|
|
@ -2485,6 +2485,7 @@ namespace ts {
|
|||
getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[];
|
||||
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
|
||||
writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void;
|
||||
getJsxFactoryEntity(): EntityName;
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
|
@ -3095,6 +3096,7 @@ namespace ts {
|
|||
project?: string;
|
||||
/* @internal */ pretty?: DiagnosticStyle;
|
||||
reactNamespace?: string;
|
||||
jsxFactory?: string;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: string[];
|
||||
|
|
|
@ -1768,7 +1768,7 @@ namespace Harness {
|
|||
}
|
||||
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSettings {
|
||||
const opts: CompilerSettings = {};
|
||||
|
@ -1777,7 +1777,7 @@ namespace Harness {
|
|||
/* tslint:disable:no-null-keyword */
|
||||
while ((match = optionRegex.exec(content)) !== null) {
|
||||
/* tslint:enable:no-null-keyword */
|
||||
opts[match[1]] = match[2];
|
||||
opts[match[1]] = match[2].trim();
|
||||
}
|
||||
|
||||
return opts;
|
||||
|
@ -1805,7 +1805,7 @@ namespace Harness {
|
|||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
const metaDataName = testMetaData[1].toLowerCase();
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2].trim();
|
||||
if (metaDataName !== "filename") {
|
||||
continue;
|
||||
}
|
||||
|
@ -1825,12 +1825,12 @@ namespace Harness {
|
|||
// Reset local data
|
||||
currentFileContent = undefined;
|
||||
currentFileOptions = {};
|
||||
currentFileName = testMetaData[2];
|
||||
currentFileName = testMetaData[2].trim();
|
||||
refs = [];
|
||||
}
|
||||
else {
|
||||
// First metadata marker in the file
|
||||
currentFileName = testMetaData[2];
|
||||
currentFileName = testMetaData[2].trim();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -385,6 +385,10 @@ var x = 0;`, {
|
|||
options: { compilerOptions: { reactNamespace: "react" }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
||||
transpilesCorrectly("Supports setting 'jsxFactory'", "x;", {
|
||||
options: { compilerOptions: { jsxFactory: "createElement" }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
||||
transpilesCorrectly("Supports setting 'removeComments'", "x;", {
|
||||
options: { compilerOptions: { removeComments: true }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
error TS5053: Option 'reactNamespace' cannot be specified with option 'jsxFactory'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'reactNamespace' cannot be specified with option 'jsxFactory'.
|
||||
==== tests/cases/compiler/Element.ts (0 errors) ====
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/test.tsx (0 errors) ====
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
81
tests/baselines/reference/jsxFactoryAndReactNamespace.js
Normal file
81
tests/baselines/reference/jsxFactoryAndReactNamespace.js
Normal file
|
@ -0,0 +1,81 @@
|
|||
//// [tests/cases/compiler/jsxFactoryAndReactNamespace.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
const Element_1 = require("./Element");
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
Element_1.Element.createElement("meta", { content: "helloworld" }),
|
||||
Element_1.Element.createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
83
tests/baselines/reference/jsxFactoryIdentifier.js
Normal file
83
tests/baselines/reference/jsxFactoryIdentifier.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
//// [tests/cases/compiler/jsxFactoryIdentifier.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
let createElement = Element.createElement;
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//# sourceMappingURL=Element.js.map//// [test.js]
|
||||
"use strict";
|
||||
const Element_1 = require("./Element");
|
||||
let createElement = Element_1.Element.createElement;
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
createElement("meta", { content: "helloworld" }),
|
||||
createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=test.js.map
|
3
tests/baselines/reference/jsxFactoryIdentifier.js.map
Normal file
3
tests/baselines/reference/jsxFactoryIdentifier.js.map
Normal file
|
@ -0,0 +1,3 @@
|
|||
//// [Element.js.map]
|
||||
{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAAA,uCAAmC;AACnC,IAAI,aAAa,GAAG,iBAAO,CAAC,aAAa,CAAC;AAC1C,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,wBAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,wBAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"}
|
520
tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt
Normal file
520
tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt
Normal file
|
@ -0,0 +1,520 @@
|
|||
===================================================================
|
||||
JsFile: Element.js
|
||||
mapUrl: Element.js.map
|
||||
sourceRoot:
|
||||
sources: Element.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/Element.js
|
||||
sourceFile:Element.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>var Element;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^
|
||||
5 > ^^^^^^^^^^->
|
||||
1 >
|
||||
>declare namespace JSX {
|
||||
> interface Element {
|
||||
> name: string;
|
||||
> isIntrinsic: boolean;
|
||||
> isCustomElement: boolean;
|
||||
> toString(renderId?: number): string;
|
||||
> bindDOM(renderId?: number): number;
|
||||
> resetComponent(): void;
|
||||
> instantiateComponents(renderId?: number): number;
|
||||
> props: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
2 >export namespace
|
||||
3 > Element
|
||||
4 > {
|
||||
> export function isElement(el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
>
|
||||
> export function createElement(args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
1 >Emitted(2, 1) Source(14, 1) + SourceIndex(0)
|
||||
2 >Emitted(2, 5) Source(14, 18) + SourceIndex(0)
|
||||
3 >Emitted(2, 12) Source(14, 25) + SourceIndex(0)
|
||||
4 >Emitted(2, 13) Source(24, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>(function (Element) {
|
||||
1->
|
||||
2 >^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^^^^^^^^^^->
|
||||
1->
|
||||
2 >export namespace
|
||||
3 > Element
|
||||
1->Emitted(3, 1) Source(14, 1) + SourceIndex(0)
|
||||
2 >Emitted(3, 12) Source(14, 18) + SourceIndex(0)
|
||||
3 >Emitted(3, 19) Source(14, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> function isElement(el) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1-> {
|
||||
>
|
||||
2 > export function isElement(
|
||||
3 > el: any
|
||||
1->Emitted(4, 5) Source(15, 5) + SourceIndex(0)
|
||||
2 >Emitted(4, 24) Source(15, 31) + SourceIndex(0)
|
||||
3 >Emitted(4, 26) Source(15, 38) + SourceIndex(0)
|
||||
---
|
||||
>>> return el.markAsChildOfRootElement !== undefined;
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
6 > ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
7 > ^^^^^
|
||||
8 > ^^^^^^^^^
|
||||
9 > ^
|
||||
1->): el is JSX.Element {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > el
|
||||
5 > .
|
||||
6 > markAsChildOfRootElement
|
||||
7 > !==
|
||||
8 > undefined
|
||||
9 > ;
|
||||
1->Emitted(5, 9) Source(16, 9) + SourceIndex(0)
|
||||
2 >Emitted(5, 15) Source(16, 15) + SourceIndex(0)
|
||||
3 >Emitted(5, 16) Source(16, 16) + SourceIndex(0)
|
||||
4 >Emitted(5, 18) Source(16, 18) + SourceIndex(0)
|
||||
5 >Emitted(5, 19) Source(16, 19) + SourceIndex(0)
|
||||
6 >Emitted(5, 43) Source(16, 43) + SourceIndex(0)
|
||||
7 >Emitted(5, 48) Source(16, 48) + SourceIndex(0)
|
||||
8 >Emitted(5, 57) Source(16, 57) + SourceIndex(0)
|
||||
9 >Emitted(5, 58) Source(16, 58) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(6, 5) Source(17, 5) + SourceIndex(0)
|
||||
2 >Emitted(6, 6) Source(17, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> Element.isElement = isElement;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^
|
||||
4 > ^
|
||||
5 > ^->
|
||||
1->
|
||||
2 > isElement
|
||||
3 > (el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
4 >
|
||||
1->Emitted(7, 5) Source(15, 21) + SourceIndex(0)
|
||||
2 >Emitted(7, 22) Source(15, 30) + SourceIndex(0)
|
||||
3 >Emitted(7, 34) Source(17, 6) + SourceIndex(0)
|
||||
4 >Emitted(7, 35) Source(17, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> function createElement(args) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^
|
||||
1->
|
||||
>
|
||||
>
|
||||
2 > export function createElement(
|
||||
3 > args: any[]
|
||||
1->Emitted(8, 5) Source(19, 5) + SourceIndex(0)
|
||||
2 >Emitted(8, 28) Source(19, 35) + SourceIndex(0)
|
||||
3 >Emitted(8, 32) Source(19, 46) + SourceIndex(0)
|
||||
---
|
||||
>>> return {};
|
||||
1 >^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
1 >) {
|
||||
>
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > {
|
||||
> }
|
||||
5 >
|
||||
1 >Emitted(9, 9) Source(21, 9) + SourceIndex(0)
|
||||
2 >Emitted(9, 15) Source(21, 15) + SourceIndex(0)
|
||||
3 >Emitted(9, 16) Source(21, 16) + SourceIndex(0)
|
||||
4 >Emitted(9, 18) Source(22, 10) + SourceIndex(0)
|
||||
5 >Emitted(9, 19) Source(22, 10) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(10, 5) Source(23, 5) + SourceIndex(0)
|
||||
2 >Emitted(10, 6) Source(23, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> Element.createElement = createElement;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^^^
|
||||
4 > ^
|
||||
5 > ^^^^^^^^^^^^^^^->
|
||||
1->
|
||||
2 > createElement
|
||||
3 > (args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
4 >
|
||||
1->Emitted(11, 5) Source(19, 21) + SourceIndex(0)
|
||||
2 >Emitted(11, 26) Source(19, 34) + SourceIndex(0)
|
||||
3 >Emitted(11, 42) Source(23, 6) + SourceIndex(0)
|
||||
4 >Emitted(11, 43) Source(23, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>})(Element = exports.Element || (exports.Element = {}));
|
||||
1->
|
||||
2 >^
|
||||
3 > ^^
|
||||
4 > ^^^^^^^
|
||||
5 > ^^^
|
||||
6 > ^^^^^^^^^^^^^^^
|
||||
7 > ^^^^^
|
||||
8 > ^^^^^^^^^^^^^^^
|
||||
9 > ^^^^^^^^
|
||||
1->
|
||||
>
|
||||
2 >}
|
||||
3 >
|
||||
4 > Element
|
||||
5 >
|
||||
6 > Element
|
||||
7 >
|
||||
8 > Element
|
||||
9 > {
|
||||
> export function isElement(el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
>
|
||||
> export function createElement(args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
1->Emitted(12, 1) Source(24, 1) + SourceIndex(0)
|
||||
2 >Emitted(12, 2) Source(24, 2) + SourceIndex(0)
|
||||
3 >Emitted(12, 4) Source(14, 18) + SourceIndex(0)
|
||||
4 >Emitted(12, 11) Source(14, 25) + SourceIndex(0)
|
||||
5 >Emitted(12, 14) Source(14, 18) + SourceIndex(0)
|
||||
6 >Emitted(12, 29) Source(14, 25) + SourceIndex(0)
|
||||
7 >Emitted(12, 34) Source(14, 18) + SourceIndex(0)
|
||||
8 >Emitted(12, 49) Source(14, 25) + SourceIndex(0)
|
||||
9 >Emitted(12, 57) Source(24, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.createElement = Element.createElement;
|
||||
1 >
|
||||
2 >^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^
|
||||
4 > ^^^
|
||||
5 > ^^^^^^^
|
||||
6 > ^
|
||||
7 > ^^^^^^^^^^^^^
|
||||
8 > ^
|
||||
1 >
|
||||
>
|
||||
>export let
|
||||
2 >
|
||||
3 > createElement
|
||||
4 > =
|
||||
5 > Element
|
||||
6 > .
|
||||
7 > createElement
|
||||
8 > ;
|
||||
1 >Emitted(13, 1) Source(26, 12) + SourceIndex(0)
|
||||
2 >Emitted(13, 9) Source(26, 12) + SourceIndex(0)
|
||||
3 >Emitted(13, 22) Source(26, 25) + SourceIndex(0)
|
||||
4 >Emitted(13, 25) Source(26, 28) + SourceIndex(0)
|
||||
5 >Emitted(13, 32) Source(26, 35) + SourceIndex(0)
|
||||
6 >Emitted(13, 33) Source(26, 36) + SourceIndex(0)
|
||||
7 >Emitted(13, 46) Source(26, 49) + SourceIndex(0)
|
||||
8 >Emitted(13, 47) Source(26, 50) + SourceIndex(0)
|
||||
---
|
||||
>>>function toCamelCase(text) {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 >function toCamelCase(
|
||||
3 > text: string
|
||||
1 >Emitted(14, 1) Source(28, 1) + SourceIndex(0)
|
||||
2 >Emitted(14, 22) Source(28, 22) + SourceIndex(0)
|
||||
3 >Emitted(14, 26) Source(28, 34) + SourceIndex(0)
|
||||
---
|
||||
>>> return text[0].toLowerCase() + text.substring(1);
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^
|
||||
5 > ^
|
||||
6 > ^
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^^^^^^^^^^^
|
||||
10> ^^
|
||||
11> ^^^
|
||||
12> ^^^^
|
||||
13> ^
|
||||
14> ^^^^^^^^^
|
||||
15> ^
|
||||
16> ^
|
||||
17> ^
|
||||
18> ^
|
||||
1->): string {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > text
|
||||
5 > [
|
||||
6 > 0
|
||||
7 > ]
|
||||
8 > .
|
||||
9 > toLowerCase
|
||||
10> ()
|
||||
11> +
|
||||
12> text
|
||||
13> .
|
||||
14> substring
|
||||
15> (
|
||||
16> 1
|
||||
17> )
|
||||
18> ;
|
||||
1->Emitted(15, 5) Source(29, 5) + SourceIndex(0)
|
||||
2 >Emitted(15, 11) Source(29, 11) + SourceIndex(0)
|
||||
3 >Emitted(15, 12) Source(29, 12) + SourceIndex(0)
|
||||
4 >Emitted(15, 16) Source(29, 16) + SourceIndex(0)
|
||||
5 >Emitted(15, 17) Source(29, 17) + SourceIndex(0)
|
||||
6 >Emitted(15, 18) Source(29, 18) + SourceIndex(0)
|
||||
7 >Emitted(15, 19) Source(29, 19) + SourceIndex(0)
|
||||
8 >Emitted(15, 20) Source(29, 20) + SourceIndex(0)
|
||||
9 >Emitted(15, 31) Source(29, 31) + SourceIndex(0)
|
||||
10>Emitted(15, 33) Source(29, 33) + SourceIndex(0)
|
||||
11>Emitted(15, 36) Source(29, 36) + SourceIndex(0)
|
||||
12>Emitted(15, 40) Source(29, 40) + SourceIndex(0)
|
||||
13>Emitted(15, 41) Source(29, 41) + SourceIndex(0)
|
||||
14>Emitted(15, 50) Source(29, 50) + SourceIndex(0)
|
||||
15>Emitted(15, 51) Source(29, 51) + SourceIndex(0)
|
||||
16>Emitted(15, 52) Source(29, 52) + SourceIndex(0)
|
||||
17>Emitted(15, 53) Source(29, 53) + SourceIndex(0)
|
||||
18>Emitted(15, 54) Source(29, 54) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >
|
||||
2 >^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 >}
|
||||
1 >Emitted(16, 1) Source(30, 1) + SourceIndex(0)
|
||||
2 >Emitted(16, 2) Source(30, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=Element.js.map===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>const Element_1 = require("./Element");
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
2 >import { Element} from './Element';
|
||||
1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(2, 40) Source(1, 36) + SourceIndex(0)
|
||||
---
|
||||
>>>let createElement = Element_1.Element.createElement;
|
||||
1->
|
||||
2 >^^^^
|
||||
3 > ^^^^^^^^^^^^^
|
||||
4 > ^^^
|
||||
5 > ^^^^^^^^^^^^^^^^^
|
||||
6 > ^
|
||||
7 > ^^^^^^^^^^^^^
|
||||
8 > ^
|
||||
1->
|
||||
>
|
||||
2 >let
|
||||
3 > createElement
|
||||
4 > =
|
||||
5 > Element
|
||||
6 > .
|
||||
7 > createElement
|
||||
8 > ;
|
||||
1->Emitted(3, 1) Source(2, 1) + SourceIndex(0)
|
||||
2 >Emitted(3, 5) Source(2, 5) + SourceIndex(0)
|
||||
3 >Emitted(3, 18) Source(2, 18) + SourceIndex(0)
|
||||
4 >Emitted(3, 21) Source(2, 21) + SourceIndex(0)
|
||||
5 >Emitted(3, 38) Source(2, 28) + SourceIndex(0)
|
||||
6 >Emitted(3, 39) Source(2, 29) + SourceIndex(0)
|
||||
7 >Emitted(3, 52) Source(2, 42) + SourceIndex(0)
|
||||
8 >Emitted(3, 53) Source(2, 43) + SourceIndex(0)
|
||||
---
|
||||
>>>let c;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^
|
||||
4 > ^
|
||||
5 > ^^^^->
|
||||
1 >
|
||||
>
|
||||
2 >let
|
||||
3 > c: {
|
||||
> a?: {
|
||||
> b: string
|
||||
> }
|
||||
> }
|
||||
4 > ;
|
||||
1 >Emitted(4, 1) Source(3, 1) + SourceIndex(0)
|
||||
2 >Emitted(4, 5) Source(3, 5) + SourceIndex(0)
|
||||
3 >Emitted(4, 6) Source(7, 2) + SourceIndex(0)
|
||||
4 >Emitted(4, 7) Source(7, 3) + SourceIndex(0)
|
||||
---
|
||||
>>>class A {
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^->
|
||||
1->
|
||||
>
|
||||
>
|
||||
1->Emitted(5, 1) Source(9, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> view() {
|
||||
1->^^^^
|
||||
2 > ^^^^
|
||||
3 > ^^^^^^^^^->
|
||||
1->class A {
|
||||
>
|
||||
2 > view
|
||||
1->Emitted(6, 5) Source(10, 2) + SourceIndex(0)
|
||||
2 >Emitted(6, 9) Source(10, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> return [
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->() {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
1->Emitted(7, 9) Source(11, 3) + SourceIndex(0)
|
||||
2 >Emitted(7, 15) Source(11, 9) + SourceIndex(0)
|
||||
3 >Emitted(7, 16) Source(11, 10) + SourceIndex(0)
|
||||
---
|
||||
>>> createElement("meta", { content: "helloworld" }),
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^
|
||||
5 > ^^^^^^^^^^^^
|
||||
6 > ^^^
|
||||
1->[
|
||||
>
|
||||
2 > <meta
|
||||
3 > content
|
||||
4 > =
|
||||
5 > "helloworld"
|
||||
6 > ></meta>
|
||||
1->Emitted(8, 13) Source(12, 4) + SourceIndex(0)
|
||||
2 >Emitted(8, 37) Source(12, 10) + SourceIndex(0)
|
||||
3 >Emitted(8, 44) Source(12, 17) + SourceIndex(0)
|
||||
4 >Emitted(8, 46) Source(12, 18) + SourceIndex(0)
|
||||
5 >Emitted(8, 58) Source(12, 30) + SourceIndex(0)
|
||||
6 >Emitted(8, 61) Source(12, 38) + SourceIndex(0)
|
||||
---
|
||||
>>> createElement("meta", { content: c.a.b })
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
6 > ^
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^
|
||||
10> ^^^
|
||||
1 >,
|
||||
>
|
||||
2 > <meta
|
||||
3 > content
|
||||
4 > ={
|
||||
5 > c
|
||||
6 > .
|
||||
7 > a!
|
||||
8 > .
|
||||
9 > b
|
||||
10> }></meta>
|
||||
1 >Emitted(9, 13) Source(13, 4) + SourceIndex(0)
|
||||
2 >Emitted(9, 37) Source(13, 10) + SourceIndex(0)
|
||||
3 >Emitted(9, 44) Source(13, 17) + SourceIndex(0)
|
||||
4 >Emitted(9, 46) Source(13, 19) + SourceIndex(0)
|
||||
5 >Emitted(9, 47) Source(13, 20) + SourceIndex(0)
|
||||
6 >Emitted(9, 48) Source(13, 21) + SourceIndex(0)
|
||||
7 >Emitted(9, 49) Source(13, 23) + SourceIndex(0)
|
||||
8 >Emitted(9, 50) Source(13, 24) + SourceIndex(0)
|
||||
9 >Emitted(9, 51) Source(13, 25) + SourceIndex(0)
|
||||
10>Emitted(9, 54) Source(13, 34) + SourceIndex(0)
|
||||
---
|
||||
>>> ];
|
||||
1 >^^^^^^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
> ]
|
||||
2 > ;
|
||||
1 >Emitted(10, 10) Source(14, 4) + SourceIndex(0)
|
||||
2 >Emitted(10, 11) Source(14, 5) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(11, 5) Source(15, 2) + SourceIndex(0)
|
||||
2 >Emitted(11, 6) Source(15, 3) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(12, 2) Source(16, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
125
tests/baselines/reference/jsxFactoryIdentifier.symbols
Normal file
125
tests/baselines/reference/jsxFactoryIdentifier.symbols
Normal file
|
@ -0,0 +1,125 @@
|
|||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
|
||||
interface Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Element.name, Decl(Element.ts, 2, 23))
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : Symbol(Element.isIntrinsic, Decl(Element.ts, 3, 21))
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : Symbol(Element.isCustomElement, Decl(Element.ts, 4, 29))
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : Symbol(Element.toString, Decl(Element.ts, 5, 33))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 6, 17))
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : Symbol(Element.bindDOM, Decl(Element.ts, 6, 44))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 7, 16))
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : Symbol(Element.resetComponent, Decl(Element.ts, 7, 43))
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : Symbol(Element.instantiateComponents, Decl(Element.ts, 8, 31))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 9, 30))
|
||||
|
||||
props: any;
|
||||
>props : Symbol(Element.props, Decl(Element.ts, 9, 57))
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : Symbol(isElement, Decl(Element.ts, 13, 26))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
>Element : Symbol(JSX.Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>undefined : Symbol(undefined)
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 16, 5))
|
||||
>args : Symbol(args, Decl(Element.ts, 18, 34))
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 25, 10))
|
||||
>Element.createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
>createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : Symbol(toCamelCase, Decl(Element.ts, 25, 49))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : Symbol(Element, Decl(test.tsx, 0, 8))
|
||||
|
||||
let createElement = Element.createElement;
|
||||
>createElement : Symbol(createElement, Decl(test.tsx, 1, 3))
|
||||
>Element.createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
>Element : Symbol(Element, Decl(test.tsx, 0, 8))
|
||||
>createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
|
||||
let c: {
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
|
||||
a?: {
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
|
||||
b: string
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(test.tsx, 6, 2))
|
||||
|
||||
view() {
|
||||
>view : Symbol(A.view, Decl(test.tsx, 8, 9))
|
||||
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
];
|
||||
}
|
||||
}
|
140
tests/baselines/reference/jsxFactoryIdentifier.types
Normal file
140
tests/baselines/reference/jsxFactoryIdentifier.types
Normal file
|
@ -0,0 +1,140 @@
|
|||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : any
|
||||
|
||||
interface Element {
|
||||
>Element : Element
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : boolean
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : boolean
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : (renderId?: number) => string
|
||||
>renderId : number
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : () => void
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
props: any;
|
||||
>props : any
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : typeof Element
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : (el: any) => el is JSX.Element
|
||||
>el : any
|
||||
>el : any
|
||||
>JSX : any
|
||||
>Element : JSX.Element
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el.markAsChildOfRootElement !== undefined : boolean
|
||||
>el.markAsChildOfRootElement : any
|
||||
>el : any
|
||||
>markAsChildOfRootElement : any
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : (args: any[]) => {}
|
||||
>args : any[]
|
||||
|
||||
return {
|
||||
>{ } : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : (args: any[]) => {}
|
||||
>Element.createElement : (args: any[]) => {}
|
||||
>Element : typeof Element
|
||||
>createElement : (args: any[]) => {}
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : (text: string) => string
|
||||
>text : string
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase() + text.substring(1) : string
|
||||
>text[0].toLowerCase() : string
|
||||
>text[0].toLowerCase : () => string
|
||||
>text[0] : string
|
||||
>text : string
|
||||
>0 : 0
|
||||
>toLowerCase : () => string
|
||||
>text.substring(1) : string
|
||||
>text.substring : (start: number, end?: number) => string
|
||||
>text : string
|
||||
>substring : (start: number, end?: number) => string
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : typeof Element
|
||||
|
||||
let createElement = Element.createElement;
|
||||
>createElement : (args: any[]) => {}
|
||||
>Element.createElement : (args: any[]) => {}
|
||||
>Element : typeof Element
|
||||
>createElement : (args: any[]) => {}
|
||||
|
||||
let c: {
|
||||
>c : { a?: { b: string; }; }
|
||||
|
||||
a?: {
|
||||
>a : { b: string; }
|
||||
|
||||
b: string
|
||||
>b : string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
view() {
|
||||
>view : () => any[]
|
||||
|
||||
return [
|
||||
>[ <meta content="helloworld"></meta>, <meta content={c.a!.b}></meta> ] : any[]
|
||||
|
||||
<meta content="helloworld"></meta>,
|
||||
><meta content="helloworld"></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>meta : any
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
><meta content={c.a!.b}></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>c.a!.b : string
|
||||
>c.a! : { b: string; }
|
||||
>c.a : { b: string; }
|
||||
>c : { a?: { b: string; }; }
|
||||
>a : { b: string; }
|
||||
>b : string
|
||||
>meta : any
|
||||
|
||||
];
|
||||
}
|
||||
}
|
24
tests/baselines/reference/jsxFactoryIdentifierAsParameter.js
Normal file
24
tests/baselines/reference/jsxFactoryIdentifierAsParameter.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render(createElement) {
|
||||
return createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,2 @@
|
|||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
|
@ -0,0 +1,87 @@
|
|||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render(createElement) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^
|
||||
5 > ^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
3 > (
|
||||
4 > createElement
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0)
|
||||
4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> return createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->) {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render(createElement) {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/compiler/test.tsx ===
|
||||
|
||||
declare module JSX {
|
||||
>JSX : Symbol(JSX, Decl(test.tsx, 0, 0))
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(test.tsx, 1, 20))
|
||||
|
||||
[s: string]: any;
|
||||
>s : Symbol(s, Decl(test.tsx, 3, 9))
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
>AppComponent : Symbol(AppComponent, Decl(test.tsx, 5, 1))
|
||||
|
||||
render(createElement) {
|
||||
>render : Symbol(AppComponent.render, Decl(test.tsx, 7, 27))
|
||||
>createElement : Symbol(createElement, Decl(test.tsx, 8, 11))
|
||||
|
||||
return <div />;
|
||||
>div : Symbol(unknown)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
=== tests/cases/compiler/test.tsx ===
|
||||
|
||||
declare module JSX {
|
||||
>JSX : any
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : IntrinsicElements
|
||||
|
||||
[s: string]: any;
|
||||
>s : string
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
>AppComponent : AppComponent
|
||||
|
||||
render(createElement) {
|
||||
>render : (createElement: any) => any
|
||||
>createElement : any
|
||||
|
||||
return <div />;
|
||||
><div /> : any
|
||||
>div : any
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'createElement'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/test.tsx (1 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'createElement'.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render() {
|
||||
return createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,2 @@
|
|||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM;QACF,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
|
@ -0,0 +1,81 @@
|
|||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render() {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
---
|
||||
>>> return createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->() {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render() {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,59 @@
|
|||
error TS5067: Invalid value for 'jsxFactory'. 'Element.createElement=' is not a valid identifier or qualified-name.
|
||||
tests/cases/compiler/test.tsx(12,5): error TS2304: Cannot find name 'React'.
|
||||
tests/cases/compiler/test.tsx(13,5): error TS2304: Cannot find name 'React'.
|
||||
|
||||
|
||||
!!! error TS5067: Invalid value for 'jsxFactory'. 'Element.createElement=' is not a valid identifier or qualified-name.
|
||||
==== tests/cases/compiler/Element.ts (0 errors) ====
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/test.tsx (2 errors) ====
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'React'.
|
||||
<meta content={c.a!.b}></meta>
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'React'.
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
//// [tests/cases/compiler/jsxFactoryNotIdentifierOrQualifiedName.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
React.createElement("meta", { content: "helloworld" }),
|
||||
React.createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
error TS5067: Invalid value for 'jsxFactory'. 'id1 id2' is not a valid identifier or qualified-name.
|
||||
tests/cases/compiler/test.tsx(12,5): error TS2304: Cannot find name 'React'.
|
||||
tests/cases/compiler/test.tsx(13,5): error TS2304: Cannot find name 'React'.
|
||||
|
||||
|
||||
!!! error TS5067: Invalid value for 'jsxFactory'. 'id1 id2' is not a valid identifier or qualified-name.
|
||||
==== tests/cases/compiler/Element.ts (0 errors) ====
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/test.tsx (2 errors) ====
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'React'.
|
||||
<meta content={c.a!.b}></meta>
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'React'.
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
//// [tests/cases/compiler/jsxFactoryNotIdentifierOrQualifiedName2.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
React.createElement("meta", { content: "helloworld" }),
|
||||
React.createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
82
tests/baselines/reference/jsxFactoryQualifiedName.js
Normal file
82
tests/baselines/reference/jsxFactoryQualifiedName.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
//// [tests/cases/compiler/jsxFactoryQualifiedName.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//# sourceMappingURL=Element.js.map//// [test.js]
|
||||
"use strict";
|
||||
const Element_1 = require("./Element");
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
Element_1.Element.createElement("meta", { content: "helloworld" }),
|
||||
Element_1.Element.createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=test.js.map
|
3
tests/baselines/reference/jsxFactoryQualifiedName.js.map
Normal file
3
tests/baselines/reference/jsxFactoryQualifiedName.js.map
Normal file
|
@ -0,0 +1,3 @@
|
|||
//// [Element.js.map]
|
||||
{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAAA,uCAAmC;AAEnC,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,0CAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,0CAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"}
|
493
tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt
Normal file
493
tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt
Normal file
|
@ -0,0 +1,493 @@
|
|||
===================================================================
|
||||
JsFile: Element.js
|
||||
mapUrl: Element.js.map
|
||||
sourceRoot:
|
||||
sources: Element.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/Element.js
|
||||
sourceFile:Element.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>var Element;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^
|
||||
5 > ^^^^^^^^^^->
|
||||
1 >
|
||||
>declare namespace JSX {
|
||||
> interface Element {
|
||||
> name: string;
|
||||
> isIntrinsic: boolean;
|
||||
> isCustomElement: boolean;
|
||||
> toString(renderId?: number): string;
|
||||
> bindDOM(renderId?: number): number;
|
||||
> resetComponent(): void;
|
||||
> instantiateComponents(renderId?: number): number;
|
||||
> props: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
2 >export namespace
|
||||
3 > Element
|
||||
4 > {
|
||||
> export function isElement(el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
>
|
||||
> export function createElement(args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
1 >Emitted(2, 1) Source(14, 1) + SourceIndex(0)
|
||||
2 >Emitted(2, 5) Source(14, 18) + SourceIndex(0)
|
||||
3 >Emitted(2, 12) Source(14, 25) + SourceIndex(0)
|
||||
4 >Emitted(2, 13) Source(24, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>(function (Element) {
|
||||
1->
|
||||
2 >^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^^^^^^^^^^->
|
||||
1->
|
||||
2 >export namespace
|
||||
3 > Element
|
||||
1->Emitted(3, 1) Source(14, 1) + SourceIndex(0)
|
||||
2 >Emitted(3, 12) Source(14, 18) + SourceIndex(0)
|
||||
3 >Emitted(3, 19) Source(14, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> function isElement(el) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1-> {
|
||||
>
|
||||
2 > export function isElement(
|
||||
3 > el: any
|
||||
1->Emitted(4, 5) Source(15, 5) + SourceIndex(0)
|
||||
2 >Emitted(4, 24) Source(15, 31) + SourceIndex(0)
|
||||
3 >Emitted(4, 26) Source(15, 38) + SourceIndex(0)
|
||||
---
|
||||
>>> return el.markAsChildOfRootElement !== undefined;
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
6 > ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
7 > ^^^^^
|
||||
8 > ^^^^^^^^^
|
||||
9 > ^
|
||||
1->): el is JSX.Element {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > el
|
||||
5 > .
|
||||
6 > markAsChildOfRootElement
|
||||
7 > !==
|
||||
8 > undefined
|
||||
9 > ;
|
||||
1->Emitted(5, 9) Source(16, 9) + SourceIndex(0)
|
||||
2 >Emitted(5, 15) Source(16, 15) + SourceIndex(0)
|
||||
3 >Emitted(5, 16) Source(16, 16) + SourceIndex(0)
|
||||
4 >Emitted(5, 18) Source(16, 18) + SourceIndex(0)
|
||||
5 >Emitted(5, 19) Source(16, 19) + SourceIndex(0)
|
||||
6 >Emitted(5, 43) Source(16, 43) + SourceIndex(0)
|
||||
7 >Emitted(5, 48) Source(16, 48) + SourceIndex(0)
|
||||
8 >Emitted(5, 57) Source(16, 57) + SourceIndex(0)
|
||||
9 >Emitted(5, 58) Source(16, 58) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(6, 5) Source(17, 5) + SourceIndex(0)
|
||||
2 >Emitted(6, 6) Source(17, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> Element.isElement = isElement;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^
|
||||
4 > ^
|
||||
5 > ^->
|
||||
1->
|
||||
2 > isElement
|
||||
3 > (el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
4 >
|
||||
1->Emitted(7, 5) Source(15, 21) + SourceIndex(0)
|
||||
2 >Emitted(7, 22) Source(15, 30) + SourceIndex(0)
|
||||
3 >Emitted(7, 34) Source(17, 6) + SourceIndex(0)
|
||||
4 >Emitted(7, 35) Source(17, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> function createElement(args) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^
|
||||
1->
|
||||
>
|
||||
>
|
||||
2 > export function createElement(
|
||||
3 > args: any[]
|
||||
1->Emitted(8, 5) Source(19, 5) + SourceIndex(0)
|
||||
2 >Emitted(8, 28) Source(19, 35) + SourceIndex(0)
|
||||
3 >Emitted(8, 32) Source(19, 46) + SourceIndex(0)
|
||||
---
|
||||
>>> return {};
|
||||
1 >^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
1 >) {
|
||||
>
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > {
|
||||
> }
|
||||
5 >
|
||||
1 >Emitted(9, 9) Source(21, 9) + SourceIndex(0)
|
||||
2 >Emitted(9, 15) Source(21, 15) + SourceIndex(0)
|
||||
3 >Emitted(9, 16) Source(21, 16) + SourceIndex(0)
|
||||
4 >Emitted(9, 18) Source(22, 10) + SourceIndex(0)
|
||||
5 >Emitted(9, 19) Source(22, 10) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(10, 5) Source(23, 5) + SourceIndex(0)
|
||||
2 >Emitted(10, 6) Source(23, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> Element.createElement = createElement;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^^^
|
||||
4 > ^
|
||||
5 > ^^^^^^^^^^^^^^^->
|
||||
1->
|
||||
2 > createElement
|
||||
3 > (args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
4 >
|
||||
1->Emitted(11, 5) Source(19, 21) + SourceIndex(0)
|
||||
2 >Emitted(11, 26) Source(19, 34) + SourceIndex(0)
|
||||
3 >Emitted(11, 42) Source(23, 6) + SourceIndex(0)
|
||||
4 >Emitted(11, 43) Source(23, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>})(Element = exports.Element || (exports.Element = {}));
|
||||
1->
|
||||
2 >^
|
||||
3 > ^^
|
||||
4 > ^^^^^^^
|
||||
5 > ^^^
|
||||
6 > ^^^^^^^^^^^^^^^
|
||||
7 > ^^^^^
|
||||
8 > ^^^^^^^^^^^^^^^
|
||||
9 > ^^^^^^^^
|
||||
1->
|
||||
>
|
||||
2 >}
|
||||
3 >
|
||||
4 > Element
|
||||
5 >
|
||||
6 > Element
|
||||
7 >
|
||||
8 > Element
|
||||
9 > {
|
||||
> export function isElement(el: any): el is JSX.Element {
|
||||
> return el.markAsChildOfRootElement !== undefined;
|
||||
> }
|
||||
>
|
||||
> export function createElement(args: any[]) {
|
||||
>
|
||||
> return {
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
1->Emitted(12, 1) Source(24, 1) + SourceIndex(0)
|
||||
2 >Emitted(12, 2) Source(24, 2) + SourceIndex(0)
|
||||
3 >Emitted(12, 4) Source(14, 18) + SourceIndex(0)
|
||||
4 >Emitted(12, 11) Source(14, 25) + SourceIndex(0)
|
||||
5 >Emitted(12, 14) Source(14, 18) + SourceIndex(0)
|
||||
6 >Emitted(12, 29) Source(14, 25) + SourceIndex(0)
|
||||
7 >Emitted(12, 34) Source(14, 18) + SourceIndex(0)
|
||||
8 >Emitted(12, 49) Source(14, 25) + SourceIndex(0)
|
||||
9 >Emitted(12, 57) Source(24, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.createElement = Element.createElement;
|
||||
1 >
|
||||
2 >^^^^^^^^
|
||||
3 > ^^^^^^^^^^^^^
|
||||
4 > ^^^
|
||||
5 > ^^^^^^^
|
||||
6 > ^
|
||||
7 > ^^^^^^^^^^^^^
|
||||
8 > ^
|
||||
1 >
|
||||
>
|
||||
>export let
|
||||
2 >
|
||||
3 > createElement
|
||||
4 > =
|
||||
5 > Element
|
||||
6 > .
|
||||
7 > createElement
|
||||
8 > ;
|
||||
1 >Emitted(13, 1) Source(26, 12) + SourceIndex(0)
|
||||
2 >Emitted(13, 9) Source(26, 12) + SourceIndex(0)
|
||||
3 >Emitted(13, 22) Source(26, 25) + SourceIndex(0)
|
||||
4 >Emitted(13, 25) Source(26, 28) + SourceIndex(0)
|
||||
5 >Emitted(13, 32) Source(26, 35) + SourceIndex(0)
|
||||
6 >Emitted(13, 33) Source(26, 36) + SourceIndex(0)
|
||||
7 >Emitted(13, 46) Source(26, 49) + SourceIndex(0)
|
||||
8 >Emitted(13, 47) Source(26, 50) + SourceIndex(0)
|
||||
---
|
||||
>>>function toCamelCase(text) {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 >function toCamelCase(
|
||||
3 > text: string
|
||||
1 >Emitted(14, 1) Source(28, 1) + SourceIndex(0)
|
||||
2 >Emitted(14, 22) Source(28, 22) + SourceIndex(0)
|
||||
3 >Emitted(14, 26) Source(28, 34) + SourceIndex(0)
|
||||
---
|
||||
>>> return text[0].toLowerCase() + text.substring(1);
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^
|
||||
5 > ^
|
||||
6 > ^
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^^^^^^^^^^^
|
||||
10> ^^
|
||||
11> ^^^
|
||||
12> ^^^^
|
||||
13> ^
|
||||
14> ^^^^^^^^^
|
||||
15> ^
|
||||
16> ^
|
||||
17> ^
|
||||
18> ^
|
||||
1->): string {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > text
|
||||
5 > [
|
||||
6 > 0
|
||||
7 > ]
|
||||
8 > .
|
||||
9 > toLowerCase
|
||||
10> ()
|
||||
11> +
|
||||
12> text
|
||||
13> .
|
||||
14> substring
|
||||
15> (
|
||||
16> 1
|
||||
17> )
|
||||
18> ;
|
||||
1->Emitted(15, 5) Source(29, 5) + SourceIndex(0)
|
||||
2 >Emitted(15, 11) Source(29, 11) + SourceIndex(0)
|
||||
3 >Emitted(15, 12) Source(29, 12) + SourceIndex(0)
|
||||
4 >Emitted(15, 16) Source(29, 16) + SourceIndex(0)
|
||||
5 >Emitted(15, 17) Source(29, 17) + SourceIndex(0)
|
||||
6 >Emitted(15, 18) Source(29, 18) + SourceIndex(0)
|
||||
7 >Emitted(15, 19) Source(29, 19) + SourceIndex(0)
|
||||
8 >Emitted(15, 20) Source(29, 20) + SourceIndex(0)
|
||||
9 >Emitted(15, 31) Source(29, 31) + SourceIndex(0)
|
||||
10>Emitted(15, 33) Source(29, 33) + SourceIndex(0)
|
||||
11>Emitted(15, 36) Source(29, 36) + SourceIndex(0)
|
||||
12>Emitted(15, 40) Source(29, 40) + SourceIndex(0)
|
||||
13>Emitted(15, 41) Source(29, 41) + SourceIndex(0)
|
||||
14>Emitted(15, 50) Source(29, 50) + SourceIndex(0)
|
||||
15>Emitted(15, 51) Source(29, 51) + SourceIndex(0)
|
||||
16>Emitted(15, 52) Source(29, 52) + SourceIndex(0)
|
||||
17>Emitted(15, 53) Source(29, 53) + SourceIndex(0)
|
||||
18>Emitted(15, 54) Source(29, 54) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >
|
||||
2 >^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
2 >}
|
||||
1 >Emitted(16, 1) Source(30, 1) + SourceIndex(0)
|
||||
2 >Emitted(16, 2) Source(30, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=Element.js.map===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>const Element_1 = require("./Element");
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1 >
|
||||
2 >import { Element} from './Element';
|
||||
1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(2, 40) Source(1, 36) + SourceIndex(0)
|
||||
---
|
||||
>>>let c;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^
|
||||
4 > ^
|
||||
5 > ^^^^->
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 >let
|
||||
3 > c: {
|
||||
> a?: {
|
||||
> b: string
|
||||
> }
|
||||
> }
|
||||
4 > ;
|
||||
1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0)
|
||||
2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0)
|
||||
3 >Emitted(3, 6) Source(7, 2) + SourceIndex(0)
|
||||
4 >Emitted(3, 7) Source(7, 3) + SourceIndex(0)
|
||||
---
|
||||
>>>class A {
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^->
|
||||
1->
|
||||
>
|
||||
>
|
||||
1->Emitted(4, 1) Source(9, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> view() {
|
||||
1->^^^^
|
||||
2 > ^^^^
|
||||
3 > ^^^^^^^^^->
|
||||
1->class A {
|
||||
>
|
||||
2 > view
|
||||
1->Emitted(5, 5) Source(10, 2) + SourceIndex(0)
|
||||
2 >Emitted(5, 9) Source(10, 6) + SourceIndex(0)
|
||||
---
|
||||
>>> return [
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->() {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
1->Emitted(6, 9) Source(11, 3) + SourceIndex(0)
|
||||
2 >Emitted(6, 15) Source(11, 9) + SourceIndex(0)
|
||||
3 >Emitted(6, 16) Source(11, 10) + SourceIndex(0)
|
||||
---
|
||||
>>> Element_1.Element.createElement("meta", { content: "helloworld" }),
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^
|
||||
5 > ^^^^^^^^^^^^
|
||||
6 > ^^^
|
||||
1->[
|
||||
>
|
||||
2 > <meta
|
||||
3 > content
|
||||
4 > =
|
||||
5 > "helloworld"
|
||||
6 > ></meta>
|
||||
1->Emitted(7, 13) Source(12, 4) + SourceIndex(0)
|
||||
2 >Emitted(7, 55) Source(12, 10) + SourceIndex(0)
|
||||
3 >Emitted(7, 62) Source(12, 17) + SourceIndex(0)
|
||||
4 >Emitted(7, 64) Source(12, 18) + SourceIndex(0)
|
||||
5 >Emitted(7, 76) Source(12, 30) + SourceIndex(0)
|
||||
6 >Emitted(7, 79) Source(12, 38) + SourceIndex(0)
|
||||
---
|
||||
>>> Element_1.Element.createElement("meta", { content: c.a.b })
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
6 > ^
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^
|
||||
10> ^^^
|
||||
1 >,
|
||||
>
|
||||
2 > <meta
|
||||
3 > content
|
||||
4 > ={
|
||||
5 > c
|
||||
6 > .
|
||||
7 > a!
|
||||
8 > .
|
||||
9 > b
|
||||
10> }></meta>
|
||||
1 >Emitted(8, 13) Source(13, 4) + SourceIndex(0)
|
||||
2 >Emitted(8, 55) Source(13, 10) + SourceIndex(0)
|
||||
3 >Emitted(8, 62) Source(13, 17) + SourceIndex(0)
|
||||
4 >Emitted(8, 64) Source(13, 19) + SourceIndex(0)
|
||||
5 >Emitted(8, 65) Source(13, 20) + SourceIndex(0)
|
||||
6 >Emitted(8, 66) Source(13, 21) + SourceIndex(0)
|
||||
7 >Emitted(8, 67) Source(13, 23) + SourceIndex(0)
|
||||
8 >Emitted(8, 68) Source(13, 24) + SourceIndex(0)
|
||||
9 >Emitted(8, 69) Source(13, 25) + SourceIndex(0)
|
||||
10>Emitted(8, 72) Source(13, 34) + SourceIndex(0)
|
||||
---
|
||||
>>> ];
|
||||
1 >^^^^^^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
> ]
|
||||
2 > ;
|
||||
1 >Emitted(9, 10) Source(14, 4) + SourceIndex(0)
|
||||
2 >Emitted(9, 11) Source(14, 5) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(10, 5) Source(15, 2) + SourceIndex(0)
|
||||
2 >Emitted(10, 6) Source(15, 3) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(11, 2) Source(16, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
119
tests/baselines/reference/jsxFactoryQualifiedName.symbols
Normal file
119
tests/baselines/reference/jsxFactoryQualifiedName.symbols
Normal file
|
@ -0,0 +1,119 @@
|
|||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
|
||||
interface Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Element.name, Decl(Element.ts, 2, 23))
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : Symbol(Element.isIntrinsic, Decl(Element.ts, 3, 21))
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : Symbol(Element.isCustomElement, Decl(Element.ts, 4, 29))
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : Symbol(Element.toString, Decl(Element.ts, 5, 33))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 6, 17))
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : Symbol(Element.bindDOM, Decl(Element.ts, 6, 44))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 7, 16))
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : Symbol(Element.resetComponent, Decl(Element.ts, 7, 43))
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : Symbol(Element.instantiateComponents, Decl(Element.ts, 8, 31))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 9, 30))
|
||||
|
||||
props: any;
|
||||
>props : Symbol(Element.props, Decl(Element.ts, 9, 57))
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : Symbol(isElement, Decl(Element.ts, 13, 26))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
>Element : Symbol(JSX.Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>undefined : Symbol(undefined)
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 16, 5))
|
||||
>args : Symbol(args, Decl(Element.ts, 18, 34))
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 25, 10))
|
||||
>Element.createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
>createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : Symbol(toCamelCase, Decl(Element.ts, 25, 49))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : Symbol(Element, Decl(test.tsx, 0, 8))
|
||||
|
||||
let c: {
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
|
||||
a?: {
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
|
||||
b: string
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(test.tsx, 6, 2))
|
||||
|
||||
view() {
|
||||
>view : Symbol(A.view, Decl(test.tsx, 8, 9))
|
||||
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
];
|
||||
}
|
||||
}
|
134
tests/baselines/reference/jsxFactoryQualifiedName.types
Normal file
134
tests/baselines/reference/jsxFactoryQualifiedName.types
Normal file
|
@ -0,0 +1,134 @@
|
|||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : any
|
||||
|
||||
interface Element {
|
||||
>Element : Element
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : boolean
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : boolean
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : (renderId?: number) => string
|
||||
>renderId : number
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : () => void
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
props: any;
|
||||
>props : any
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : typeof Element
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : (el: any) => el is JSX.Element
|
||||
>el : any
|
||||
>el : any
|
||||
>JSX : any
|
||||
>Element : JSX.Element
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el.markAsChildOfRootElement !== undefined : boolean
|
||||
>el.markAsChildOfRootElement : any
|
||||
>el : any
|
||||
>markAsChildOfRootElement : any
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : (args: any[]) => {}
|
||||
>args : any[]
|
||||
|
||||
return {
|
||||
>{ } : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : (args: any[]) => {}
|
||||
>Element.createElement : (args: any[]) => {}
|
||||
>Element : typeof Element
|
||||
>createElement : (args: any[]) => {}
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : (text: string) => string
|
||||
>text : string
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase() + text.substring(1) : string
|
||||
>text[0].toLowerCase() : string
|
||||
>text[0].toLowerCase : () => string
|
||||
>text[0] : string
|
||||
>text : string
|
||||
>0 : 0
|
||||
>toLowerCase : () => string
|
||||
>text.substring(1) : string
|
||||
>text.substring : (start: number, end?: number) => string
|
||||
>text : string
|
||||
>substring : (start: number, end?: number) => string
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : typeof Element
|
||||
|
||||
let c: {
|
||||
>c : { a?: { b: string; }; }
|
||||
|
||||
a?: {
|
||||
>a : { b: string; }
|
||||
|
||||
b: string
|
||||
>b : string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
view() {
|
||||
>view : () => any[]
|
||||
|
||||
return [
|
||||
>[ <meta content="helloworld"></meta>, <meta content={c.a!.b}></meta> ] : any[]
|
||||
|
||||
<meta content="helloworld"></meta>,
|
||||
><meta content="helloworld"></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>meta : any
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
><meta content={c.a!.b}></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>c.a!.b : string
|
||||
>c.a! : { b: string; }
|
||||
>c.a : { b: string; }
|
||||
>c : { a?: { b: string; }; }
|
||||
>a : { b: string; }
|
||||
>b : string
|
||||
>meta : any
|
||||
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'MyElement'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/test.tsx (1 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'MyElement'.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render(createElement) {
|
||||
return MyElement.createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,2 @@
|
|||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,oCAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
|
@ -0,0 +1,87 @@
|
|||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render(createElement) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^
|
||||
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
3 > (
|
||||
4 > createElement
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0)
|
||||
4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> return MyElement.createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->) {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 52) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 53) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render(createElement) {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
x;
|
||||
//# sourceMappingURL=input.js.map
|
54
tests/cases/compiler/jsxFactoryAndReactNamespace.ts
Normal file
54
tests/cases/compiler/jsxFactoryAndReactNamespace.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@reactNamespace: Element
|
||||
//@jsxFactory: Element.createElement
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
54
tests/cases/compiler/jsxFactoryIdentifier.ts
Normal file
54
tests/cases/compiler/jsxFactoryIdentifier.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
let createElement = Element.createElement;
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
18
tests/cases/compiler/jsxFactoryIdentifierAsParameter.ts
Normal file
18
tests/cases/compiler/jsxFactoryIdentifierAsParameter.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: Element.createElement=
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: id1 id2
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
54
tests/cases/compiler/jsxFactoryQualifiedName.ts
Normal file
54
tests/cases/compiler/jsxFactoryQualifiedName.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: Element.createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: MyElement.createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue