-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added exports for chai extensions #3
Conversation
@@ -10,4 +10,6 @@ import {Chai} from './lib/Chai'; | |||
|
|||
declare var chai: Chai; | |||
|
|||
export = chai; | |||
export default chai; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change can't be accepted, it's not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be merged it you don't use this and remove the Chai
interface instead actually. cc @unional, does that sound right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. The other things is about the tslint. The format might be a bit off.
@olivr70 The changes can not be accepted because you're changing to export incorrectly. @unional The changes make sense, it would be good to have some proper refactoring to not export an interface as the main and instead have multiple exports. Currently nothing can be augmented for re-used because of the type definition structure. |
export declare var config:Config; | ||
export declare var util:Utils; | ||
export function should(): Should; | ||
export function use(fn: ((chai: any, utils: Utils) => void) | ((chai: any) => void) ): Chai; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use (fn: ChaiExtension): Chai
? I'd also move this to the main export to be able to kill the Chai
name. It'll then look like import * as Chai from './lib/Chai'
.
Thank you for your comments. As you have guessed, I am rather new to this ecosystem. The olivr70/typings-chai-as-promised project references my version of npm-chai, compiles and runs multiple mocha tests (in the test folder : just clone and run npm test). I don't understand why "export default chai;" is not correct (it is compiled by the Typescript compiler) My problem for chai-as-promised are :
|
Definitely should have multiple exports. When I port them I focus on cleaning up and expose the core shape. |
That is because the source package ( |
Unfortunately I think currently TypeScript 1.8 has a bug on the module augmentation, so it might not work. |
@blakeembrey about the And the Typescript spec (section 11.3.4.2 does not mention any limit to using default. Am I missing something ? |
@olivr70 , it's a whole can of worms. Don't go there: microsoft/TypeScript#7398 |
If you write a definition that does not match the source code, you can never expect runtime to actually work. By writing it incorrectly, people won't be able to actually use the definition. At least, they will, but not until they actually try to run their code. |
For example, if you say the source code is |
Here's a simple example: http://www.typescriptlang.org/Playground#src=export%20default%20function%20()%20%7B%7D%3B. Notice |
@olivr70 are you working on another PR? I can re-work it to expose the interfaces. |
Changes required for the chai-as-promised type definition