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

Typings for typescript #169

Merged
merged 3 commits into from
Dec 20, 2016
Merged

Typings for typescript #169

merged 3 commits into from
Dec 20, 2016

Conversation

mkusher
Copy link
Contributor

@mkusher mkusher commented Dec 17, 2016

Resolves #167
I'm not sure about how to test it properly in your configuration, but it looks like my variant would be ok.
I've added feature from new ts 2.1, but it's only needed for one case td.object(['a', 'b']). Also not sure what to add into README.md.

@orazyto
Copy link

orazyto commented Dec 20, 2016

@mkusher - thanks for putting this together!
I've tried it on my machine - td is now recognized in my Typescript spec (I can get an example working).

When I run my tests, I do the following errors though:
ERROR in [default] /Users/orazyto/Documents/RapidPrototype/test_project/node_modules/testdouble/index.d.ts:4:2
A computed property name in a type literal must directly refer to a built-in symbol.

ERROR in [default] /Users/orazyto/Documents/RapidPrototype/test_project/node_modules/testdouble/index.d.ts:4:2
A computed property name must be of type 'string', 'number', 'symbol', or 'any'.

ERROR in [default] /Users/orazyto/Documents/RapidPrototype/test_project/node_modules/testdouble/index.d.ts:4:3
Cannot find name 'P'.

ERROR in [default] /Users/orazyto/Documents/RapidPrototype/test_project/node_modules/testdouble/index.d.ts:4:8
Cannot find name 'Key'.

@mkusher
Copy link
Contributor Author

mkusher commented Dec 20, 2016

@orazyto you are using typescript < 2.1

@orazyto
Copy link

orazyto commented Dec 20, 2016

@mkusher - you are right, my mistake.
Since we're using Angular2, upgrading to typescript 2.1 seems to be currently blocked - as described here:
http://stackoverflow.com/questions/40309510/typescript-2-1-coupled-with-the-angular-2-compiler-silently-fails-to-compile-pro
angular/angular#13294
I'm awaiting this fix to be able to move forward testing your typings file.

@mkusher
Copy link
Contributor Author

mkusher commented Dec 20, 2016

@orazyto oh, I see. Well, I've removed this mapped type for arrays, they are untyped now. Can you check the branch now?

@orazyto
Copy link

orazyto commented Dec 20, 2016

@mkusher - Thanks! It's working now with Typescript 2.0 in my Angular2 project :-)

@mkusher
Copy link
Contributor Author

mkusher commented Dec 20, 2016

@orazyto ;)

@searls
Copy link
Member

searls commented Dec 20, 2016

Two questions:

  1. Is there anything I need to know about this thing as a maintainer other than having this in the repo / npm bundle?

  2. Can we move this typescript config json outside of src/? I want to keep src for the actual code in the library and it seems like a config file wouldn't belong there. I'm fine with a dot-file in the root or a config/typescript.json. Let me know if this is counter-idiomatic or wouldn't work

@mkusher
Copy link
Contributor Author

mkusher commented Dec 20, 2016

@searls

  1. It should be included in npm package(not be excluded by npmignore or something similar). It describes package's public api, so if public api is changed the d.ts file needs to be changed
  2. I can put index.d.ts anywhere you want, the path to index.d.ts is specified in package.json

@searls
Copy link
Member

searls commented Dec 20, 2016

Is index.d.ts the conventional location? Seems like people know to look for it or something like it when they glance at a repo

@mkusher
Copy link
Contributor Author

mkusher commented Dec 20, 2016

@searls from documentation:

Also note that if your main declaration file is named index.d.ts and lives at the root of the package (next to index.js) you do not need to mark the "types" property, though it is advisable to do so.

@searls
Copy link
Member

searls commented Dec 20, 2016

neato, looks good

@searls searls merged commit ec78cc2 into testdouble:master Dec 20, 2016
@mkusher mkusher deleted the feature/typescript-typings branch December 20, 2016 20:09
@searls
Copy link
Member

searls commented Dec 20, 2016

Landed in 1.10.1

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

Successfully merging this pull request may close these issues.

None yet

3 participants