diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e30178e987b..5a39e96b119 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -892,7 +892,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); + let bindingName = (node).name ? (node).name.text : "__function"; + return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -964,7 +965,8 @@ namespace ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } else { - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); + let bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); } let symbol = node.symbol; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index da7ac5844b8..7e631ff5bce 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7303,6 +7303,16 @@ namespace ts { checkGrammarJsxElement(node); checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === JsxEmit.React) { + let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + let targetAttributesType = getJsxElementAttributesType(node); let nameTable: Map = {}; diff --git a/src/services/services.ts b/src/services/services.ts index 19e0873d8b5..d79436bb478 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2892,33 +2892,36 @@ namespace ts { log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - - let options = program.getCompilerOptions(); - let jsx = options.jsx !== JsxEmit.None; - let target = options.target; - - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. let node = currentToken; let isRightOfDot = false; let isRightOfOpenTag = false; let location = getTouchingPropertyName(sourceFile, position); - if(contextToken) { - let kind = contextToken.kind; - if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; } - else if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; + + let { parent, kind } = contextToken; + if (kind === SyntaxKind.DotToken) { + if (parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } } else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { isRightOfOpenTag = true; @@ -3010,68 +3013,21 @@ namespace ts { } function tryGetGlobalSymbols(): boolean { - let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); - let jsxContainer = tryGetContainingJsxElement(contextToken); - if (objectLikeContainer) { - // We're looking up possible property names from contextual/inferred/declared type. - isMemberCompletion = true; + let objectLikeContainer: ObjectLiteralExpression | BindingPattern; + let importClause: ImportClause; + let jsxContainer: JsxOpeningLikeElement; - let typeForObject: Type; - let existingMembers: Declaration[]; - - if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { - // We are completing on contextual types, but may also include properties - // other than those within the declared type. - isNewIdentifierLocation = true; - - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = (objectLikeContainer).properties; - } - else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { - // We are *only* completing on properties from the type being destructured. - isNewIdentifierLocation = false; - - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = (objectLikeContainer).elements; - } - else { - Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); - } - - if (!typeForObject) { - return false; - } - - let typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { - // cursor is in import clause + + if (importClause = getAncestor(contextToken, SyntaxKind.ImportClause)) { + // cursor is in an import clause // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration !== undefined); - - let exports: Symbol[]; - if (importDeclaration.moduleSpecifier) { - let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - } - - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; - } - return true; + return tryGetImportClauseCompletionSymbols(importClause); } - else if (jsxContainer) { + + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element @@ -3144,16 +3100,16 @@ namespace ts { return scope; } - function isCompletionListBlocker(previousToken: Node): boolean { + function isCompletionListBlocker(contextToken: Node): boolean { let start = new Date().getTime(); - let result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node: Node): boolean { + function shouldShowCompletionsInImportsClause(node: Node): boolean { if (node) { // import {| // import {a,| @@ -3227,12 +3183,12 @@ namespace ts { return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { - if (previousToken.kind === SyntaxKind.StringLiteral - || previousToken.kind === SyntaxKind.RegularExpressionLiteral - || isTemplateLiteralKind(previousToken.kind)) { - let start = previousToken.getStart(); - let end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken: Node): boolean { + if (contextToken.kind === SyntaxKind.StringLiteral + || contextToken.kind === SyntaxKind.RegularExpressionLiteral + || isTemplateLiteralKind(contextToken.kind)) { + let start = contextToken.getStart(); + let end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -3243,14 +3199,94 @@ namespace ts { } if (position === end) { - return !!(previousToken).isUnterminated || - previousToken.kind === SyntaxKind.RegularExpressionLiteral; + return !!(contextToken).isUnterminated + || contextToken.kind === SyntaxKind.RegularExpressionLiteral; } } return false; } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | BindingPattern): boolean { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + + let typeForObject: Type; + let existingMembers: Declaration[]; + + if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = (objectLikeContainer).properties; + } + else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + else { + Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + + if (!typeForObject) { + return false; + } + + let typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { + // cursor is in import clause + // try to show exported member for imported module + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + + let importDeclaration = importClause.parent; + Debug.assert(importDeclaration !== undefined && importDeclaration.kind === SyntaxKind.ImportDeclaration); + + let exports: Symbol[]; + let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + + return true; + } + /** * Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given. @@ -3318,101 +3354,98 @@ namespace ts { return false; } - function isIdentifierDefinitionLocation(previousToken: Node): boolean { - if (previousToken) { - let containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case SyntaxKind.CommaToken: - return containingNodeKind === SyntaxKind.VariableDeclaration || - containingNodeKind === SyntaxKind.VariableDeclarationList || - containingNodeKind === SyntaxKind.VariableStatement || - containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | - isFunction(containingNodeKind) || - containingNodeKind === SyntaxKind.ClassDeclaration || // class A(); ->v : ->new m() : +>v : C +>new m() : C >m : typeof C return v.f(); >v.f() : { t: string; x: number; } >v.f : () => { t: T; x: number; } ->v : +>v : C >f : () => { t: T; x: number; } } diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js new file mode 100644 index 00000000000..72612e8ce54 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution19.tsx] //// + +//// [react.d.ts] + +declare module "react" { + +} + +//// [file1.tsx] +declare module JSX { + interface Element { } +} +export class MyClass { } + +//// [file2.tsx] + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + var MyClass = (function () { + function MyClass() { + } + return MyClass; + })(); + exports.MyClass = MyClass; +}); +//// [file2.js] +define(["require", "exports", 'react', './file1'], function (require, exports, React, file1_1) { + React.createElement(file1_1.MyClass, null); +}); diff --git a/tests/baselines/reference/tsxElementResolution19.symbols b/tests/baselines/reference/tsxElementResolution19.symbols new file mode 100644 index 00000000000..48aa4f962b6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(file1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file1.tsx, 0, 20)) +} +export class MyClass { } +>MyClass : Symbol(MyClass, Decl(file1.tsx, 2, 1)) + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : Symbol(React, Decl(file2.tsx, 2, 6)) + +import {MyClass} from './file1'; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + +; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + diff --git a/tests/baselines/reference/tsxElementResolution19.types b/tests/baselines/reference/tsxElementResolution19.types new file mode 100644 index 00000000000..0fa1eefe5f6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} +export class MyClass { } +>MyClass : MyClass + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : typeof React + +import {MyClass} from './file1'; +>MyClass : typeof MyClass + +; +> : any +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index b6c5fd96183..f1799e5bb77 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 60fa5e70b0a..c9e819c82d3 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -12,133 +12,135 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit1.tsx, 6, 11)) var p; ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var selfClosed1 =
; ->selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 8, 3)) +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var selfClosed2 =
; ->selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 9, 3)) +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed3 =
; ->selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 10, 3)) +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed4 =
; ->selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 11, 3)) +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed5 =
; ->selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 12, 3)) +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed6 =
; ->selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 13, 3)) +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed7 =
; ->selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) >b : Symbol(unknown) var openClosed1 =
; ->openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed2 =
foo
; ->openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 17, 3)) +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed3 =
{p}
; ->openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 18, 3)) +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed4 =
{p < p}
; ->openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 19, 3)) +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var openClosed5 =
{p > p}
; ->openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 21, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) >b : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) class SomeClass { ->SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) f() { ->f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 23, 17)) var rewrites1 =
{() => this}
; ->rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 25, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites2 =
{[p, ...p, p]}
; ->rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 26, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites3 =
{{p}}
; ->rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 26, 5)) +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 27, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 26, 25)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 27, 25)) var rewrites4 =
this}>
; ->rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites5 =
; ->rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites6 =
; ->rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 30, 5)) +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 31, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 30, 27)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 31, 27)) } } var whitespace1 =
; ->whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 34, 3)) +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace2 =
{p}
; ->whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 35, 3)) +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
->whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 36, 3)) +>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 37, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index d23cad4560a..0b6e03c5742 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p; >p : any diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index f4a12946ed9..4b2b4695561 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 9607d9330da..9cf739c960c 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -12,32 +12,34 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit2.tsx, 6, 11)) var p1, p2, p3; ->p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 7, 7)) ->p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 7, 11)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) var spreads1 =
{p2}
; ->spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 8, 3)) +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; ->spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 9, 3)) +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; ->spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 10, 3)) +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads4 =
{p2}
; ->spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 11, 3)) +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads5 =
{p2}
; ->spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 12, 3)) +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types index 9f8d6e494d0..e28910b62c7 100644 --- a/tests/baselines/reference/tsxReactEmit2.types +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p1, p2, p3; >p1 : any diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index d31fec1c550..1a6ba037230 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -1,6 +1,7 @@ //// [tsxReactEmit3.tsx] declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols index 8ef0ccab241..857647400a9 100644 --- a/tests/baselines/reference/tsxReactEmit3.symbols +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -4,15 +4,18 @@ declare module JSX { interface Element { } } >JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) >Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit3.tsx, 2, 11)) + declare var Foo, Bar, baz; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 3, 21)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 4, 21)) q s ; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types index 9e5d9fece56..8babe724fa1 100644 --- a/tests/baselines/reference/tsxReactEmit3.types +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -4,6 +4,9 @@ declare module JSX { interface Element { } } >JSX : any >Element : Element +declare var React: any; +>React : any + declare var Foo, Bar, baz; >Foo : any >Bar : any diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt index 00b7cb8d019..fca2b028237 100644 --- a/tests/baselines/reference/tsxReactEmit4.errors.txt +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find name 'blah'. +tests/cases/conformance/jsx/tsxReactEmit4.tsx(12,5): error TS2304: Cannot find name 'blah'. ==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== @@ -8,6 +8,7 @@ tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find n [s: string]: any; } } + declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index 2254c4dd651..dcbfafcef2f 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index 2f32295c279..a124ce73312 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index afbb6944981..06c8258a2c2 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -12,12 +12,14 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace.tsx, 6, 11)) // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; ->p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 10, 3)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) // Emit " "
; diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index e0e3639fa9b..603dc4ca6c1 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx deleted file mode 100644 index fb54f9d7c82..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// OK -; // OK -; // OK -; // OK -; // OK -; // OK -// Errors -; // Error, '0' is not number -; // Error, no property "y" -; // Error, no property "y" -; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property -; // Error, missing reqd -; // Error, reqd is not string diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx deleted file mode 100644 index 7c47046dcde..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx +++ /dev/null @@ -1,5 +0,0 @@ -// OK -; // OK -; // OK -// Errors -; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx deleted file mode 100644 index 46cb5d8ff69..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx +++ /dev/null @@ -1,21 +0,0 @@ -// OK -var obj1 = { x: 'foo' }; -; -// Error, x is not string -var obj2 = { x: 32 }; -; -// Error, x is missing -var obj3 = { y: 32 }; -; -// OK -var obj4 = { x: 32, y: 32 }; -; -// Error -var obj5 = { x: 32, y: 32 }; -; -// OK -var obj6 = { x: 'ok', y: 32, extra: 100 }; -; -// Error -var obj7 = { x: 'foo' }; -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx deleted file mode 100644 index da2e1d12038..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -; -// Error, no member 'len' on 'string' -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx deleted file mode 100644 index 3e4c89d06fb..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx +++ /dev/null @@ -1,11 +0,0 @@ -function make1(obj) { - return ; // OK -} -function make2(obj) { - return ; // Error (x is number, not string) -} -function make3(obj) { - return ; // Error, missing x -} -; // Error, missing x -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.jsx b/tests/cases/conformance/jsx/tsxElementResolution1.jsx deleted file mode 100644 index 97357dbba8e..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution1.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -
; -// Fail -; diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.jsx b/tests/cases/conformance/jsx/tsxElementResolution11.jsx deleted file mode 100644 index 6349906508c..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution11.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var Obj1; -; // OK -var Obj2; -; // Error -var Obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.jsx b/tests/cases/conformance/jsx/tsxElementResolution12.jsx deleted file mode 100644 index ef137fd0e29..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution12.jsx +++ /dev/null @@ -1,9 +0,0 @@ -var obj1; -; // OK -var obj2; -; // OK -var obj3; -; // Error -var obj4; -; // OK -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.jsx b/tests/cases/conformance/jsx/tsxElementResolution13.jsx deleted file mode 100644 index 6a55efa612d..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution13.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.jsx b/tests/cases/conformance/jsx/tsxElementResolution14.jsx deleted file mode 100644 index 29df7710af1..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution14.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.jsx b/tests/cases/conformance/jsx/tsxElementResolution15.jsx deleted file mode 100644 index 6a55efa612d..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution15.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.jsx b/tests/cases/conformance/jsx/tsxElementResolution16.jsx deleted file mode 100644 index e1987489bbb..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution16.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution19.tsx b/tests/cases/conformance/jsx/tsxElementResolution19.tsx new file mode 100644 index 00000000000..23e503ae962 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution19.tsx @@ -0,0 +1,21 @@ +//@jsx: react +//@module: amd + +//@filename: react.d.ts +declare module "react" { + +} + +//@filename: file1.tsx +declare module JSX { + interface Element { } +} +export class MyClass { } + +//@filename: file2.tsx + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.jsx b/tests/cases/conformance/jsx/tsxElementResolution7.jsx deleted file mode 100644 index e95505539ab..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution7.jsx +++ /dev/null @@ -1,14 +0,0 @@ -var my; -(function (my) { -})(my || (my = {})); -// OK -; -// Error -; -var q; -(function (q) { - // OK - ; - // Error - ; -})(q || (q = {})); diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.jsx b/tests/cases/conformance/jsx/tsxElementResolution8.jsx deleted file mode 100644 index e0f95dc6d22..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution8.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// Error -var div = 3; -
; -// OK -function fact() { return null; } -; -// Error -function fnum() { return 42; } -; -var obj1; -; // OK, prefer construct signatures -var obj2; -; // Error -var obj3; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.jsx b/tests/cases/conformance/jsx/tsxElementResolution9.jsx deleted file mode 100644 index 2b62d86eac5..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution9.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var obj1; -; // Error, return type is not an object type -var obj2; -; // Error, return type is not an object type -var obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.jsx b/tests/cases/conformance/jsx/tsxEmit1.jsx deleted file mode 100644 index 45ca6e2469f..00000000000 --- a/tests/cases/conformance/jsx/tsxEmit1.jsx +++ /dev/null @@ -1,34 +0,0 @@ -var p; -/* -var selfClosed1 =
; -var selfClosed2 =
; -var selfClosed3 =
; -var selfClosed4 =
; -var selfClosed5 =
; -var selfClosed6 =
; -var selfClosed7 =
; - -var openClosed1 =
; -var openClosed2 =
foo
; -var openClosed3 =
{p}
; -var openClosed4 =
{p < p}
; -var openClosed5 =
{p > p}
; -*/ -var SomeClass = (function () { - function SomeClass() { - } - SomeClass.prototype.f = function () { - var _this = this; - var rewrites1 =
{function () { return _this; }}
; - var rewrites4 =
; - }; - return SomeClass; -})(); -/* -var q = () => this; -var rewrites2 =
{[p, ...p, p]}
; -var rewrites3 =
{{p}}
; - -var rewrites5 =
; -var rewrites6 =
; -*/ diff --git a/tests/cases/conformance/jsx/tsxEmit3.jsx b/tests/cases/conformance/jsx/tsxEmit3.jsx deleted file mode 100644 index 7c979051d00..00000000000 --- a/tests/cases/conformance/jsx/tsxEmit3.jsx +++ /dev/null @@ -1,41 +0,0 @@ -var M; -(function (M) { - var Foo = (function () { - function Foo() { - } - return Foo; - })(); - M.Foo = Foo; - var S; - (function (S) { - var Bar = (function () { - function Bar() { - } - return Bar; - })(); - S.Bar = Bar; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.Foo - M.Foo, ; - var S; - (function (S) { - // Emit M.Foo - M.Foo, ; - // Emit S.Bar - S.Bar, ; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.S.Bar - M.S.Bar, ; -})(M || (M = {})); -var M; -(function (M_1) { - var M = 100; - // Emit M_1.Foo - M_1.Foo, ; -})(M || (M = {})); diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx index b8f14b0ba22..15ece4153a8 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit1.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx index 39a78a7da87..96ab8c6046b 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit2.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx index eb63be44f3b..12adcd3c2b6 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit3.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -2,6 +2,7 @@ //@filename: test.tsx declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx index f007c35c24a..a032a5a3985 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit4.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 38c966fa700..34fd158eab1 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/cases/fourslash/completionForExports.ts b/tests/cases/fourslash/completionForExports.ts deleted file mode 100644 index 57c0f75efc1..00000000000 --- a/tests/cases/fourslash/completionForExports.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -// @Filename: m1.ts -////export var foo: number = 1; -////export function bar() { return 10; } -////export function baz() { return 10; } - -// @Filename: m2.ts -////import {/*1*/, /*2*/ from "m1" -////import {/*3*/} from "m1" -////import {foo,/*4*/ from "m1" -////import {bar as /*5*/, /*6*/ from "m1" -////import {foo, bar, baz as b,/*7*/} from "m1" -function verifyCompletionAtMarker(marker: string, ...completions: string[]) { - goTo.marker(marker); - if (completions.length) { - for (var i = 0; i < completions.length; ++i) { - verify.completionListContains(completions[i]); - } - } - else { - verify.completionListIsEmpty(); - } -} - -verifyCompletionAtMarker("1", "foo", "bar", "baz"); -verifyCompletionAtMarker("2", "foo", "bar", "baz"); -verifyCompletionAtMarker("3", "foo", "bar", "baz"); -verifyCompletionAtMarker("4", "bar", "baz"); -verifyCompletionAtMarker("5"); -verifyCompletionAtMarker("6", "foo", "baz"); -verifyCompletionAtMarker("7"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts new file mode 100644 index 00000000000..48a50124daf --- /dev/null +++ b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts @@ -0,0 +1,7 @@ +/// + +////let v = [1,2,3,4]; +////let x = [.../**/ + +goTo.marker(); +verify.completionListContains("v"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index eac7085ab66..0552e540a7e 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -5,9 +5,8 @@ ////module A./*moduleName2*/ +goTo.marker("moduleName1"); +verify.not.completionListIsEmpty(); -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +goTo.marker("moduleName2"); +verify.completionListIsEmpty(); diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts new file mode 100644 index 00000000000..1191216baf1 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -0,0 +1,39 @@ +/// + +// @Filename: m1.ts +////export var foo: number = 1; +////export function bar() { return 10; } +////export function baz() { return 10; } + +// @Filename: m2.ts +////import {/*1*/, /*2*/ from "m1" +////import {/*3*/} from "m1" +////import {foo,/*4*/ from "m1" +////import {bar as /*5*/, /*6*/ from "m1" +////import {foo, bar, baz as b,/*7*/} from "m1" +function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { + goTo.marker(marker); + if (completions.length) { + for (let completion of completions) { + verify.completionListContains(completion); + } + } + else { + verify.completionListIsEmpty(); + } + + if (showBuilder) { + verify.completionListAllowsNewIdentifier(); + } + else { + verify.not.completionListAllowsNewIdentifier(); + } +} + +verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); +verifyCompletionAtMarker("5", /*showBuilder*/ true); +verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); +verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts new file mode 100644 index 00000000000..9cf216f4578 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -0,0 +1,13 @@ +/// + +////declare module "M1" { +//// export var V; +////} +//// +////declare module "M2" { +//// import { /**/ } from "M1" +////} + +goTo.marker(); +verify.completionListContains("V"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/memberListAfterDoubleDot.ts b/tests/cases/fourslash/memberListAfterDoubleDot.ts new file mode 100644 index 00000000000..21a1ad913ea --- /dev/null +++ b/tests/cases/fourslash/memberListAfterDoubleDot.ts @@ -0,0 +1,6 @@ +/// + +////../**/ + +goTo.marker(); +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index 0bc5107f2c1..62edf3b8c9e 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -3,4 +3,4 @@ ////./**/ goTo.marker(); -verify.not.memberListIsEmpty(); \ No newline at end of file +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index a1174d503ed..e7247f8e4ee 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -3,13 +3,13 @@ ////class Foo { ////} //// -////var x = class /**/Foo { +////var x = class [|Foo|] { //// doIt() { -//// return Foo; +//// return [|Foo|]; //// } //// //// static doItStatically() { -//// return Foo; +//// return [|Foo|]; //// } ////} //// @@ -23,12 +23,10 @@ // TODO (yuit): Fix up this test when class expressions are supported. // Just uncomment the below, remove the marker, and add the // appropriate ranges in the test itself. -goTo.marker(); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////let ranges = test.ranges() -////for (let range of ranges) { -//// goTo.position(range.start); -//// -//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////} \ No newline at end of file +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/tsxCompletion4.ts b/tests/cases/fourslash/tsxCompletion4.ts new file mode 100644 index 00000000000..6a66c4a898f --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion4.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare namespace JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +//// let bag = { x: 100, y: 200 }; +////