Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript not compiling #98

Closed
axefrog opened this issue Mar 27, 2017 · 5 comments
Closed

TypeScript not compiling #98

axefrog opened this issue Mar 27, 2017 · 5 comments

Comments

@axefrog
Copy link

axefrog commented Mar 27, 2017

[Running] ts-node "d:\dropbox\work\dev\yreuq.js\temp-zadfghcabp.typescript"
d:\dropbox\work\dev\yreuq.js\temp-zadfghcabp.typescript:1
(function (exports, require, module, __filename, __dirname) { function isPathEqual(a: number[], b: number[]): boolean {
                                                                                    ^
SyntaxError: Unexpected token :
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Function.Module.runMain (module.js:605:10)
    at Object.<anonymous> (C:\Users\axefr\AppData\Roaming\npm\node_modules\ts-node\src\_bin.ts:177:12)
    at Module._compile (module.js:571:32)

[Done] exited with code=1 in 1.977 seconds
@formulahendry
Copy link
Owner

temp-zadfghcabp.typescript: Do you intend to select a piece of code snippet to run?

@axefrog
Copy link
Author

axefrog commented Mar 28, 2017

I just made an untitled file (unsaved in a tab), set the language to typescript, pasted some code in, then pressed CTRL+SHIFT+N to run it. Do I need to select it as well?

@formulahendry
Copy link
Owner

Got it. So did you try to run the same code (with ts-node) in the terminal?

philmueller added a commit to philmueller/vscode-code-runner that referenced this issue Aug 23, 2017
This is needed for ts-node to interpret typescript files correctly.
@philmueller
Copy link
Contributor

@axefrog: The reason is that the automatically generated temporary file for your unsaved code (tempCodeRunnerFile.typescript) doesn't end with ".ts", so ts-node seems to interpret it as JavaScript instead of TypeScript. As a workaround, you can save the file with ".ts" ending or add the following to your user settings:

"code-runner.languageIdToFileExtensionMap": {
  "typescript": ".ts"
}

@formulahendry: I've created a corresponding pull request to apply the correct file ending to the default configuration (#166).

@formulahendry
Copy link
Owner

That's cool. Thanks @philmueller !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants