Skip to content

Fix37991 #43166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2021
Merged

Fix37991 #43166

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34665,8 +34665,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
Expand Down
8 changes: 8 additions & 0 deletions tests/baselines/reference/tslibInJs.errors.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions tests/baselines/reference/tslibInJs.symbols
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions tests/baselines/reference/tslibInJs.types
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions tests/cases/compiler/tslibInJs.ts
Original file line number Diff line number Diff line change
@@ -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");