Home

Issue: 1475

[Typescript] Unable to find imported async method from a different file.

[issue link]

In my component I have an import of my class, Api, and i am attempting to reference its method.

import {Components} from "../components/components";
import {Api} from "../components/api";

export default {
    async asyncData ({ params }) {
        return {
            test : [1,2,3,4],
            name : "Hello"
        }
    },
    components : {
        SiteHeader : Components.SiteHeader,
        SiteFooter : Components.SiteFooter,
    },
    created : function () {
        Api.get("at api");
    },
    methods : {
        addV : function () {
            this.test.push(5);
        }
    }
}

This throws the following error…

39:8-11 "export 'Api' was not found in '../components/api'

export class Api {

    public static readonly get = async (name : string) => {

    };

}

but if I remove the async…

export class Api {

    public static readonly get = (name : string) => {

    };

}

then it works fine.

I would assume it has something to do with the way typescript compiles it down.

This question is available on Nuxt.js community (#c1315)