Dont let an import that doesnt need helpers override one that does (#22966) (#22990)

This commit is contained in:
Wesley Wigham
2018-03-29 11:58:20 -07:00
committed by GitHub
parent 209e92fd7a
commit 0b2d6f6993
5 changed files with 134 additions and 1 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ namespace ts {
// import * as x from "mod"
// import { x, y } from "mod"
externalImports.push(<ImportDeclaration>node);
hasImportStarOrImportDefault = getImportNeedsImportStarHelper(<ImportDeclaration>node) || getImportNeedsImportDefaultHelper(<ImportDeclaration>node);
hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(<ImportDeclaration>node) || getImportNeedsImportDefaultHelper(<ImportDeclaration>node);
break;
case SyntaxKind.ImportEqualsDeclaration:
@@ -0,0 +1,39 @@
//// [tests/cases/compiler/esModuleInteropImportTSLibHasImport.ts] ////
//// [types.d.ts]
declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; }
//// [username.ts]
export const username = () => 'username';
//// [index.ts]
export * from './username';
//// [hello.ts]
const sayHello = (name?: string) => void (`Hello, ${name}!`);
export default sayHello;
//// [index.ts]
import sayHello from "./hello";
import { username } from './utils';
sayHello(username());
//// [username.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.username = () => 'username';
//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./username"), exports);
//// [hello.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const sayHello = (name) => void (`Hello, ${name}!`);
exports.default = sayHello;
//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const hello_1 = tslib_1.__importDefault(require("./hello"));
const utils_1 = require("./utils");
hello_1.default(utils_1.username());
@@ -0,0 +1,33 @@
=== tests/cases/compiler/types.d.ts ===
declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; }
>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 0))
>__exportStar : Symbol(__exportStar, Decl(types.d.ts, 0, 37))
>__importDefault : Symbol(__importDefault, Decl(types.d.ts, 0, 69))
>__importStar : Symbol(__importStar, Decl(types.d.ts, 0, 104))
=== tests/cases/compiler/utils/username.ts ===
export const username = () => 'username';
>username : Symbol(username, Decl(username.ts, 0, 12))
=== tests/cases/compiler/utils/index.ts ===
export * from './username';
No type information for this code.=== tests/cases/compiler/hello.ts ===
const sayHello = (name?: string) => void (`Hello, ${name}!`);
>sayHello : Symbol(sayHello, Decl(hello.ts, 0, 5))
>name : Symbol(name, Decl(hello.ts, 0, 18))
>name : Symbol(name, Decl(hello.ts, 0, 18))
export default sayHello;
>sayHello : Symbol(sayHello, Decl(hello.ts, 0, 5))
=== tests/cases/compiler/index.ts ===
import sayHello from "./hello";
>sayHello : Symbol(sayHello, Decl(index.ts, 0, 6))
import { username } from './utils';
>username : Symbol(username, Decl(index.ts, 1, 8))
sayHello(username());
>sayHello : Symbol(sayHello, Decl(index.ts, 0, 6))
>username : Symbol(username, Decl(index.ts, 1, 8))
@@ -0,0 +1,41 @@
=== tests/cases/compiler/types.d.ts ===
declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; }
>"tslib" : typeof "tslib"
>__exportStar : any
>__importDefault : any
>__importStar : any
=== tests/cases/compiler/utils/username.ts ===
export const username = () => 'username';
>username : () => string
>() => 'username' : () => string
>'username' : "username"
=== tests/cases/compiler/utils/index.ts ===
export * from './username';
No type information for this code.=== tests/cases/compiler/hello.ts ===
const sayHello = (name?: string) => void (`Hello, ${name}!`);
>sayHello : (name?: string) => any
>(name?: string) => void (`Hello, ${name}!`) : (name?: string) => any
>name : string
>void (`Hello, ${name}!`) : undefined
>(`Hello, ${name}!`) : string
>`Hello, ${name}!` : string
>name : string
export default sayHello;
>sayHello : (name?: string) => any
=== tests/cases/compiler/index.ts ===
import sayHello from "./hello";
>sayHello : (name?: string) => any
import { username } from './utils';
>username : () => string
sayHello(username());
>sayHello(username()) : any
>sayHello : (name?: string) => any
>username() : string
>username : () => string
@@ -0,0 +1,20 @@
// @esModuleInterop: true
// @importHelpers: true
// @noEmitHelpers: true
// @target: es2017
// @module: commonjs
// @filename: types.d.ts
declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; }
// @filename: utils/username.ts
export const username = () => 'username';
// @filename: utils/index.ts
export * from './username';
// @filename: hello.ts
const sayHello = (name?: string) => void (`Hello, ${name}!`);
export default sayHello;
// @filename: index.ts
import sayHello from "./hello";
import { username } from './utils';
sayHello(username());