Skip to content

Bug/#71 fix undefined import modules#80

Open
BSteffaniak wants to merge 7 commits into
grant:masterfrom
BSteffaniak:bug/#71-fix-undefined-import-modules
Open

Bug/#71 fix undefined import modules#80
BSteffaniak wants to merge 7 commits into
grant:masterfrom
BSteffaniak:bug/#71-fix-undefined-import-modules

Conversation

@BSteffaniak

@BSteffaniak BSteffaniak commented Sep 7, 2023

Copy link
Copy Markdown

Hi again, this is my naive attempt at fixing #71.

This PR is based on top of #79, so a lot of the file changes may appear duplicated from there.

I'm not sure if my implementation in index.ts#createMockModuleImportStatement is the idiomatic way to achieve this functionality, but it seems to be working for the previous test cases and the few new test cases I have added:
image

Here is an example typescript input:

import { func } from 'bob';
func();

and with this PR, the produced output looks like this:

// Compiled using ts2gas 4.2.0 (TypeScript 4.9.5)
var exports = exports || {};
var module = module || { exports: exports };
var bob_1 = bob_1 || { func: func }; //import { func } from 'bob';
(0, bob_1.func)();

I'm also not sure what determines the suffix on the module names (e.g. the _1 part of bob_1), so it's just hardcoded to that currently.

Again, I'm not super familiar with the typescript compiler structure, so let me know if this is completely incorrect.

Thanks!

@BSteffaniak BSteffaniak force-pushed the bug/#71-fix-undefined-import-modules branch from 8ffee7f to ca8fa6d Compare September 7, 2023 01:02
@BSteffaniak BSteffaniak force-pushed the bug/#71-fix-undefined-import-modules branch from ca8fa6d to 0feaff2 Compare September 7, 2023 13:29
mikedownesdev added a commit to mikedownesdev/gas-svelte-app that referenced this pull request Sep 27, 2023
Importing a function from another file the way I've been trying to
does not work. I've followed up on a GitHub issue / PR on this topic:

issue: grant/ts2gas#71
PR: grant/ts2gas#80

Going to try this `namespace` workaround next:
https://github.com/google/clasp/blob/master/docs/typescript.md#the-exports-declaration-workaround

Which names this useful respository for inspiration:
https://github.com/PopGoesTheWza/ts-gas-project-starter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant