Conflict with Chai assert / changing a keyword
miohtama opened this issue · 1 comments
miohtama commented
This is not strictly espower-typescript
specific issue, but maybe you can help.
I am using truffle-typing package to bring some TypeScript definitions into my tests. However, these definitions already declare assert
from Chai.
If I try to add import assert = require('assert');
in my test.ts, TypeScript compiler will balk.
TSError: ⨯ Unable to compile TypeScript:
test/Token.spec.ts:4:7 - error TS2451: Cannot redeclare block-scoped variable 'assert'.
4 const assert = require("assert"); // Power assert https://github.com/power-assert-js/espower-typescript
~~~~~~
node_modules/truffle-typings/index.d.ts:10:15
10 declare const assert: Chai.AssertStatic;
~~~~~~
'assert' was also declared here.
I was thinking a workaround of using some different symbol for assert
from power-assert, e.g.
asrt = require("assert"); // Power assert aliased
...but I am not sure if this is going to work due to transpiling.
Can I change the keyword power-assert is using in TypeScript somehow?
Namely, the following does not give me power-assert output:
// test/test.ts
import asrt = require('assert'); // If I rename assert -> asrt power-assert is no longer triggered
describe('Array#join', () => {
it('joins all elements into a string with separator', () => {
asrt(['a', 'b', 'c'].join(':') === 'a:b:c:');
});
});
miohtama commented
The issue on truffle-typings is open here dethcrypto/truffle-typings#17