From 62ed6183d9ceda708a8ce184960d7f25e8d45cf5 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 30 Jan 2015 13:02:11 -0800 Subject: [PATCH] Change the name of defaultBinding to name and make ImportClause as Declaration This helps binder to use it directly to bind the default binding --- src/compiler/parser.ts | 4 ++-- src/compiler/types.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 35c74a7ef48..33742378b61 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4569,12 +4569,12 @@ module ts { if (identifier) { // ImportedDefaultBinding: // ImportedBinding - importClause.defaultBinding = identifier; + importClause.name = identifier; } // If there was no default import or if there is comma token after default import // parse namespace or named imports - if (!importClause.defaultBinding || + if (!importClause.name || parseOptional(SyntaxKind.CommaToken)) { importClause.namedBindings = token === SyntaxKind.AsteriskToken ? parseNamespaceImport() : parseNamedImports(); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d1410240911..d46e31dc982 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -878,13 +878,13 @@ module ts { } // In case of: - // import d from "mod" => defaultBinding = d, namedBinding = undefined - // import * as ns from "mod" => defaultBinding = undefined, namedBinding: NamespaceImport = { name: ns } - // import d, * as ns from "mod" => defaultBinding = d, namedBinding: NamespaceImport = { name: ns } - // import { a, b as x } from "mod" => defaultBinding = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} - // import d, { a, b as x } from "mod" => defaultBinding = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} - export interface ImportClause extends Node { - defaultBinding?: Identifier; + // import d from "mod" => name = d, namedBinding = undefined + // import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns } + // import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns } + // import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} + // import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} + export interface ImportClause extends Declaration { + name?: Identifier; // Default binding namedBindings?: NamespaceImport | NamedImports; }