Fix37991 (#43166)
* Add failing test * Fix tslib check errors for commonjs imports
This commit is contained in:
parent
9610c16cc8
commit
ec4863cc0e
|
@ -34678,8 +34678,8 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.BindingElement) {
|
||||
if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext) {
|
||||
if (isBindingElement(node)) {
|
||||
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < ScriptTarget.ES2018) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.Rest);
|
||||
}
|
||||
// check computed properties inside property names of binding elements
|
||||
|
|
8
tests/baselines/reference/tslibInJs.errors.txt
Normal file
8
tests/baselines/reference/tslibInJs.errors.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
tests/cases/compiler/main.js(2,25): error TS2307: Cannot find module 'bar' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/main.js (1 errors) ====
|
||||
"use strict";
|
||||
const { foo } = require("bar");
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'bar' or its corresponding type declarations.
|
6
tests/baselines/reference/tslibInJs.symbols
Normal file
6
tests/baselines/reference/tslibInJs.symbols
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/compiler/main.js ===
|
||||
"use strict";
|
||||
const { foo } = require("bar");
|
||||
>foo : Symbol(foo, Decl(main.js, 1, 7))
|
||||
>require : Symbol(require)
|
||||
|
10
tests/baselines/reference/tslibInJs.types
Normal file
10
tests/baselines/reference/tslibInJs.types
Normal file
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/main.js ===
|
||||
"use strict";
|
||||
>"use strict" : "use strict"
|
||||
|
||||
const { foo } = require("bar");
|
||||
>foo : any
|
||||
>require("bar") : any
|
||||
>require : any
|
||||
>"bar" : "bar"
|
||||
|
13
tests/cases/compiler/tslibInJs.ts
Normal file
13
tests/cases/compiler/tslibInJs.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @moduleResolution: node
|
||||
// @target: es2018
|
||||
// @module: commonjs
|
||||
// @importHelpers: true
|
||||
// @lib: es2018
|
||||
// @outDir: out
|
||||
// @noEmit: true
|
||||
|
||||
// @fileName: main.js
|
||||
"use strict";
|
||||
const { foo } = require("bar");
|
Loading…
Reference in a new issue