-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
fix: Use export =
in TypeScript definitions
#1285
Conversation
I was wondering why VSCode still didn't know about the app. So I think this makes sense, thank you! The tests failed because TSLint is complaining:
This might warrant an exception but I'll let you double check. You can run the tests (including linting) with
In the cloned repository. |
Sorry, I should know better to lint before submitting a PR. I disabled the The TSLint docs say:
So this applies to Another option might be to use a tool like dtslint to lint the Before merging this, let me know if you want to wait for me to do the rest of the packages and add them to this PR, or if you want me to create a separate PR of each package. |
I should have continued reading the TSLint docs. This is the configuration we should probably use.
This will prohibit |
You can also just disable it for that file by adding a
At the beginning |
True, but that will need to be added to the rest of the handwritten |
I've got the typings for @feathersjs/express ready. Do you want me to add them to this PR or submit a new one? |
Let's get it all into this one PR. And your'e right, if this setting will apply to more than one file it makes sense to keep it global. |
Okay, for all CommonJS packages that already had an A few packages still don't have I also removed the headers because they serve no purpose outside of DefinitelyTyped. A few of the files needed triple-slash directives replaced with imports. See Consuming Dependencies and Global Libraries regarding that. All tests passed, so the typings referenced by the packages written in TypeScript are working internally. I performed manual tests along the way, but some more human testing before merging wouldn't hurt. We probably want to squash some, if not all, of these commits. Let me know if you want me to do that. |
Argh, sorry I merged some PRs in the wrong order and now I'm confused on how to resolve those conflicts. Would you mind having a look? If the conflicts are fixed it's definitely good to merge. |
Not a problem. I was on vacation last week, so I didn't have much time to work on this PR. I have a few more commits that I haven't pushed, anyway. I also wanted to see if you'd be okay with me adding test files and implementing |
Thanks! And yes, |
3ec3398
to
59b98dc
Compare
- Replace triple-slash directives with imports. See https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html#consuming-dependencies and https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html#global-libraries
Also, keep export name consistent with lib.js
express() returns the Express type, not the Application type.
Since the express typings use `export =` we can import express' default export.
Once the tests pass this should be good to go right? |
Since tests are still passing I'll take this as a yes 😄, thank you for doing this! |
Sorry, I missed your question. Thanks for merging. I've got a |
Status
Written in TypeScript
Has index.d.ts, but needs
export =
Has index.d.ts, but doesn't need
export =
Has no index.d.ts
Since Feathers isn't written in TypeScript, and it doesn't use ES modules, its typings should use
export =
instead ofexport default
.The main reason for this change is that VSCode's intellisense is completely broken with Feathers when using JavaScript and CommonJS.
Another reason is that the following imports should all work in TypeScript.
This PR follows the pattern used in Express' typings.
Moved all of the exported types and interfaces to a new namespace called
feathers
.Added a new
Feathers
interface, and movedversion
anddefault
to that interface. This is the type of the export.Declared a
feathers
variable that implementsFeathers
and exported it withexport =
syntax.This should probably be implemented in all feathers packages, but I just did this one as a start to gauge interest. I can do the rest of the typings and add it to this PR if desired.
This issue was raised in feathers-typescript with no response.
These changes were requested in DefinitelyTyped with no response from the package maintainers and eventually merged into DefinitelyTyped today. When I noticed that
index.d.ts
files were added to this repo, I decided to open a PR here.Please let me know what you think and if there is anything I'm missing.