Skip to content

Table decorator overloaded returning incorrect void type #282

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

Closed
Danlock opened this issue Jan 24, 2018 · 9 comments
Closed

Table decorator overloaded returning incorrect void type #282

Danlock opened this issue Jan 24, 2018 · 9 comments

Comments

@Danlock
Copy link
Contributor

Danlock commented Jan 24, 2018

So first of all, if a decorator returns void instead of Function on strict mode typescript throws an error because of this, and it can't really be worked around., or used as a decorator in strict mode. So the type is wrong because of that.

microsoft/TypeScript#4534
https://stackoverflow.com/questions/36446480/typescript-decorator-reports-unable-to-resolve-signature-of-class-decorator-whe

The way I found it is that IDefineOptions is incorrect, in that it doesn't allow indexes with where conditions. This type definition is hosted outside the library, so it isn't as relevant but it causes making a table with decorators with partial indexes throw errors on typescript strict mode.

The quick workaround is to just set the where key under indexes as an any key on the object so typescript cant detect it. such as

['where' as any]

Danlock pushed a commit to Danlock/sequelize-typescript that referenced this issue Jan 24, 2018
@Danlock
Copy link
Contributor Author

Danlock commented Jan 24, 2018

I tried to solve the issue by returning void or void|Function, but neither passes the tests.
Ill take another look when I have more time, typecasting it to any isn't really a solution.

@RobinBuschmann
Copy link
Member

Hey @Danlock which exact strict option do you mean?

@Danlock
Copy link
Contributor Author

Danlock commented Mar 4, 2018

{
  "compileOnSave": true,
  "compilerOptions": {
    "lib": ["es2015","es2016","es2017"],
    "suppressImplicitAnyIndexErrors": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": "node",
    "noImplicitReturns": false,
    "noEmitOnError": true,
    "strictNullChecks": true,
    "traceResolution": false,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "noImplicitAny": true,
    "alwaysStrict": true,
    "strict": true,
    "module": "commonjs",
    "outDir": "./build",
    "baseUrl": "./src",
    "target": "es2017",
    "inlineSourceMap": true,
    "allowJs": true,
    "pretty": true
  },
  "include": [
    "./package.json",
    "./tsconfig.json",
    "./src/**/*"
  ],
  "paths": {
    "src/*" : ["./src/**/*"]
  }
}

Posted is my tsconfig.json

@mxs42
Copy link

mxs42 commented Jun 11, 2018

Any updates on this? Examples from readme simply don't compile in strict mode.

@RobinBuschmann
Copy link
Member

Sry completely overseen this issue. But where seems to work perfectly well in @Table({indexes: [{where: {bla: 'sdfdsf'}}]})

@mxs42 What's your issue here? :)

@mxs42
Copy link

mxs42 commented Jun 11, 2018

@RobinBuschmann well, it turns out that I messed with types while hot-fixing an issue with AnyWhereOptions and broke some code accidentally 😆
No issues on my sides anymore, I should be more careful I guess.

@RobinBuschmann
Copy link
Member

@Danlock @mxs42 Is this still an issue? I couldn't reproduce it.

@mxs42
Copy link

mxs42 commented Sep 29, 2018

I don't use sequelize-typescript anymore (and I believe it was issue on my side) so I guess it can be closed.

@Danlock
Copy link
Contributor Author

Danlock commented Sep 29, 2018

I also don't use typescript anymore, so If you can't reproduce it, that's good enough for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants