From fe040e2d5dd9d55ccfc6cab867fcd869e77a1203 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 Oct 2017 21:24:51 -0400 Subject: [PATCH 1/2] Adds failing test --- test/TypescriptParser.spec.ts | 2 +- .../TypescriptParser.spec.ts.snap | 30 +++++++++++++++++++ .../typescript-parser/importsOnly.ts | 3 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/TypescriptParser.spec.ts b/test/TypescriptParser.spec.ts index a7e3093..5a67292 100644 --- a/test/TypescriptParser.spec.ts +++ b/test/TypescriptParser.spec.ts @@ -51,7 +51,7 @@ describe('TypescriptParser', () => { }); it('should parse imports', () => { - expect(parsed.imports).toHaveLength(9); + expect(parsed.imports).toHaveLength(12); expect(parsed.imports).toMatchSnapshot(); }); diff --git a/test/__snapshots__/TypescriptParser.spec.ts.snap b/test/__snapshots__/TypescriptParser.spec.ts.snap index 0d94eee..c568c07 100644 --- a/test/__snapshots__/TypescriptParser.spec.ts.snap +++ b/test/__snapshots__/TypescriptParser.spec.ts.snap @@ -1012,6 +1012,36 @@ Array [ ], "start": 400, }, + NamedImport { + "defaultAlias": "__DefaultAlias", + "end": 540, + "libraryName": "namedImport", + "specifiers": Array [ + SymbolSpecifier { + "alias": "__Specifier1", + "specifier": "Specifier1", + }, + ], + "start": 456, + }, + NamedImport { + "defaultAlias": "__DefaultAlias", + "end": 614, + "libraryName": "namedImport", + "specifiers": Array [ + SymbolSpecifier { + "alias": "__Specifier1", + "specifier": "Specifier1", + }, + ], + "start": 541, + }, + NamespaceImport { + "alias": "__namespaceImport", + "end": 662, + "libraryName": "namespace", + "start": 615, + }, ] `; diff --git a/test/_workspace/typescript-parser/importsOnly.ts b/test/_workspace/typescript-parser/importsOnly.ts index 61d3692..d96617f 100644 --- a/test/_workspace/typescript-parser/importsOnly.ts +++ b/test/_workspace/typescript-parser/importsOnly.ts @@ -10,3 +10,6 @@ import { import Foobar from 'aFile'; import { default as DefaultAlias, Specifier1 } from 'namedImport'; import DefaultAlias, { Specifier1 } from 'namedImport'; +import { default as __DefaultAlias, Specifier1 as __Specifier1 } from 'namedImport'; +import __DefaultAlias, { Specifier1 as __Specifier1 } from 'namedImport'; +import * as __namespaceImport from 'namespace'; \ No newline at end of file From 6ed0caf358758b3716131d010b621b902ad4fb96 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 Oct 2017 18:20:02 -0400 Subject: [PATCH 2/2] Fixes #35 and buehler/typescript-hero#320 by upgrading to TS 2.5 - type assertion is necessary to make TS 2.5 happy --- package.json | 2 +- src/DeclarationIndex.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c0af237..5bce8e3 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,6 @@ "dependencies": { "lodash": "^4.17.4", "tslib": "^1.7.1", - "typescript": "2.4.2" + "typescript": "^2.5.3" } } diff --git a/src/DeclarationIndex.ts b/src/DeclarationIndex.ts index f16ccc8..bd0bcee 100644 --- a/src/DeclarationIndex.ts +++ b/src/DeclarationIndex.ts @@ -118,7 +118,7 @@ export class DeclarationIndex { */ public get declarationInfos(): DeclarationInfo[] { return Object - .keys(this.index) + .keys(this.index!) .sort() .reduce((all, key) => all.concat(this.index![key]), []); }