Print {} in import if it's in the source, fixes #2145 (#2150)

master
Lucas Azzola 2017-06-15 20:19:01 +10:00 committed by GitHub
parent cb44125a21
commit 9e7b02d50e
3 changed files with 22 additions and 1 deletions

View File

@ -694,7 +694,13 @@ function genericPrintNoParens(path, options, print, args) {
}
parts.push(" ", "from ");
} else if (n.importKind && n.importKind === "type") {
} else if (
(n.importKind && n.importKind === "type") ||
// import {} from 'x'
/{\s*}/.test(
options.originalText.slice(util.locStart(n), util.locStart(n.source))
)
) {
parts.push("{} from ");
}

View File

@ -228,6 +228,20 @@ import {
`;
exports[`empty-import.js 1`] = `
import { } from '@types/googlemaps';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import {} from "@types/googlemaps";
`;
exports[`empty-import.js 2`] = `
import { } from '@types/googlemaps';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import {} from "@types/googlemaps";
`;
exports[`inline.js 1`] = `
import somethingSuperLongsomethingSuperLong from 'somethingSuperLongsomethingSuperLongsomethingSuperLong'
import {somethingSuperLongsomethingSuperLong} from 'somethingSuperLongsomethingSuperLongsomethingSuperLong'

View File

@ -0,0 +1 @@
import { } from '@types/googlemaps';