question

Wally96333-0597 avatar image
0 Votes"
Wally96333-0597 asked TimonYang-MSFT edited

Inserting numbers into strings in strict mode

Hi all,

I am trying to assign a file path to a variable in Typescript while in strict mode.
The path has numbers in it, particularly the date of creation prefixed.
The code is being executed in Node.JS.

This is the path:

 const path = 'C:\\Software Development\\2020_12_21_NET_NodeJS\\NET_NodeJS_01';

error - [Octal escape sequences are not allowed in strict mode.]

My thought at that point was to break the string into elements of an array, then join the elements into the finished string.

 const path_parts = [
         'C:\\Software Development\\',
      '2020_12_21_NET_NodeJS\\NET_NodeJS_01'
                    ];
    
 const path = path_parts.join ();

error - [Numeric separators are not allowed at the end of numeric literals]


Try again:

 const path_parts = [
         'C:\\Software Development',
      '\\2020',
      '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                    ];

error - [Octal escape sequences are not allowed in strict mode.]

Try again:

 const path_parts = [
         'C:\\Software Development\\',
      '2020',
      '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                    ];

error - [Unexpected number]

Try again:

 const path_parts = [
         'C:\\Software Development\\',
      '2020',
      '_', '12', '_21_NET_NodeJS\\NET_NodeJS_01'
                    ];

error - [Unexpected number]


Remove the first element in the array, then try again:

 const path_parts = [
      '2020',
      '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                    ];

no error



Any help would be appreciated!










not-supported
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Wally96333-0597
Unfortunately, Microsoft Q&A currently does not provide support for typescript. You can follow Paul’s suggestions to StackOverflow and ask your questions. If you find a bug or have constructive suggestions for it, you can go to its GitHub repository.
The list of products currently supported by Microsoft Q&A is as follows: Microsoft Q&A supported products

0 Votes 0 ·
Paul-5034 avatar image
0 Votes"
Paul-5034 answered Paul-5034 edited

This tag is for .NET/C# questions - you're probably better off asking this somewhere like SO:
https://stackoverflow.com/questions/tagged/typescript
or
https://stackoverflow.com/questions/tagged/node.js

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Wally96333-0597 avatar image
0 Votes"
Wally96333-0597 answered

I know,

I'm surprised that there is no tag for Typescript, or for any kind of scripts.

CSharp is the closest thing I could come up with.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.