1

Is it possible to "import" or somehow "include" a content of a plain Javascript files copied from browser (so there are no no external keywords) to a Typescript source code file, so the function/global vars declarations on that files can be reachable?

To me known simplistic workaround is to copy the content of the js files to the top of the ts.file, but exist there any other more elegant way?

if not got reason for this question still - it is a try for a"kind of hacking" solution on SharePoint client side, to check typo with actually existing sharepoint build-in functions on global scope.

thanks in advance for any idea?

4
  • a more elegant way would be to write a proper TypeScript file, because the missing types are the only difference between JavaScript and TypeScript
    – smnbbrv
    Commented Sep 18, 2017 at 11:35
  • 1
    You're looking for the allowJs option.
    – user663031
    Commented Sep 18, 2017 at 11:36
  • exactly, that was I needed, thanks! (just a comment, in my case was also wrongly set the include option, after correcting it it is working)
    – rychlmoj
    Commented Sep 18, 2017 at 13:07
  • Unlikely there is another problem I noticed further in the real life. SPhave e.g. initt.js there s defined one function $_global_init() and it contains another functions which I would need to have in scope in my typescript file. (mightbe a no-important note: the $_global_init() is called at the end and probably brings some its functions to the global scope.). And there is another file with similar structure as init.js I would need to involve. I am using the latest version of vs code). Any idea?
    – rychlmoj
    Commented Sep 18, 2017 at 13:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.