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

Add TypeScript .d.ts file for type checking #72

Merged
merged 1 commit into from
May 8, 2016
Merged

Conversation

blakeembrey
Copy link
Member

No description provided.

@dougwilson
Copy link

This is super awesome! What I wound wonder, especially if we start adding this to other modules, is I under if there is a way to use TypeScript to valid the bindings file against the JavaScript file? Is that even possible through some kind of command line?

@blakeembrey
Copy link
Member Author

@dougwilson I spent some time thinking about it from last year, and yes, there is. I was considering making a more complex toolchain, but an easy way is to just use the (TypeScript) compiler. We can either compile a .ts file and run the emitted JavaScript (E.g. type check, then a runtime check) or we could do it all in one step using something like ts-node. I can append it to this PR, which would you like to see or try?

Edit: Using ts-node is probably easier to integrate with existing test suites, since it won't change anything except having to use ts-node as part of the tests. Having the compiled output might make things a bit of a PITA.

@dougwilson
Copy link

I'm not certain which one makes the most sense :) What I'm thinking is that either there could be a npm run-script command that would say yes/no or some way to make it be a mocha test, so like it('should contain valid TypeScript definitions', ...) or something.

@blakeembrey
Copy link
Member Author

Hmm, ok. I was thinking you'd just have part of the test suite as literally a TypeScript file and that would enable the type checking on what you're doing. Are you think more along that there should be a way to load the JavaScript file and the definition file and "overlay" them to check if they're valid? I don't think TypeScript has anything like that, at least not right now, but the advantage of writing it against the actual test suite would be that we continuously test the defined options parameters, etc. to ensure accuracy.

Tweaked the test suite into TypeScript for continuous integration and type checking of the public interface
@blakeembrey
Copy link
Member Author

@dougwilson I committed a version using ts-node as part of the test suite, what do you think?

@blakeembrey blakeembrey merged commit e06109e into master May 8, 2016
@blakeembrey blakeembrey deleted the typescript-dts branch May 8, 2016 21:30
bestMUsman pushed a commit to bestMUsman/path-to-regexp that referenced this pull request May 26, 2023
Tweaked the test suite into TypeScript for continuous integration and type checking of the public interface
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

Successfully merging this pull request may close these issues.

None yet

2 participants