Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/environments/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The solution, test fixture and optional setup/preloaded code are all combined in

## TypeScript

Typescript 2.4 is supported. Only the Mocha test framework is available for testing.
Typescript 2.4 is supported. The Mocha test framework and Karma+Mocha are available for testing.

The following typings are available:

Expand Down
6 changes: 5 additions & 1 deletion lib/runners/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ function prepareKarma(opts, interfaceType, runCode, fail) {
},
};

runKarma(opts, runCode, fail, interfaceType, config);
const nodeOpts = Object.assign({}, opts);
// run on the default node version
delete nodeOpts.languageVersion;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I was curious how long ago Node 2.4 was and apparently it doesn't even exist :D (it was io.js 2.4 released 2015-07-17).

If specifying the target for Karma is useful, we can do that too. I didn't touch Karma's configuration in #476 because it was explicitly set to ES5.
https://github.com/Codewars/codewars-runner-cli/blob/aeb1d5d7628000217dc79b8a3d0594f9668d4f5d/lib/runners/typescript.js#L142-L147

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I definitely thought about it. I couldn't imagine a good scenario for setting the Karma ES target. Nobody building websites today can safely target anything newer than ES5, and ES3 is too restrictive for most modern JS.

I'll leave it for something we can add in later if it become useful. As it is, we only support a single version of TS, and I'm not 100% sure how significantly the different target versions change the output in this case.


runKarma(nodeOpts, runCode, fail, interfaceType, config);
}

function _tsc(opts) {
Expand Down
6 changes: 6 additions & 0 deletions test/runners/typescript_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ describe('typescript runner', function() {
it('basic test', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: 'export var a = {b: 2};',
fixture: `\
/// <reference path="/runner/typings/mocha/index.d.ts" />
Expand All @@ -142,6 +143,7 @@ describe('typescript runner', function() {
it('handle successes', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: `\
import 'core-js';
import { Component } from "@angular/core";
Expand Down Expand Up @@ -222,6 +224,7 @@ describe('typescript runner', function() {
it('handles failure', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: `\
import 'core-js';
import { Component } from "@angular/core";
Expand Down Expand Up @@ -300,6 +303,7 @@ describe('typescript runner', function() {
it('basic test', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: 'export var a = {b: 2};',
fixture: `\
/// <reference path="/runner/typings/mocha/index.d.ts" />
Expand All @@ -322,6 +326,7 @@ describe('typescript runner', function() {
it('handle successes', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: `\
import 'core-js';
import { Component } from "@angular/core";
Expand Down Expand Up @@ -402,6 +407,7 @@ describe('typescript runner', function() {
it('handles failure', function(done) {
runner.run({
language: 'typescript',
languageVersion: '2.4',
code: `\
import 'core-js';
import { Component } from "@angular/core";
Expand Down