0

I have a typescript google data studio connector project in which all files are executed in one global scope one after another. Order of execution is defined in

"filePushOrder": [
    "src/declaration.ts",
    "src/usage.ts"
]

declaration.ts:

import CommunityConnector = GoogleAppsScript.Data_Studio.CommunityConnector; // it's only a type

const connector: CommunityConnector = DataStudioApp.createCommunityConnector();

usage.ts:

import GetAuthTypeResponse = GoogleAppsScript.Data_Studio.GetAuthTypeResponse;

function getAuthType(): GetAuthTypeResponse {
    return connector
        .newAuthTypeResponse()
        .setAuthType(connector.AuthType.OAUTH2)
        .build();
};

So if i run this in their google script environment it's going to run ok, but locally compiler displays error Cannot find name 'connector'.. Also their environment doesn't support modules, so import and export doesn't work. How do i make all the variables visible for all the files?

So what i need is just suppress all the import/export-related errors. Btw i'm using intellij idea and vscode-related solutions don't work for me. like this example: How to enable autocomplete for Google Apps Script in locally-installed IDE

I currently have this working solution:
declaration.ts:

// all the previous content
export { connector };

usage.ts:

// @ts-ignore
// noinspection ES6UnusedImports
import { connector } from './declaration';
// @ts-ignore
const { connector } = { connector };

// all the previous content

and example that doesn't work:

export const connector: CommunityConnector = DataStudioApp.createCommunityConnector();
import { connector } from './declaration';

0 Answers0