-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Problem with Newley released types #2206
Problem with Newley released types #2206
Comments
Just checking, but does require work? And can you import using `import * as nodemon from 'nodemon'? |
const nodemon = require('nodemon'); - WORKS doesn't load types import * as nodemon from 'nodemon'; - DOESN't work I am pretty sure it is because there is no export of the functionality of nodemon. Based on the types nothing is exported |
I need to have a play. I only added types as an attempt to help people who were requiring the module, but I don't personally use TypeScript (some context). If you have any advice, please do share, otherwise I'll tinker this week 👍 |
Okay, to clarify, // test.mjs
import nodemon from 'nodemon'
nodemon({}).on('start', () => {
console.log('started');
}); But the types aren't being found by tools like VS Code. This is my code: package.json {
"name": "2206",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"nodemon": "^3.1.1"
}
} index.js (the sub process): console.log('Hello, World!'); And the run script: test.mjs import nodemon from 'nodemon';
nodemon({}).on('start', () => {
console.log('started');
}); From the command line: @KevinGruber you're saying it's undefined, can you share your code? |
Ok sry for the misunderstanding. The runtime code works yes, but the typescript doesn't build because of "wrong" types. undefined in the sense of types in TS Beforehand it worked because there where no types (and I configured ts to allow for no types). If you want I can make a PR with adjusted types? |
Yeah, if you could do a PR I'd appreciate it. I don't want to convert the project to typescript, but I do want to expose the types to help devs (which is why I've just added index.d.ts) |
I have the types already working, I now ran into the problem that they are not fitting the api approach types. Can you help me and send me a list of allowed attributes? Like script etc. are those than just merged with the current NodemonSettings? Or is NodemonSettings just the json config representation? |
This:
Sod, there's more props, I'll take a look and see if I can get a complete list. Annoyingly the |
If you have a branch, send up a work in progress PR and I can add to it (I think…) |
Found the following - pretty sure that's it. script?: string;
ext?: string; // "js,mjs" etc (should really support an array of strings, but I don't think it does right now)
events?: { [key: string]: string };
env?: { [key: string]: string };
exec?: string; // node, python, etc
execArgs?: string[]; // args passed to node, etc |
🎉 This issue has been resolved in version 3.1.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@remy the types still aren't correct in latest version, type errors happen when using the documented API (the API that was 100% working prior to 3.1.1. |
@arpowers what do you mean with working before, it wasn't using any types before Can you show me the error? |
@arpowers a screenshot would be useful here, or othewise some code for context. Ta. |
I should mention that I'm using ....and no change, type errors are still there. |
Oooh. I know what it is. Though, not sure how you represent it in Typescript. It's because the This isn't a fix, but if you chain the. I'll see if I can fix the types in the morning, or if anyone gets a PR before then, happy to merge. Unrelated: I wonder who is maintaining @types/nodemon...that isn't mine... 🤔 |
no hurry, just locked version for now. |
@KevinGruber or @arpowers I'd appreciate some eyes on my change: https://github.com/remy/nodemon/pull/2208/files - I've tested it and it appears to work (with autocomplete), but more importantly the code actually still runs. Again, I'm not a regular TS dev, so wary it could be wrong. |
@remy yes that works for me I tested both use cases I wasn't aware that you can use nodemon as a singleton like that. Sry for missing that :-( I noticed another thing yesterday can you provide string and string[] to nodeArgs and execArgs? I took your suggestion and it took only string[] but my old code provided string. If it supports both and is expected I would change the type to string | string[] |
🎉 This issue has been resolved in version 3.1.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
nodemon -v
: 3.1.1Expected behaviour
When importing nodemon there is a default export for functionality defined in the types.
Actual behaviour
With the addition of #2204 there where types added to the project, but no default export types for functionality -> that leads to a not usable nodemon in typescript
Steps to reproduce
import nodemon from 'nodemon';
-> nodemon is not a module
The text was updated successfully, but these errors were encountered: