Converts `const name = require("moduleSpecifier").propertyName`
(name, propertyName, moduleSpecifier, identifiers, quotePreference)
| 152246 | } |
| 152247 | /** Converts `const name = require("moduleSpecifier").propertyName` */ |
| 152248 | function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { |
| 152249 | switch (name.kind) { |
| 152250 | case 201 /* SyntaxKind.ObjectBindingPattern */: |
| 152251 | case 202 /* SyntaxKind.ArrayBindingPattern */: { |
| 152252 | // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` |
| 152253 | var tmp = makeUniqueName(propertyName, identifiers); |
| 152254 | return convertedImports([ |
| 152255 | makeSingleImport(tmp, propertyName, moduleSpecifier, quotePreference), |
| 152256 | makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), |
| 152257 | ]); |
| 152258 | } |
| 152259 | case 79 /* SyntaxKind.Identifier */: |
| 152260 | // `const a = require("b").c` --> `import { c as a } from "./b"; |
| 152261 | return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); |
| 152262 | default: |
| 152263 | return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); |
| 152264 | } |
| 152265 | } |
| 152266 | function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { |
| 152267 | var left = assignment.left, right = assignment.right; |
| 152268 | if (!ts.isPropertyAccessExpression(left)) { |
no test coverage detected