Skip to content

Add nullcheck when calculating indentations for implort clause #9426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/formatting/smartIndenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ namespace ts.formatting {
return childKind !== SyntaxKind.NamedExports;
case SyntaxKind.ImportDeclaration:
return childKind !== SyntaxKind.ImportClause ||
(<ImportClause>child).namedBindings.kind !== SyntaxKind.NamedImports;
((<ImportClause>child).namedBindings && (<ImportClause>child).namedBindings.kind !== SyntaxKind.NamedImports);
case SyntaxKind.JsxElement:
return childKind !== SyntaxKind.JsxClosingElement;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/cases/fourslash/formattingIllegalImportClause.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path='fourslash.ts' />

//// var expect = require('expect.js');
//// import React from 'react'/*1*/;
//// import { mount } from 'enzyme';
//// require('../setup');
//// var Amount = require('../../src/js/components/amount');

//// describe('<Failed />', () => {
//// var history
//// beforeEach(() => {
//// history = createMemoryHistory();
//// sinon.spy(history, 'pushState');
//// });

//// afterEach(() => {
//// })

//// it('redirects to order summary', () => {

//// });
//// });

format.document();
goTo.marker("1");
verify.currentLineContentIs("import React from 'react';")