简体   繁体   中英

How to use a global module

So I have

declare module "test" {
    declare export type running = number;
}

in a lib file, and I was wondering how to use the module and what it's really for.

If I try something like:

async function testMe (testing_stuff /* : test.running */) {
}

It doesn't know what test is.

But if I don't have it in a module I can just straight up use running eg

declare type running = number;

Then use it as:

async function testMe (testing_stuff /* : running */) {
}

So what is the use of module here?

You should be able to do

/*:: import type { running } from "test"; */

async function testMe (testing_stuff /* : running */) {
}

to import the type from the module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM