Skip to content

Commit 62ed618

Browse files
committed
Change the name of defaultBinding to name and make ImportClause as Declaration
This helps binder to use it directly to bind the default binding
1 parent d85581b commit 62ed618

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/compiler/parser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4569,12 +4569,12 @@ module ts {
45694569
if (identifier) {
45704570
// ImportedDefaultBinding:
45714571
// ImportedBinding
4572-
importClause.defaultBinding = identifier;
4572+
importClause.name = identifier;
45734573
}
45744574

45754575
// If there was no default import or if there is comma token after default import
45764576
// parse namespace or named imports
4577-
if (!importClause.defaultBinding ||
4577+
if (!importClause.name ||
45784578
parseOptional(SyntaxKind.CommaToken)) {
45794579
importClause.namedBindings = token === SyntaxKind.AsteriskToken ? parseNamespaceImport() : parseNamedImports();
45804580
}

src/compiler/types.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,13 @@ module ts {
878878
}
879879

880880
// In case of:
881-
// import d from "mod" => defaultBinding = d, namedBinding = undefined
882-
// import * as ns from "mod" => defaultBinding = undefined, namedBinding: NamespaceImport = { name: ns }
883-
// import d, * as ns from "mod" => defaultBinding = d, namedBinding: NamespaceImport = { name: ns }
884-
// import { a, b as x } from "mod" => defaultBinding = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
885-
// import d, { a, b as x } from "mod" => defaultBinding = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
886-
export interface ImportClause extends Node {
887-
defaultBinding?: Identifier;
881+
// import d from "mod" => name = d, namedBinding = undefined
882+
// import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns }
883+
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
884+
// import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
885+
// import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
886+
export interface ImportClause extends Declaration {
887+
name?: Identifier; // Default binding
888888
namedBindings?: NamespaceImport | NamedImports;
889889
}
890890

0 commit comments

Comments
 (0)