Skip to content

test(filter): enable type inference to marble diagram #2202

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

Merged
merged 3 commits into from
Feb 5, 2017

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Dec 20, 2016

⚠️ Targeting master ⚠️

  • Non-breaking change

Description:

This PR resolves long-pending issue #1633, provides type inference to marble-diagram based test cases while does not hurt documentation for specs. It is using TypeScript compiler's feature to import type signature without real module import and assign it to existing ambient declaration - ambient declaration will provide same type inference to exported modules.

Why Targeting master?

Originally test case were designed to be used as validating type definition as well for most common use cases to prevent issue like #2163 . Due to current setup ergonomics, all of tests are running without any compiler validation so there wasn't any regression testing for type definitions which would be considered as breaking change if occurs.

This PR will enable all test cases to have correct compiler type inference, allows all test cases become first-guard to type definition validation. Once this PR is accepted, I'll work on other test cases to have same changes.

Related issue (if exists):
#1633

@kwonoj kwonoj added the TS Issues and PRs related purely to TypeScript issues label Dec 20, 2016
@kwonoj
Copy link
Member Author

kwonoj commented Dec 20, 2016

I have assigned @david-driscoll , @staltz as reviewer for code / document side changes just in case.

@kwonoj
Copy link
Member Author

kwonoj commented Dec 20, 2016

This is generated doc with PR, which preserves transpiled spec

image

with type inference supported.

image

@coveralls
Copy link

coveralls commented Dec 20, 2016

Coverage Status

Coverage remained the same at 97.674% when pulling d86e918 on kwonoj:fix-test-type-inference into dc06e01 on ReactiveX:master.

@@ -1,6 +1,12 @@
import {expect} from 'chai';
import * as Rx from '../../dist/cjs/Rx';
declare const {hot, cold, asDiagram, expectObservable, expectSubscriptions};
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about import * as marbleTestingSignature from '../helpers/marble-testing';?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it but tempted to leave as-is to give clarity this import is unique kind and not being used in general.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That intent may be better expressed as a comment, not as the usage of require.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you not just destructure it with the import?

import {hot, cold, asDiagram, expectObservable, expectSubscriptions} from '../helpers/marble-testing';

Copy link
Member Author

@kwonoj kwonoj Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's #1633. If use imported module, TS will transpile it and doc will be affected, reason only use it as type to be removed while transpiling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment here is super important. I can easily see myself wondering why this was done and changing it later.

@kwonoj kwonoj force-pushed the fix-test-type-inference branch 7 times, most recently from ff68a2d to f802e79 Compare February 4, 2017 22:48
@kwonoj kwonoj force-pushed the fix-test-type-inference branch from f802e79 to 716377d Compare February 4, 2017 22:50
@kwonoj
Copy link
Member Author

kwonoj commented Feb 4, 2017

@jayphelps @Blesh updated PR with changes to watch PR to validate certain behaviors like large PR, missing type definition import. It'll looks like #2327 (comment)

image

make status checker fail if those validation does not passes.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.689% when pulling e338ca6 on kwonoj:fix-test-type-inference into 3ec315d on ReactiveX:master.

@jayphelps jayphelps merged commit 2889519 into ReactiveX:master Feb 5, 2017
@kwonoj kwonoj deleted the fix-test-type-inference branch February 5, 2017 02:46
@ladyleet
Copy link
Member

ladyleet commented Feb 5, 2017

🔥

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
TS Issues and PRs related purely to TypeScript issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants