- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 91
Removed the definition of locals from index.d.ts #239
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
Conversation
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.
Indeed that's a good remark. Would you mind write a little Typescript usage in the Readme? Explaining the use of this plugin with Typescript like you did in the test?
        
          
                README.md
              
                Outdated
          
        
      | ```typescript | ||
| interface Locals { | ||
| appVersion: string, | ||
| assetsManifest: AssetsManifest, | 
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.
Why this addition?
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.
Moved to a separate interface for better readability
This option seems less clear:
declare module 'fastify' {
  interface FastifyReply {
    locals:
      | Partial<{
        appVersion: string;
        assetsManifest: AssetsManifest;
      }>
      | undefined;
    }
}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.
but AssetsManifest is not defined in the example it could lead to misreading don't you think?
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.
Removed undeclared types and added another example with an object
interface Locals {
  appVersion: string,
  isAuthorized: boolean,
  user?: {
    id: number
    login: string
  }
}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.
lgtm
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.
lgtm. Thanks!
Checklist
npm run testandnpm run benchmarkand the Code of conduct
In practice it turned out that it is better when there are no definitions for
localsat all. If necessary, it is easier to determine without conflicts directly in the code