Coder Social home page Coder Social logo

Comments (6)

knor-el-snor avatar knor-el-snor commented on August 16, 2024 1

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.

wdavidw avatar wdavidw commented on August 16, 2024

I am no TypeScript expert, anyone could help here?

from node-http-status.

TazmanianD avatar TazmanianD commented on August 16, 2024

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.

wdavidw avatar wdavidw commented on August 16, 2024

@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.

knor-el-snor avatar knor-el-snor commented on August 16, 2024

@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.

wdavidw avatar wdavidw commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.