* Add failing test

* Fix tslib check errors for commonjs imports
This commit is contained in:
Ron Buckton 2021-03-09 11:43:19 -08:00 committed by GitHub
parent 9610c16cc8
commit ec4863cc0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 2 deletions

View file

@ -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

View 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.

View 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)

View 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"

View 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");