Skip to content
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

Support export = TypeScript syntax #1841

Closed
dpinol opened this issue Jul 1, 2020 · 7 comments
Closed

Support export = TypeScript syntax #1841

dpinol opened this issue Jul 1, 2020 · 7 comments
Assignees

Comments

@dpinol
Copy link

dpinol commented Jul 1, 2020

Hi,

I get "TypeError: Cannot read property 'name' of undefined" when importing an index.d.ts with export = AnalyticsNode.Analytics;:

I have "eslint-plugin-import": "^2.22.0" (which fixed #1818) I still get:


TypeError: Cannot read property 'name' of undefined
Occurred while linting /home/dani/hubtype/botonic/packages/botonic-cli/src/utils.ts:5
    at /home/dani/hubtype/botonic/node_modules/eslint-plugin-import/lib/ExportMap.js:712:221
    at Array.forEach (<anonymous>)
    at Function.ExportMap.parse (/home/dani/hubtype/botonic/node_modules/eslint-plugin-import/lib/ExportMap.js:706:248)
    at Function.ExportMap.for (/home/dani/hubtype/botonic/node_modules/eslint-plugin-import/lib/ExportMap.js:699:201)
    at Function.ExportMap.get (/home/dani/hubtype/botonic/node_modules/eslint-plugin-import/lib/ExportMap.js:693:370)
    at checkDefault (/home/dani/hubtype/botonic/node_modules/eslint-plugin-import/lib/rules/default.js:22:41)

It happens when importing a namespace from this file:

"analytics-node": "^3.4.0-beta.1",
"@types/analytics-node": "^3.1.3",

I added
console.log("exp", n.expression, n.expression.name, n.expression.id);
before
const exportedName = n.type === 'TSNamespaceExportDeclaration'
in ExportMap, and I got:

exp {
  type: 'MemberExpression',
  object: {
    type: 'Identifier',
    name: 'AnalyticsNode',
    range: [ 379, 392 ],
    loc: { start: [Object], end: [Object] }
  },
  property: {
    type: 'Identifier',
    name: 'Analytics',
    range: [ 393, 402 ],
    loc: { start: [Object], end: [Object] }
  },
  computed: false,
  optional: false,
  range: [ 379, 402 ],
  loc: { start: { line: 8, column: 9 }, end: { line: 8, column: 32 } }
} undefined undefined

It crashes because the expression has no name nor id fields.

I tried hard to generate a small test case, but I could not reproduce the issue then.

My workaround to avoid the crash was removing this

  settings: {
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
    },

@nickharris
Copy link

nickharris commented Jul 7, 2020

@dpinol @ljharb any rough idea when a package with this fix will be published to npmjs?

@ljharb
Copy link
Member

ljharb commented Jul 7, 2020

Nope, but hopefully not long.

@montgomp
Copy link

montgomp commented Aug 3, 2020

Is there any update here?

@ljharb
Copy link
Member

ljharb commented Aug 4, 2020

@montgomp Nope, no release yet.

@adithi-k
Copy link

adithi-k commented Aug 13, 2020

@ljharb any idea when it will be published to npmjs?

@akankshajsh
Copy link

Can you please update when the above fix will be merged?

@ljharb
Copy link
Member

ljharb commented Sep 27, 2020

v2.22.1 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants