TypeScript/tests/cases/conformance/salsa/nestedDestructuringOfRequire.ts
Nathan Shively-Sanders b7c598ea39
Use ad-hoc code for nested destructuring in require (#40188)
* Use ad-hoc code for nested destructuring in require

Nested destructuring doesn't really map to ES imports:

```js
const { utils: { nub, intercalate } } = require('./monopackage')
```

Previously, isRequireVariableDeclaration walked up binding elements
until it reached a variable declaration. This change instead only walks
up one binding element and stops. Then it's not bound as an alias and
uses the checker-only code to produce types for the nested-imported
identifiers.

Fixes #40143

* revert binder formatting change
2020-09-10 13:07:58 -07:00

18 lines
243 B
TypeScript

// @allowJs: true
// @checkJs: true
// @outDir: out
// @declaration: true
// @filename: mod1.js
const chalk = {
grey: {}
};
module.exports.chalk = chalk
// @filename: main.js
const {
chalk: { grey }
} = require('./mod1');
grey
chalk