From 99fc99f3bcbc123b7c37be05a4be7ac25e929fd7 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 7 Jul 2015 14:27:57 -0700 Subject: [PATCH] Improved fix from @JsonFreeman --- src/compiler/checker.ts | 10 +++---- .../reference/tsxAttributeResolution9.symbols | 30 ++++++++++--------- .../reference/tsxAttributeResolution9.types | 8 +++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b910dc3306..842b6dcd55 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7096,18 +7096,18 @@ namespace ts { // Look up the value in the current scope if (node.tagName.kind === SyntaxKind.Identifier) { let tag = node.tagName; - valueSymbol = resolveName(tag, tag.text, SymbolFlags.Value, Diagnostics.Cannot_find_name_0, tag.text); + let maybeExportSymbol = getResolvedSymbol(node.tagName); + let valueDecl = maybeExportSymbol.valueDeclaration; + + valueSymbol = (valueDecl && valueDecl.localSymbol) || maybeExportSymbol; } else { valueSymbol = checkQualifiedName(node.tagName).symbol; } if (valueSymbol && valueSymbol !== unknownSymbol) { - let symbolLinks = getSymbolLinks(valueSymbol); - if (symbolLinks) { - symbolLinks.referenced = true; - } links.jsxFlags |= JsxFlags.ClassElement; + getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; diff --git a/tests/baselines/reference/tsxAttributeResolution9.symbols b/tests/baselines/reference/tsxAttributeResolution9.symbols index cbb30864c8..081482d5d4 100644 --- a/tests/baselines/reference/tsxAttributeResolution9.symbols +++ b/tests/baselines/reference/tsxAttributeResolution9.symbols @@ -1,45 +1,47 @@ -=== tests/cases/conformance/jsx/tsxAttributeResolution9.tsx === +=== tests/cases/conformance/jsx/react.d.ts === + declare module JSX { ->JSX : Symbol(JSX, Decl(tsxAttributeResolution9.tsx, 0, 0)) +>JSX : Symbol(JSX, Decl(react.d.ts, 0, 0)) interface Element { } ->Element : Symbol(Element, Decl(tsxAttributeResolution9.tsx, 0, 20)) +>Element : Symbol(Element, Decl(react.d.ts, 1, 20)) interface IntrinsicElements { ->IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution9.tsx, 1, 22)) +>IntrinsicElements : Symbol(IntrinsicElements, Decl(react.d.ts, 2, 22)) } interface ElementAttributesProperty { ->ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(tsxAttributeResolution9.tsx, 3, 2)) +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 4, 2)) props; ->props : Symbol(props, Decl(tsxAttributeResolution9.tsx, 4, 38)) +>props : Symbol(props, Decl(react.d.ts, 5, 38)) } } interface Props { ->Props : Symbol(Props, Decl(tsxAttributeResolution9.tsx, 7, 1)) +>Props : Symbol(Props, Decl(react.d.ts, 8, 1)) foo: string; ->foo : Symbol(foo, Decl(tsxAttributeResolution9.tsx, 9, 17)) +>foo : Symbol(foo, Decl(react.d.ts, 10, 17)) } +=== tests/cases/conformance/jsx/file.tsx === export class MyComponent { ->MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1)) +>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) render() { ->render : Symbol(render, Decl(tsxAttributeResolution9.tsx, 13, 26)) +>render : Symbol(render, Decl(file.tsx, 0, 26)) } props: { foo: string; } ->props : Symbol(props, Decl(tsxAttributeResolution9.tsx, 15, 3)) ->foo : Symbol(foo, Decl(tsxAttributeResolution9.tsx, 17, 10)) +>props : Symbol(props, Decl(file.tsx, 2, 3)) +>foo : Symbol(foo, Decl(file.tsx, 4, 10)) } ; // ok ->MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1)) +>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) >foo : Symbol(unknown) ; // should be an error ->MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1)) +>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) >foo : Symbol(unknown) diff --git a/tests/baselines/reference/tsxAttributeResolution9.types b/tests/baselines/reference/tsxAttributeResolution9.types index aab3806a5f..1b2c6d4238 100644 --- a/tests/baselines/reference/tsxAttributeResolution9.types +++ b/tests/baselines/reference/tsxAttributeResolution9.types @@ -1,4 +1,5 @@ -=== tests/cases/conformance/jsx/tsxAttributeResolution9.tsx === +=== tests/cases/conformance/jsx/react.d.ts === + declare module JSX { >JSX : any @@ -23,6 +24,7 @@ interface Props { >foo : string } +=== tests/cases/conformance/jsx/file.tsx === export class MyComponent { >MyComponent : MyComponent @@ -36,12 +38,12 @@ export class MyComponent { } ; // ok -> : any +> : JSX.Element >MyComponent : typeof MyComponent >foo : any ; // should be an error -> : any +> : JSX.Element >MyComponent : typeof MyComponent >foo : any