-
Notifications
You must be signed in to change notification settings - Fork 176
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
Updated radium to 0.17, Update chai-enzyme #270
base: master
Are you sure you want to change the base?
Conversation
Thanks. Also, maybe you can consider adding |
Yeah, var make sense, didn't try but actually |
Yes, you can import the interface import Radium from 'radium';
Radium.TestMode.disable(); |
@unional |
LGTM. |
@unional Sorry to bring another stuff into PR, but i updated chai-enzyme too |
No problem. Sorry that will have to wait for Blake to merge PR. I'm not ready to merge other people's PR yet. :) As for the typings. you can consider using One more thing is I've updated the generator and it includes more features. You may like it (I hope) :) |
@asvetliakov Can you augment the non-namespaced versions? It should work (let me know if it does not), but the tilde will break once you use it as a dependency: https://github.com/asvetliakov/typings-chai-enzyme/blob/master/index.d.ts#L2. |
@blakeembrey I can't augment non tilde version, because current chai typings contains this:
Module doesn't introduce local names and couldn't be augmented. Same for 'chai'. |
@asvetliakov When you bundle or it's installed, it should be re-writing the augmentation for you. I'll have to dive into it more at another time though. Definitely don't want to be augmenting the |
@blakeembrey Will not work, because if i do this: import {Assertion} from "chai/lib/Assertion"
declare module "chai/lib/Assertion" {
// augmentation
} it will produce this: // Generated by typings
// Source: index.d.ts
declare module '~chai-enzyme/index' {
import {EnzymeSelector, ShallowWrapper, ReactWrapper, CheerioWrapper} from '~chai-enzyme~enzyme';
import {Assertion} from '~chai-enzyme~chai/lib/Assertion';
// Augment chai assertions
module '~chai-enzyme~chai/lib/Assertion' { and when trying to use it: import * as React from "react";
import * as chai from "chai";
import {expect} from "chai";
import * as chaiEnzyme from "chai-enzyme";
import {shallow} from "enzyme";
chai.use(chaiEnzyme());
class MyComponent extends React.Component<any, any> {
render() {
return (
<div id="root">
<h1>Test</h1>
<span id="child">Child</span>
</div>
);
}
}
let wrapper = shallow(<MyComponent />);
expect(wrapper).to.contain(<h1>Test</h1>); // error
expect(wrapper.find('span')).to.have.id('child'); // error
expect(wrapper).to.have.descendants('#child'); // error
expect(wrapper).to.have.id("root"); //error because augmented module name is different than original chai's module What is the reason to putting dependencies including into resulting type def? Versioning? |
Did try to augment just 'chai', same result - the augmented name is being rewritten and thus isn't being augmented correctly.
|
Gotcha, I see now. If you switch to using |
Btw if the chai typings has anything missing, let me know |
Oh, ok, |
@unional You need to export internal interfaces, i want to augment just |
https://github.com/typings/typings/blob/master/docs/faq.md#writing-typings-definitions links to the TypeScript definition in |
Ok, with peerDependencies the chai isn't being included, but
This produces error because chai/lib/Assertion doesn't introduce local names:
I think this is because interface Assertion(and other interfaces, such as Match) isn't being exported from 'chai', instead it exports: |
Yeah, I need to expose the interfaces, for sure. We are debating what is the recommended approach on that. See typings/typings#354. What do you think? |
@asvetliakov Interesting. I can make a patch to correctly rewrite the |
Maybe of interest @RyanCavanaugh, Typings has been using the proposed |
@blakeembrey
use
This way the module augmentation will work, i doubt that TS team will change something since this likely ES6 spec behavior (re-export doesn't introduce local names). |
@asvetliakov I'll take a look, have you confirmed that fixes your issue though? |
Yes, this works:
|
Sweet, thanks. Just confirmed myself. Looks like I'll update to just use declare module '~x' {
export interface Foo {
x: string;
}
}
declare module 'x' {
// export * from '~x';
import main = require('~x')
export = main
}
declare module 'augment' {
module 'x' {
interface Foo {
y: number
}
}
} |
De nada. Looking forward for update 👍 |
@asvetliakov Ready to update when you are. 1.0 has been released with the changes discussed - |
Thanks! Looks like this even won't be needed for 2.0 |
@asvetliakov Unless I'm missing something, that doesn't fix the augmenting of a module right? |
If i'm correct with dev version we'll be able to augment just "chai" top level module even if it uses es6 reexport. need to test |
Oh, that's not what I thought that PR was. I believe(d) it was to allow new names in Edit: That's what I thought, but looking at the tests seems like you could be right. Seems interesting. |
The PR for global augmentation is microsoft/TypeScript#8104 |
In this case, I can't tell if I should revert the |
Thanks. Yeah, I haven't been following TypeScript for a bit 😄 Got a bit too much to follow. |
We're removing the restriction that module augmentations can't introduce new top-level names, which I think is what the I'm working on a comprehensive set of docs that should address this and (hopefully) all other scenarios. |
@RyanCavanaugh The |
Typings URL: [https://github.com/asvetliakov/typings-radium]
Source URL: [https://github.com/FormidableLabs/radium]
Typings URL: [https://github.com/asvetliakov/typings-chai-enzyme]
Source URL: [https://github.com/producthunt/chai-enzyme]