"SyntaxError: Unexpected token?" appears when displaying the "tsc" command.
P粉026665919
P粉026665919 2023-08-25 19:05:09
0
1
869

I am new to typescript, I tried converting a typescript file to a javascript file by running the command tsc filename.ts. But it shows error.

C:Program Files (x86)Nodistbinnode_modulestypescriptlibtsc.js:93 for (let i = startIndex ?? 0; i < array.length; i ) { ^ SyntaxError: Unexpected token? at Module._compile (internal/modules/cjs/loader.js:749:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader.js:612:12) at Function.Module._load (internal/modules/cjs/loader.js:604:3) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (C:Program Files (x86)Nodistbinnode_modulestypescriptbintsc:2:1) at Module._compile (internal/modules/cjs/loader.js:805:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)

I tried installing node to the latest version.

P粉026665919
P粉026665919

reply all (1)
P粉798343415

I encountered the same problem usingTypeScript5.1.6 and Node 12.x versions.

You get this problem because of this combination. I downgraded myTypeScriptto 4.9.5 and it works fine for me.

Please check the pictures below for reference:

https://www.typescriptlang.org /docs/handbook/release-notes/typescript-5-1.html

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!