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

Conflict with Chai assert / changing a keyword #68

Open
miohtama opened this issue Mar 5, 2020 · 1 comment
Open

Conflict with Chai assert / changing a keyword #68

miohtama opened this issue Mar 5, 2020 · 1 comment

Comments

@miohtama
Copy link

miohtama commented Mar 5, 2020

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
Copy link
Author

miohtama commented Mar 5, 2020

The issue on truffle-typings is open here dethcrypto/truffle-typings#17

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

No branches or pull requests

1 participant