#Force treat file as a global script

14 messages · Page 1 of 1 (latest)

median sparrow
#

Is there a way to force TS to treat file as a global script(meaning evry type/const/function) this file has is treated as global even if the file has import/export statements which usually make TS treat file as a module?

#

If I have a file

type Foo=string;
export {}

can I force TS to still expose type Foo as a global and not treat it as module?

junior mason
#
declare global {
    type Foo = string
}
median sparrow
junior mason
#

Hmm, not quite sure I get the full picture.

#

Wouldn't you want your user to write vanilla TS so they aren't confused about "why does it work in TS but not in your editor" or vice versa?

median sparrow
#

the intent is that the user has two editor panes(pane=file basically) - and these panes should share types between each other.

#

trying to think of a way to achieve that even if something is imported(an external lib)

#

it's all about ts types so don't really care about compiled runtime js, just the types

junior mason
#

What about just concating the two files?

median sparrow
#

yeah, was thinking in that direction too - didn't find a way to do that yet so thought perhaps there's some ts compiler option that would do that

junior mason
#

I would think you can just concat the content before feeding it to the TS compiler.

median sparrow
#

well, theoretically absolutely should be possible - I just didn't find a convenient api in monaco which would allow me to do that yet

#

!solved