Comments (6)
I fixed the issue in #28. Tested it locally, and it works now. Although the remarks of TazmanianD are correct, using the DefinitelyTyped library to keep a cleaner overview. But with the PR I sent, the package will not break typescript compilation anymore
from node-http-status.
I am no TypeScript expert, anyone could help here?
from node-http-status.
I'm not an expert on .d.ts files but I think the basic problem here is that .d.ts files are only supposed to describe the shape of a module but not of any of the implementation details. Each .d.ts file is entirely for compile only purposes and no code should exist in them that you'd expect to be used in any transpiled output. Here, you've got strings like "Permanent Redirect" but those strings aren't going to end up anywhere. Those strings are implemented in the actual JavaScript for your library.
You don't actually need to include TS definitions as part of your module if you're not using TS and can't really maintain as it would needed. I'm always a fan of module authors including them because then the TS definitions stay in sync with the actual code but most libraries out there have TS definitions created separately as part of the DefinitelyTyped library. In fact, someone has already done that for http-status
and you can see their version of this file here: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-status.
You might be able to just copy that file into your library although I'm not sure if it would be different since it would be part of the module it describes instead of an outside module.
One other thing that would be great if you decide to include the TS definitions in your library is other libraries will upload dummy definitions to DefinitelyTyped that produce an error if you try to use them. If you try to use them, you'll end up with some message like, "You don't need to use this as the types are defined in the library itself."
Your easiest path here is to just remove the .d.ts file and rely on the DefinitelyTyped one.
from node-http-status.
@knor-el-snor, I have been trying without success to add typescript to the mocha based test suite, with typescript being defined as a dev dependency. I will be happy to get help in case you have experience in this field. I will be beneficial to my others packages (csv, printf, ...) and I will be much more confident making TypeScript related changes.
from node-http-status.
@wdavidw I personally use jest for testing, but have used mocha with typescript in the past. But I actually do not have any coffeescript experience. I usually write my own modules in Typescript itself where you can put a transpiler before running the tests like babel-node
or ts-jest
from node-http-status.
You dont need to use coffeescript, you could point to the generated js file directly and i'll deal with that. Otherwise, just requiring a coffescript should work transparently like if it was its js alternative. Mocha is already configured to transpile coffee file transparently.
I used to have some code where I declared the TypeScript in the package.json file and in mocha but it was no close from working and I cleaned up everything. This package is a good place to try to make it work because it is small.
from node-http-status.
Related Issues (19)
- add 424 status HOT 1
- Failed to work with typescript: "Cannot find module 'http-status'" HOT 2
- Typo: MOVED_PERMAMENTLY HOT 2
- Support for unofficial codes? HOT 3
- Github description links to 404 page HOT 1
- Wrong keys for 305_MESSAGE and 305_NAME HOT 1
- Double 420 HOT 1
- Typescript dynamic show status name HOT 2
- Status 502 Missing Message and Code HOT 1
- intl HOT 1
- Expose status code series? HOT 1
- doc bug: s/_CODE/_NAME/ HOT 1
- Modify interface typing HOT 6
- Types are incorrect - lib returns undefined for unknown status codes HOT 4
- HTTP 425 Too Early HOT 1
- literate version of the source code HOT 4
- 300 message bug at npm package release HOT 1
- 300 message bug at npm package release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-http-status.