Powershell Join-Path showing 2 dirs in result instead of 1 - accidental script/function outputWhy does a getter/setter property return duplicated value?Why is Select-String returning a DirectoryInfo object in addition to MatchInfo objects?Why does Range.BorderAround emit “True” to the console?UTF8 Script in PowerShell outputs incorrect charactersCreating a folder if it does not exists - “Item already exists”Creating subfolders with PowerShell in multiple parent foldersSplit-Path + Join-Path functionalityHow do I write a PowerShell script to test and copy file paths?Copy-Item and Join-Path creates a folder instead of a filePowerShell 5 Copy-Item not workingPowershell Copy-Item -DestinationUser input - folder and subfolder creation

Videos of surgery

What are the IPSE’s, the ASPE’s, the FRIPSE’s and the GRIPSE’s?

Why did James Cameron decide to give Alita big eyes?

Is it unusual for a math department not to have a mail/web server?

Many many thanks

Dual of a bimodule

Will removing shelving screws from studs damage the studs?

Could the UK amend the European Withdrawal Act and revoke the Article 50 invocation?

"Petrol aggregate"?

Can I use coax outlets for cable modem?

Why didn't Doc believe Marty was from the future?

Are strlen optimizations really needed in glibc?

Pen test results for web application include a file from a forbidden directory that is not even used or referenced

Commercial company wants me to list all prior "inventions", give up everything not listed

Time difference between banns and marriage

Is the Amazon rainforest the "world's lungs"?

How could a self contained organic body propel itself in space

How to determine algebraically whether an equation has an infinite solutions or not?

Does trying to charm an uncharmable creature cost a spell slot?

What's the point of fighting monsters in Zelda BoTW?

Why is there not a willingness from the world to step in between Pakistan and India?

Using a JoeBlow Sport pump on a presta valve

Toroidal Heyacrazy: Rainstorm

Why was this commercial plane highly delayed mid-flight?



Powershell Join-Path showing 2 dirs in result instead of 1 - accidental script/function output


Why does a getter/setter property return duplicated value?Why is Select-String returning a DirectoryInfo object in addition to MatchInfo objects?Why does Range.BorderAround emit “True” to the console?UTF8 Script in PowerShell outputs incorrect charactersCreating a folder if it does not exists - “Item already exists”Creating subfolders with PowerShell in multiple parent foldersSplit-Path + Join-Path functionalityHow do I write a PowerShell script to test and copy file paths?Copy-Item and Join-Path creates a folder instead of a filePowerShell 5 Copy-Item not workingPowershell Copy-Item -DestinationUser input - folder and subfolder creation






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am constructing incremental directory structures, and for some reason Join-Path is showing 2 dirs. When I later join that with a file I'm sending to copy-item, it causes an error, as shown below. I have shown in the comment for the $to_loc_finalDT1 line, where I first see these two dirs:



Copy-Item : Cannot find path '\T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv \T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv' because it does not exist


So this is the pertinent powershell script:



$T2 = "\T2DisasterBackupLoc" 
$toLocParentDT2 = CreateDatedFolder $parentDirBaseNameDT2
$to_loc_finalDT2 = Join-Path -Path $toLocParentDT2 -ChildPath "Privileges"
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT2 ))

write-output " Creating folder $to_loc_finalDT2 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT2 -force



#second dir save files to
$parentDirBaseNameDT1 = "\T1DisasterBackupLoc"
$toLocParentDT1 = CreateDatedFolder $parentDirBaseNameDT1
$to_loc_finalDT1 = Join-Path -Path $toLocParentDT1 -ChildPath "Privileges" #shows 2 dirs here in debugger: \T2DisasterBackupLoc_2019-03-08Privileges \T2DisasterBackupLoc_2019-03-08Privileges
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT1 ))

write-output " Creating folder $to_loc_finalDT1 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT1 -force



I'm not sure how to get Join_path to just have the one dir, as it should. Right now, I think it's being treated as an array, which is not correct.



I tried searching for related issues, but didn't see anything similar.



Update



Here's the code for CreateDatedFolder:



#create dated folder to put backup files in 
function CreateDatedFolder([string]$name)
$datedDir = ""
$datedDir = "$name" + "_" + "$((Get-Date).ToString('yyyy-MM-dd'))"
New-Item -ItemType Directory -Path $datedDir -force
return $datedDir



The output for that looks fine when it's returned. It appends the date onto the T2DisasterBackupLoc, but the debugger only shows one dir there, not an array or 2 dirs that are separate strings.










share|improve this question





















  • 2





    Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

    – T-Me
    Mar 8 at 15:22











  • @T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

    – Michele
    Mar 8 at 15:29

















1















I am constructing incremental directory structures, and for some reason Join-Path is showing 2 dirs. When I later join that with a file I'm sending to copy-item, it causes an error, as shown below. I have shown in the comment for the $to_loc_finalDT1 line, where I first see these two dirs:



Copy-Item : Cannot find path '\T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv \T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv' because it does not exist


So this is the pertinent powershell script:



$T2 = "\T2DisasterBackupLoc" 
$toLocParentDT2 = CreateDatedFolder $parentDirBaseNameDT2
$to_loc_finalDT2 = Join-Path -Path $toLocParentDT2 -ChildPath "Privileges"
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT2 ))

write-output " Creating folder $to_loc_finalDT2 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT2 -force



#second dir save files to
$parentDirBaseNameDT1 = "\T1DisasterBackupLoc"
$toLocParentDT1 = CreateDatedFolder $parentDirBaseNameDT1
$to_loc_finalDT1 = Join-Path -Path $toLocParentDT1 -ChildPath "Privileges" #shows 2 dirs here in debugger: \T2DisasterBackupLoc_2019-03-08Privileges \T2DisasterBackupLoc_2019-03-08Privileges
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT1 ))

write-output " Creating folder $to_loc_finalDT1 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT1 -force



I'm not sure how to get Join_path to just have the one dir, as it should. Right now, I think it's being treated as an array, which is not correct.



I tried searching for related issues, but didn't see anything similar.



Update



Here's the code for CreateDatedFolder:



#create dated folder to put backup files in 
function CreateDatedFolder([string]$name)
$datedDir = ""
$datedDir = "$name" + "_" + "$((Get-Date).ToString('yyyy-MM-dd'))"
New-Item -ItemType Directory -Path $datedDir -force
return $datedDir



The output for that looks fine when it's returned. It appends the date onto the T2DisasterBackupLoc, but the debugger only shows one dir there, not an array or 2 dirs that are separate strings.










share|improve this question





















  • 2





    Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

    – T-Me
    Mar 8 at 15:22











  • @T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

    – Michele
    Mar 8 at 15:29













1












1








1


1






I am constructing incremental directory structures, and for some reason Join-Path is showing 2 dirs. When I later join that with a file I'm sending to copy-item, it causes an error, as shown below. I have shown in the comment for the $to_loc_finalDT1 line, where I first see these two dirs:



Copy-Item : Cannot find path '\T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv \T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv' because it does not exist


So this is the pertinent powershell script:



$T2 = "\T2DisasterBackupLoc" 
$toLocParentDT2 = CreateDatedFolder $parentDirBaseNameDT2
$to_loc_finalDT2 = Join-Path -Path $toLocParentDT2 -ChildPath "Privileges"
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT2 ))

write-output " Creating folder $to_loc_finalDT2 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT2 -force



#second dir save files to
$parentDirBaseNameDT1 = "\T1DisasterBackupLoc"
$toLocParentDT1 = CreateDatedFolder $parentDirBaseNameDT1
$to_loc_finalDT1 = Join-Path -Path $toLocParentDT1 -ChildPath "Privileges" #shows 2 dirs here in debugger: \T2DisasterBackupLoc_2019-03-08Privileges \T2DisasterBackupLoc_2019-03-08Privileges
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT1 ))

write-output " Creating folder $to_loc_finalDT1 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT1 -force



I'm not sure how to get Join_path to just have the one dir, as it should. Right now, I think it's being treated as an array, which is not correct.



I tried searching for related issues, but didn't see anything similar.



Update



Here's the code for CreateDatedFolder:



#create dated folder to put backup files in 
function CreateDatedFolder([string]$name)
$datedDir = ""
$datedDir = "$name" + "_" + "$((Get-Date).ToString('yyyy-MM-dd'))"
New-Item -ItemType Directory -Path $datedDir -force
return $datedDir



The output for that looks fine when it's returned. It appends the date onto the T2DisasterBackupLoc, but the debugger only shows one dir there, not an array or 2 dirs that are separate strings.










share|improve this question
















I am constructing incremental directory structures, and for some reason Join-Path is showing 2 dirs. When I later join that with a file I'm sending to copy-item, it causes an error, as shown below. I have shown in the comment for the $to_loc_finalDT1 line, where I first see these two dirs:



Copy-Item : Cannot find path '\T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv \T2DisasterBackupLoc_2019-03-08PrivilegesPrivileges_HH_Bak.csv' because it does not exist


So this is the pertinent powershell script:



$T2 = "\T2DisasterBackupLoc" 
$toLocParentDT2 = CreateDatedFolder $parentDirBaseNameDT2
$to_loc_finalDT2 = Join-Path -Path $toLocParentDT2 -ChildPath "Privileges"
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT2 ))

write-output " Creating folder $to_loc_finalDT2 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT2 -force



#second dir save files to
$parentDirBaseNameDT1 = "\T1DisasterBackupLoc"
$toLocParentDT1 = CreateDatedFolder $parentDirBaseNameDT1
$to_loc_finalDT1 = Join-Path -Path $toLocParentDT1 -ChildPath "Privileges" #shows 2 dirs here in debugger: \T2DisasterBackupLoc_2019-03-08Privileges \T2DisasterBackupLoc_2019-03-08Privileges
#create sub-folder location
if(-Not (Test-Path $to_loc_finalDT1 ))

write-output " Creating folder $to_loc_finalDT1 because it does not exist "
New-Item -ItemType directory -Path $to_loc_finalDT1 -force



I'm not sure how to get Join_path to just have the one dir, as it should. Right now, I think it's being treated as an array, which is not correct.



I tried searching for related issues, but didn't see anything similar.



Update



Here's the code for CreateDatedFolder:



#create dated folder to put backup files in 
function CreateDatedFolder([string]$name)
$datedDir = ""
$datedDir = "$name" + "_" + "$((Get-Date).ToString('yyyy-MM-dd'))"
New-Item -ItemType Directory -Path $datedDir -force
return $datedDir



The output for that looks fine when it's returned. It appends the date onto the T2DisasterBackupLoc, but the debugger only shows one dir there, not an array or 2 dirs that are separate strings.







powershell return output return-value multiple-return-values






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 20:21









mklement0

154k26 gold badges275 silver badges319 bronze badges




154k26 gold badges275 silver badges319 bronze badges










asked Mar 8 at 15:03









MicheleMichele

1,5168 gold badges29 silver badges48 bronze badges




1,5168 gold badges29 silver badges48 bronze badges










  • 2





    Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

    – T-Me
    Mar 8 at 15:22











  • @T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

    – Michele
    Mar 8 at 15:29












  • 2





    Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

    – T-Me
    Mar 8 at 15:22











  • @T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

    – Michele
    Mar 8 at 15:29







2




2





Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

– T-Me
Mar 8 at 15:22





Is CreateDatedFolder a function? What does it do? To me it looks like CreateDatedFolder creates two outputs that are stored in $toLocParentDT1 and Join-Path processes them both.

– T-Me
Mar 8 at 15:22













@T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

– Michele
Mar 8 at 15:29





@T-Me - I added CreateDatedFolder to the Update of my question. It appends the date to the folder given. The output shows just one folder correctly, not the two.

– Michele
Mar 8 at 15:29












1 Answer
1






active

oldest

votes


















2















As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path.



Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call.



New-Item outputs a [System.IO.DirectoryInfo] instance representing the newly created directory and, due to PowerShell's implicit output behavior, that instance becomes part of what the function outputs too - any command or expression inside a script / function that returns a value that isn't captured or redirected becomes part of the output.



To prevent that, suppress the output:



$null = New-Item -ItemType Directory -Path $datedDir -force


Note that you never need return in PowerShell in order to output a result - but you may need it for flow control, to exit a function prematurely:



return $datedDir 


is syntactic sugar for:



$datedDir # Implicitly output the value of $datedDir.
# While you could also use `Write-Output $datedDir`,
# that is rarely needed and actually slows things down.
return # return from the function - flow control only


For more information about PowerShell's implicit output behavior, see this answer.






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065907%2fpowershell-join-path-showing-2-dirs-in-result-instead-of-1-accidental-script-f%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2















    As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path.



    Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call.



    New-Item outputs a [System.IO.DirectoryInfo] instance representing the newly created directory and, due to PowerShell's implicit output behavior, that instance becomes part of what the function outputs too - any command or expression inside a script / function that returns a value that isn't captured or redirected becomes part of the output.



    To prevent that, suppress the output:



    $null = New-Item -ItemType Directory -Path $datedDir -force


    Note that you never need return in PowerShell in order to output a result - but you may need it for flow control, to exit a function prematurely:



    return $datedDir 


    is syntactic sugar for:



    $datedDir # Implicitly output the value of $datedDir.
    # While you could also use `Write-Output $datedDir`,
    # that is rarely needed and actually slows things down.
    return # return from the function - flow control only


    For more information about PowerShell's implicit output behavior, see this answer.






    share|improve this answer































      2















      As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path.



      Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call.



      New-Item outputs a [System.IO.DirectoryInfo] instance representing the newly created directory and, due to PowerShell's implicit output behavior, that instance becomes part of what the function outputs too - any command or expression inside a script / function that returns a value that isn't captured or redirected becomes part of the output.



      To prevent that, suppress the output:



      $null = New-Item -ItemType Directory -Path $datedDir -force


      Note that you never need return in PowerShell in order to output a result - but you may need it for flow control, to exit a function prematurely:



      return $datedDir 


      is syntactic sugar for:



      $datedDir # Implicitly output the value of $datedDir.
      # While you could also use `Write-Output $datedDir`,
      # that is rarely needed and actually slows things down.
      return # return from the function - flow control only


      For more information about PowerShell's implicit output behavior, see this answer.






      share|improve this answer





























        2














        2










        2









        As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path.



        Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call.



        New-Item outputs a [System.IO.DirectoryInfo] instance representing the newly created directory and, due to PowerShell's implicit output behavior, that instance becomes part of what the function outputs too - any command or expression inside a script / function that returns a value that isn't captured or redirected becomes part of the output.



        To prevent that, suppress the output:



        $null = New-Item -ItemType Directory -Path $datedDir -force


        Note that you never need return in PowerShell in order to output a result - but you may need it for flow control, to exit a function prematurely:



        return $datedDir 


        is syntactic sugar for:



        $datedDir # Implicitly output the value of $datedDir.
        # While you could also use `Write-Output $datedDir`,
        # that is rarely needed and actually slows things down.
        return # return from the function - flow control only


        For more information about PowerShell's implicit output behavior, see this answer.






        share|improve this answer















        As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path.



        Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call.



        New-Item outputs a [System.IO.DirectoryInfo] instance representing the newly created directory and, due to PowerShell's implicit output behavior, that instance becomes part of what the function outputs too - any command or expression inside a script / function that returns a value that isn't captured or redirected becomes part of the output.



        To prevent that, suppress the output:



        $null = New-Item -ItemType Directory -Path $datedDir -force


        Note that you never need return in PowerShell in order to output a result - but you may need it for flow control, to exit a function prematurely:



        return $datedDir 


        is syntactic sugar for:



        $datedDir # Implicitly output the value of $datedDir.
        # While you could also use `Write-Output $datedDir`,
        # that is rarely needed and actually slows things down.
        return # return from the function - flow control only


        For more information about PowerShell's implicit output behavior, see this answer.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 22 at 12:43

























        answered Mar 8 at 15:33









        mklement0mklement0

        154k26 gold badges275 silver badges319 bronze badges




        154k26 gold badges275 silver badges319 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065907%2fpowershell-join-path-showing-2-dirs-in-result-instead-of-1-accidental-script-f%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript