question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

imported function call without leading semicolon

See original GitHub issue

Repro link

import {fun} from './foo'
let arr = []
fun()

…becomes…

"use strict";var _foo = require('./foo');
let arr = []
(0, _foo.fun)()

…which evaluates to TypeError: [] is not a function

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
alangpiercecommented, Nov 18, 2018

(Oops, typo, it should be “just do the regular replacement”.)

I think it’s referring to cases like this:

export let x = 1;
x = 2;

Without being careful, we might transform the second line to (0, exports.x) = 2;, which isn’t a valid assignment. It’s from https://github.com/alangpierce/sucrase/pull/180 , where I switched the export approach to use variable replacement and changed the replacement strategy from “do the (0, f) thing everywhere for simplicity” to a more targeted approach.

If you’re reworking the code, not super-important to keep that line, I think it made more sense in the original context.

0reactions
aleclarsoncommented, Nov 18, 2018

What does this comment mean?

In some cases, like export assignees, we must NOT turn the identifier into a normal expression, so we need to just to the regular replacement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow importing of modules that don't use semicolons #1004
Give a option to output leading semicolon instead trailing semicolon. Trailing semicolon not compitable with Standard JS.
Read more >
ecmascript 6 - Does import statement need semicolon actually?
Use semi colons when declaring variables, returning something or making variable calls, as you are declaring a variable with the import it ...
Read more >
Print Hello World Without using a Semicolon in Java
Java Program to Print Hello World Without Semicolon. // Using append() method of String class. // Importing required classes.
Read more >
[SOLVED] Semi-colon not supressing output - MATLAB Answers
The issue seems to be with the last two functions, namely table2array and readtable. This would be a minor issue if I had...
Read more >
unnecessary-semicolon / W0301 - Pylint 2.16.0-dev ...
Unnecessary semicolon. Description: Used when a statement is ended by a semi-colon (";"), which isn't necessary (that's python, not C ;). Problematic code:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found