mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Correctly identify identifiers inside JSX exprs as expression identifiers
This commit is contained in:
parent
649e40b171
commit
d86fd85bd5
@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
@ -1484,6 +1485,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
else if (languageVersion < ScriptTarget.ES6) {
|
||||
debugger;
|
||||
let declaration = resolver.getReferencedImportDeclaration(node);
|
||||
if (declaration) {
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
|
||||
21
tests/baselines/reference/jsxImportInAttribute.js
Normal file
21
tests/baselines/reference/jsxImportInAttribute.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/jsxImportInAttribute.tsx] ////
|
||||
|
||||
//// [component.d.ts]
|
||||
|
||||
declare module "Test" {
|
||||
export default class Text { }
|
||||
}
|
||||
|
||||
//// [consumer.tsx]
|
||||
/// <reference path="component.d.ts" />
|
||||
import Test from 'Test';
|
||||
|
||||
let x = Test; // emit test_1.default
|
||||
<anything attr={Test} />; // ?
|
||||
|
||||
|
||||
//// [consumer.jsx]
|
||||
/// <reference path="component.d.ts" />
|
||||
var Test_1 = require('Test');
|
||||
var x = Test_1["default"]; // emit test_1.default
|
||||
<anything attr={Test_1["default"]}/>; // ?
|
||||
19
tests/baselines/reference/jsxImportInAttribute.symbols
Normal file
19
tests/baselines/reference/jsxImportInAttribute.symbols
Normal file
@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/consumer.tsx ===
|
||||
/// <reference path="component.d.ts" />
|
||||
import Test from 'Test';
|
||||
>Test : Symbol(Test, Decl(consumer.tsx, 1, 6))
|
||||
|
||||
let x = Test; // emit test_1.default
|
||||
>x : Symbol(x, Decl(consumer.tsx, 3, 3))
|
||||
>Test : Symbol(Test, Decl(consumer.tsx, 1, 6))
|
||||
|
||||
<anything attr={Test} />; // ?
|
||||
>attr : Symbol(unknown)
|
||||
|
||||
=== tests/cases/compiler/component.d.ts ===
|
||||
|
||||
declare module "Test" {
|
||||
export default class Text { }
|
||||
>Text : Symbol(Text, Decl(component.d.ts, 1, 23))
|
||||
}
|
||||
|
||||
22
tests/baselines/reference/jsxImportInAttribute.types
Normal file
22
tests/baselines/reference/jsxImportInAttribute.types
Normal file
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/consumer.tsx ===
|
||||
/// <reference path="component.d.ts" />
|
||||
import Test from 'Test';
|
||||
>Test : typeof Test
|
||||
|
||||
let x = Test; // emit test_1.default
|
||||
>x : typeof Test
|
||||
>Test : typeof Test
|
||||
|
||||
<anything attr={Test} />; // ?
|
||||
><anything attr={Test} /> : any
|
||||
>anything : any
|
||||
>attr : any
|
||||
>Test : any
|
||||
|
||||
=== tests/cases/compiler/component.d.ts ===
|
||||
|
||||
declare module "Test" {
|
||||
export default class Text { }
|
||||
>Text : Text
|
||||
}
|
||||
|
||||
14
tests/cases/compiler/jsxImportInAttribute.tsx
Normal file
14
tests/cases/compiler/jsxImportInAttribute.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
//@jsx: preserve
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: component.d.ts
|
||||
declare module "Test" {
|
||||
export default class Text { }
|
||||
}
|
||||
|
||||
//@filename: consumer.tsx
|
||||
/// <reference path="component.d.ts" />
|
||||
import Test from 'Test';
|
||||
|
||||
let x = Test; // emit test_1.default
|
||||
<anything attr={Test} />; // ?
|
||||
Loading…
x
Reference in New Issue
Block a user