mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-16 01:41:17 -06:00
Fix tslib resolutions (#58451)
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
parent
320764c386
commit
14b4529a69
@ -32194,12 +32194,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const errorMessage = isClassic
|
||||
? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
|
||||
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
|
||||
// Synthesized JSX import is either first or after tslib
|
||||
const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0;
|
||||
const specifier = file?.imports[jsxImportIndex];
|
||||
if (specifier) {
|
||||
Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`);
|
||||
}
|
||||
const specifier = getJSXRuntimeImportSpecifier(file, runtimeImportSpecifier);
|
||||
const mod = resolveExternalModule(specifier || location!, runtimeImportSpecifier, errorMessage, location!);
|
||||
const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
|
||||
if (links) {
|
||||
@ -49193,9 +49188,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveHelpersModule(node: SourceFile, errorNode: Node) {
|
||||
function resolveHelpersModule(file: SourceFile, errorNode: Node) {
|
||||
if (!externalHelpersModule) {
|
||||
externalHelpersModule = resolveExternalModule(node, externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
|
||||
externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
|
||||
}
|
||||
return externalHelpersModule;
|
||||
}
|
||||
@ -51145,6 +51140,23 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
blockScopeKind === NodeFlags.Using ||
|
||||
blockScopeKind === NodeFlags.AwaitUsing;
|
||||
}
|
||||
|
||||
function getJSXRuntimeImportSpecifier(file: SourceFile | undefined, specifierText: string) {
|
||||
// Synthesized JSX import is either first or after tslib
|
||||
const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0;
|
||||
const specifier = file?.imports[jsxImportIndex];
|
||||
if (specifier) {
|
||||
Debug.assert(nodeIsSynthesized(specifier) && specifier.text === specifierText, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`);
|
||||
}
|
||||
return specifier;
|
||||
}
|
||||
|
||||
function getImportHelpersImportSpecifier(file: SourceFile) {
|
||||
Debug.assert(compilerOptions.importHelpers, "Expected importHelpers to be enabled");
|
||||
const specifier = file.imports[0];
|
||||
Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`);
|
||||
return specifier;
|
||||
}
|
||||
}
|
||||
|
||||
function isNotAccessor(declaration: Declaration): boolean {
|
||||
|
||||
@ -3419,7 +3419,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
|
||||
function createSyntheticImport(text: string, file: SourceFile) {
|
||||
const externalHelpersModuleReference = factory.createStringLiteral(text);
|
||||
const importDecl = factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*attributes*/ undefined);
|
||||
const importDecl = factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference);
|
||||
addInternalEmitFlags(importDecl, InternalEmitFlags.NeverApplyImportHelper);
|
||||
setParent(externalHelpersModuleReference, importDecl);
|
||||
setParent(importDecl, file);
|
||||
@ -3444,11 +3444,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
let ambientModules: string[] | undefined;
|
||||
|
||||
// If we are importing helpers, we need to add a synthetic reference to resolve the
|
||||
// helpers library.
|
||||
if (
|
||||
(getIsolatedModules(options) || isExternalModuleFile)
|
||||
&& !file.isDeclarationFile
|
||||
) {
|
||||
// helpers library. (A JavaScript file without `externalModuleIndicator` set might be
|
||||
// a CommonJS module; `commonJsModuleIndicator` doesn't get set until the binder has
|
||||
// run. We synthesize a helpers import for it just in case; it will never be used if
|
||||
// the binder doesn't find and set a `commonJsModuleIndicator`.)
|
||||
if (isJavaScriptFile || (!file.isDeclarationFile && (getIsolatedModules(options) || isExternalModule(file)))) {
|
||||
if (options.importHelpers) {
|
||||
// synthesize 'import "tslib"' declaration
|
||||
imports = [createSyntheticImport(externalHelpersModuleNameText, file)];
|
||||
|
||||
51
tests/baselines/reference/importHelpersBundler.js
Normal file
51
tests/baselines/reference/importHelpersBundler.js
Normal file
@ -0,0 +1,51 @@
|
||||
//// [tests/cases/compiler/importHelpersBundler.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
//// [tslib.d.ts]
|
||||
export {};
|
||||
|
||||
//// [package.json]
|
||||
{ "type": "module" }
|
||||
|
||||
//// [index.d.ts]
|
||||
export declare var __rest: any;
|
||||
|
||||
//// [main.ts]
|
||||
export function foo(args: any) {
|
||||
const { bar, ...extraArgs } = args;
|
||||
return extraArgs;
|
||||
}
|
||||
|
||||
|
||||
//// [main.js]
|
||||
import { __rest } from "tslib";
|
||||
export function foo(args) {
|
||||
const { bar } = args, extraArgs = __rest(args, ["bar"]);
|
||||
return extraArgs;
|
||||
}
|
||||
24
tests/baselines/reference/importHelpersBundler.symbols
Normal file
24
tests/baselines/reference/importHelpersBundler.symbols
Normal file
@ -0,0 +1,24 @@
|
||||
//// [tests/cases/compiler/importHelpersBundler.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
export declare var __rest: any;
|
||||
>__rest : Symbol(__rest, Decl(index.d.ts, 0, 18))
|
||||
|
||||
=== /main.ts ===
|
||||
export function foo(args: any) {
|
||||
>foo : Symbol(foo, Decl(main.ts, 0, 0))
|
||||
>args : Symbol(args, Decl(main.ts, 0, 20))
|
||||
|
||||
const { bar, ...extraArgs } = args;
|
||||
>bar : Symbol(bar, Decl(main.ts, 1, 9))
|
||||
>extraArgs : Symbol(extraArgs, Decl(main.ts, 1, 14))
|
||||
>args : Symbol(args, Decl(main.ts, 0, 20))
|
||||
|
||||
return extraArgs;
|
||||
>extraArgs : Symbol(extraArgs, Decl(main.ts, 1, 14))
|
||||
}
|
||||
|
||||
27
tests/baselines/reference/importHelpersBundler.types
Normal file
27
tests/baselines/reference/importHelpersBundler.types
Normal file
@ -0,0 +1,27 @@
|
||||
//// [tests/cases/compiler/importHelpersBundler.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
export declare var __rest: any;
|
||||
>__rest : any
|
||||
|
||||
=== /main.ts ===
|
||||
export function foo(args: any) {
|
||||
>foo : (args: any) => any
|
||||
> : ^ ^^ ^^^^^^^^
|
||||
>args : any
|
||||
|
||||
const { bar, ...extraArgs } = args;
|
||||
>bar : any
|
||||
> : ^^^
|
||||
>extraArgs : any
|
||||
> : ^^^
|
||||
>args : any
|
||||
|
||||
return extraArgs;
|
||||
>extraArgs : any
|
||||
}
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
//// [tslib.d.ts]
|
||||
export declare var __extends: any;
|
||||
|
||||
//// [package.json]
|
||||
{ "type": "module" }
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.js]
|
||||
class Foo {}
|
||||
|
||||
class Bar extends Foo {}
|
||||
|
||||
module.exports = Bar;
|
||||
|
||||
|
||||
//// [index.js]
|
||||
var tslib_1 = require("tslib");
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
}());
|
||||
var Bar = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(Bar, _super);
|
||||
function Bar() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Bar;
|
||||
}(Foo));
|
||||
module.exports = Bar;
|
||||
@ -0,0 +1,24 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __extends: any;
|
||||
>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --))
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /index.js ===
|
||||
class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(index.js, 0, 0))
|
||||
|
||||
class Bar extends Foo {}
|
||||
>Bar : Symbol(Bar, Decl(index.js, 0, 12))
|
||||
>Foo : Symbol(Foo, Decl(index.js, 0, 0))
|
||||
|
||||
module.exports = Bar;
|
||||
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
|
||||
>module : Symbol(export=, Decl(index.js, 2, 24))
|
||||
>exports : Symbol(export=, Decl(index.js, 2, 24))
|
||||
>Bar : Symbol(Bar, Decl(index.js, 0, 12))
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __extends: any;
|
||||
>__extends : any
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /index.js ===
|
||||
class Foo {}
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
class Bar extends Foo {}
|
||||
>Bar : Bar
|
||||
> : ^^^
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
module.exports = Bar;
|
||||
>module.exports = Bar : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>module.exports : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>module : { exports: typeof Bar; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>exports : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>Bar : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
//// [tslib.d.ts]
|
||||
export declare var __extends: any;
|
||||
|
||||
//// [package.json]
|
||||
{ "type": "module" }
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.js]
|
||||
class Foo {}
|
||||
|
||||
class Bar extends Foo {}
|
||||
|
||||
module.exports = Bar;
|
||||
|
||||
|
||||
//// [index.js]
|
||||
var tslib_1 = require("tslib");
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
}());
|
||||
var Bar = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(Bar, _super);
|
||||
function Bar() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Bar;
|
||||
}(Foo));
|
||||
module.exports = Bar;
|
||||
@ -0,0 +1,24 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __extends: any;
|
||||
>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --))
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /index.js ===
|
||||
class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(index.js, 0, 0))
|
||||
|
||||
class Bar extends Foo {}
|
||||
>Bar : Symbol(Bar, Decl(index.js, 0, 12))
|
||||
>Foo : Symbol(Foo, Decl(index.js, 0, 0))
|
||||
|
||||
module.exports = Bar;
|
||||
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
|
||||
>module : Symbol(export=, Decl(index.js, 2, 24))
|
||||
>exports : Symbol(export=, Decl(index.js, 2, 24))
|
||||
>Bar : Symbol(Bar, Decl(index.js, 0, 12))
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/importHelpersCommonJSJavaScript.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __extends: any;
|
||||
>__extends : any
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /index.js ===
|
||||
class Foo {}
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
class Bar extends Foo {}
|
||||
>Bar : Bar
|
||||
> : ^^^
|
||||
>Foo : Foo
|
||||
> : ^^^
|
||||
|
||||
module.exports = Bar;
|
||||
>module.exports = Bar : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>module.exports : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>module : { exports: typeof Bar; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>exports : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
>Bar : typeof Bar
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
//// [tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
//// [tslib.d.ts]
|
||||
export declare var __rest: any;
|
||||
|
||||
//// [package.json]
|
||||
{ "type": "module" }
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [main.cts]
|
||||
function foo(args: any) {
|
||||
const { bar, ...extraArgs } = args;
|
||||
return extraArgs;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
|
||||
//// [main.cjs]
|
||||
import * as tslib_1 from "tslib";
|
||||
function foo(args) {
|
||||
const { bar } = args, extraArgs = __rest(args, ["bar"]);
|
||||
return extraArgs;
|
||||
}
|
||||
module.exports = foo;
|
||||
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __rest: any;
|
||||
>__rest : Symbol(__rest, Decl(tslib.d.ts, --, --))
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /main.cts ===
|
||||
function foo(args: any) {
|
||||
>foo : Symbol(foo, Decl(main.cts, 0, 0))
|
||||
>args : Symbol(args, Decl(main.cts, 0, 13))
|
||||
|
||||
const { bar, ...extraArgs } = args;
|
||||
>bar : Symbol(bar, Decl(main.cts, 1, 9))
|
||||
>extraArgs : Symbol(extraArgs, Decl(main.cts, 1, 14))
|
||||
>args : Symbol(args, Decl(main.cts, 0, 13))
|
||||
|
||||
return extraArgs;
|
||||
>extraArgs : Symbol(extraArgs, Decl(main.cts, 1, 14))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(main.cts, 0, 0))
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
//// [tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts] ////
|
||||
|
||||
=== /node_modules/tslib/tslib.d.ts ===
|
||||
export declare var __rest: any;
|
||||
>__rest : any
|
||||
|
||||
=== /node_modules/tslib/modules/index.d.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== /main.cts ===
|
||||
function foo(args: any) {
|
||||
>foo : (args: any) => any
|
||||
> : ^ ^^ ^^^^^^^^
|
||||
>args : any
|
||||
|
||||
const { bar, ...extraArgs } = args;
|
||||
>bar : any
|
||||
> : ^^^
|
||||
>extraArgs : any
|
||||
> : ^^^
|
||||
>args : any
|
||||
|
||||
return extraArgs;
|
||||
>extraArgs : any
|
||||
}
|
||||
export = foo;
|
||||
>foo : (args: any) => any
|
||||
> : ^ ^^ ^^^^^^^^
|
||||
|
||||
46
tests/cases/compiler/importHelpersBundler.ts
Normal file
46
tests/cases/compiler/importHelpersBundler.ts
Normal file
@ -0,0 +1,46 @@
|
||||
// @importHelpers: true
|
||||
// @target: es2017
|
||||
// @module: esnext
|
||||
// @moduleResolution: bundler
|
||||
|
||||
// @Filename: /node_modules/tslib/package.json
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
// @Filename: /node_modules/tslib/tslib.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/package.json
|
||||
{ "type": "module" }
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/index.d.ts
|
||||
export declare var __rest: any;
|
||||
|
||||
// @Filename: /main.ts
|
||||
export function foo(args: any) {
|
||||
const { bar, ...extraArgs } = args;
|
||||
return extraArgs;
|
||||
}
|
||||
48
tests/cases/compiler/importHelpersCommonJSJavaScript.ts
Normal file
48
tests/cases/compiler/importHelpersCommonJSJavaScript.ts
Normal file
@ -0,0 +1,48 @@
|
||||
// @checkJs: true
|
||||
// @outDir: ./out
|
||||
// @module: commonjs
|
||||
// @importHelpers: true
|
||||
// @verbatimModuleSyntax: true,false
|
||||
|
||||
// @Filename: /node_modules/tslib/package.json
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
// @Filename: /node_modules/tslib/tslib.d.ts
|
||||
export declare var __extends: any;
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/package.json
|
||||
{ "type": "module" }
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /index.js
|
||||
class Foo {}
|
||||
|
||||
class Bar extends Foo {}
|
||||
|
||||
module.exports = Bar;
|
||||
48
tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts
Normal file
48
tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts
Normal file
@ -0,0 +1,48 @@
|
||||
// @importHelpers: true
|
||||
// @target: es2017
|
||||
// @module: preserve
|
||||
// @moduleResolution: bundler
|
||||
// @verbatimModuleSyntax: true
|
||||
|
||||
// @Filename: /node_modules/tslib/package.json
|
||||
{
|
||||
"name": "tslib",
|
||||
"main": "tslib.js",
|
||||
"module": "tslib.es6.js",
|
||||
"jsnext:main": "tslib.es6.js",
|
||||
"typings": "tslib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
},
|
||||
"import": {
|
||||
"node": "./modules/index.js",
|
||||
"default": {
|
||||
"types": "./modules/index.d.ts",
|
||||
"default": "./tslib.es6.mjs"
|
||||
}
|
||||
},
|
||||
"default": "./tslib.js"
|
||||
},
|
||||
"./*": "./*",
|
||||
"./": "./"
|
||||
}
|
||||
}
|
||||
|
||||
// @Filename: /node_modules/tslib/tslib.d.ts
|
||||
export declare var __rest: any;
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/package.json
|
||||
{ "type": "module" }
|
||||
|
||||
// @Filename: /node_modules/tslib/modules/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /main.cts
|
||||
function foo(args: any) {
|
||||
const { bar, ...extraArgs } = args;
|
||||
return extraArgs;
|
||||
}
|
||||
export = foo;
|
||||
Loading…
x
Reference in New Issue
Block a user