Last active
February 16, 2016 17:51
-
-
Save teppeis/ea05cc3177d0b8fd42c7 to your computer and use it in GitHub Desktop.
TypeScript + power-assert + ES6 Modules issue http://qiita.com/wadahiro/items/5d8a81252f2105112339
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generated .js | |
var power_assert_1 = require('power-assert'); | |
var _1 = require('../'); | |
describe('foo', function () { | |
it('test #1', function () { | |
power_assert_1.default.ok(_1.default() === 2); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original .ts | |
import assert from 'power-assert'; | |
import sut from '../'; | |
describe('foo', () => { | |
it('test #1', () => { | |
assert.ok(sut() === 2); | |
}); | |
}); |
一度変数に戻せばいけるけど、このtipsに気づいてもらうのは難しそう。
import powerAssert from 'power-assert';
import sut from '../';
const assert = powerAssert;
describe('foo', () => {
it('test #1', () => {
assert.ok(sut() === 2);
});
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScriptでES6 Modules形式でimport文を書くと
.default
が付与されるけど、empowerのデフォルトのpatterns
だとこれを検出できないのでempowerが失敗する。power_assert_1.default.ok(_1.default() === 2);
power_assert_1.default(_1.default() === 2);
このassert式に対するpatternsオプションの指定の仕方はある?
従来のES6形式でimport文を書けば問題ないが、DTの型定義がES6形式になってしまったため、ES6形式を使うには型定義を手動で書き換える必要がある...