-
-
Notifications
You must be signed in to change notification settings - Fork 380
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 server-side type definitions #95
Conversation
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
======================================
Coverage 90.5% 90.5%
======================================
Files 15 15
Lines 200 200
Branches 54 54
======================================
Hits 181 181
Misses 17 17
Partials 2 2 Continue to review full report at Codecov.
|
"strictFunctionTypes": false, | ||
"baseUrl": ".", | ||
"paths": { | ||
"loadable-components": ["."], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it could be fixed!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? The module resolution works out of the box as soon as this package is in node_modules, but within the repository, the compiler seems to need a little hint to be able to locate the module. I don't know if it's the best way, but it works :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote the initial TS definitions, and fail to get dtslint working with server as a separate file.
You just fixed it, it the quite straight way, the way I could not figure out of dtslint documentation.
According to them - everything should work even without patching tsconfig, and I will not be surprised if it will, but they wont 💩 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submodules are apparently more complicated :) I'm not too fond of the fact that while most type definitions are in types/
, the server.d.ts
suddenly has to be in the package root. But it seems to be the way to go 🤷♂️
Thanks! |
Hello, I'm trying to use this awesome package with Typescript on the server, and I've had some difficulties.
When I
import {getLoadableState} from 'loadable-components/server'
, The Typescript compiler complains that it "Could not find a declaration file for module 'loadable-components/server'." I've managed to work around this by explicitly setting the path mapping in tsconfig.json to"loadable-components/*": ["node_modules/loadable-components/types"]
, but I feel that's an unnecessary step for the end user.This PR thus extracts the server-side type definitions to a separate
server.d.ts
to match the structure of the JS modules, which seems to be the recommended way.I've also added a type definition for the
DeferredState
which wasn't exposed before.