-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
[TypeScript] Definitions prevent importing middy #212
Comments
|
@aequasi while that may work, it results in: ERROR in /project/node_modules/middy/middlewares.d.ts
(4,8): error TS1192: Module '"/project/node_modules/middy/index"' has no default export. When using middlewares. The line is middleware.d.ts#L4 which also expects it to be Is there a reason why a default export is not used in this situation? It's just a bit weird not being able to |
What i posted is meant to solve the "no default export". I'm using it now with no issue. Default exports are a typescript thing. The are the equiv of doing |
And, if this type definition was generated automatically (which i'd assume), it wont get a default export |
I see, aren't default exports are a ES6 thing and not ts specific though? But middleware.d.ts#L4 is not compatible with the type definitions for middy either way you chose to import- it will fail every time as soon as you use any middleware, I'm not quite sure how you got it to work since just checking out middy in a blank project gives the typescript compiler error in regards to this! |
No, they are ts specific import {IMiddy} from 'middy';
import * as jsonBodyParser from 'middy/src/middlewares/jsonBodyParser';
import * as httpErrorHandler from 'middy/src/middlewares/httpErrorHandler'; The above works perfect for me, and has the added benefit of not including the other middleware when not necessary. You can ALSO do:
|
@aequasi Sorry, typescript newbie here
results in error
whereas
results in
Typescript: 3.5.3. tsconfig.json https://gist.github.com/lakshmi-kannan/b5161d3291efaa99f2d62e6566e56271 Any ideas? |
When using:
I'm using:
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"lib": ["es2015", "es2016"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"outDir": ".build",
"plugins": [
{ "name": "typescript-tslint-plugin" }
],
"preserveConstEnums": true,
"rootDir": "./",
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"target": "es6",
"esModuleInterop": true
},
"exclude": ["node_modules"]
}
|
I'm going to close for now. All ts definitions will be redone in middy v2. I will need help, as I don't know TS, please post on #587 if you can. |
Using middy 0.15.7 and Typescript 2.8.3.
import middy from 'middy'
results inmodule node_modules/middy/index has no default export
.import { middy } from 'middy'
results inhas no exported member middy, did you mean IMiddy?
IMiddy is just an interface and can not be used as a value though.Changing
export = middy;
toexport default middy
in https://github.com/middyjs/middy/blob/master/index.d.ts#L41 fixes this issueThe text was updated successfully, but these errors were encountered: