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.

IntelliJ creates import statements which fail on runtime after (ts) transpile

See original GitHub issue

When coding with IntelliJ which is fully typescript capable, when coding a line like this:

let message:GmailMessage = getCurrentMessage(event);

IntelliJ generates an import statement like this:

import GmailMessage = GoogleAppsScript.Gmail.GmailMessage;

This import statement becomes after transpiling and pushing:

var GmailMessage = GoogleAppsScript.Gmail.GmailMessage;

But this statement fails during script runtime. Problem is, without the import, I don’t have any autocomplete in my IDE and of course the IDE flags the source as invalid.

How to handle that situation? I simply can’t remove those lines manually in the Online Editor every time I have pushed. That would be a nightmare 😃

Expected Behavior

No runtime error.

Actual Behavior

ReferenceError: “GoogleAppsScript” is not defined. [line: 9, function: , file: src/GetContextualAddOn]

Steps to Reproduce the Problem

  1. use IDEA to code typed source code against Gmail AppsScript API
  2. push the results

Specifications

  • latest IntelliJ IDEA on Mac
  • Version (clasp -v): clasp 1.5.0
  • OS (Mac/Linux/Windows): Mac

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
grantcommented, Aug 1, 2018

Can you try installing the latest version of clasp 1.5.1, and see if the IntelliJ setup works?

1reaction
grantcommented, Jul 30, 2018

I will experiment with a solution that comments out the import line when pushing.

// import GmailMessage = GoogleAppsScript.Gmail.GmailMessage;
var greeter = function (person) {
    return "Hello, " + person + "!";
};
function testGreeter(event) {
  let message:GmailMessage = getCurrentMessage(event);
}

I created the 3rd party lib, so I can follow-up there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Valid imports marked as errors, but correct import suggested ...
Hi, I've been working on a scala project on IntelliJ for a while. Recently, it started showing me import errors.
Read more >
Auto import | IntelliJ IDEA Documentation - JetBrains
Basic procedures to create and optimize imports in IntelliJ IDEA. Learn more how to import the missing import or XML namespace.
Read more >
Intellij IDEA cannot resolve any import statement
Hi there, I am struggling recently with very strange issue. Suddenly, my intellij IDEA stopped resolving all java import statements. The only ...
Read more >
IDEA highlight import as red, even if compilation if fine and ...
As you can see IDEA highlights class ReconciliationSettings as error. Even if class is ok. It located in another maven module which is...
Read more >
SyntaxError: Cannot use import statement outside a module ...
You're trying to execute a React program in Node.js, but it is designed to run in a web browser. There is no DOM...
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