-
-
Notifications
You must be signed in to change notification settings - Fork 752
Closed
Closed
Copy link
Labels
needs reproductionNeeds a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05dNeeds a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d
Description
Search terms
Method Decorator
Expected Behavior
Resolve Method Decorator
Actual Behavior
Unable to resolve signature of method decorator when called as an expression.
Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
Steps to reproduce the bug
// a.ts
export function autoBind(
target: Record<string, any>,
propertyKey: string,
{ configurable, enumerable, value: fn }: TypedPropertyDescriptor<(...arg: any[]) => any>
): TypedPropertyDescriptor<(...arg: any[]) => any> {
return {
configurable,
enumerable,
get(): (...arg: any[]) => any {
if (!fn) {
throw new Error('函数不得为空');
}
return fn.bind(this);
}
};
}
// b.ts
import { autoBind } from './a';
class B {
@autoBind
private test(): void {
console.log(this);
}
}tsconfig.json :
{
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
"target": "ES5",
"lib": ["esnext", "dom"],
"sourceMap": true,
"baseUrl": ".",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowJs": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"strict": true,
"resolveJsonModule": true,
"paths": {
"@/*": ["./src/*"],
"lib/*": ["./src/lib/*"],
"public/*": ["./src/public/*"],
"res/*": ["./src/res/*"],
"script/*": ["./src/script/*"],
"style/*": ["./src/style/*"]
}
},
"exclude": [
"node_modules",
"build",
"dist",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts",
"tslint:latest",
"tslint-config-prettier"
]
}typedoc config:
{
out: './docs',
module: 'commonjs',
target: 'es5',
exclude: ['**/node_modules/**/*.*'],
experimentalDecorators: true,
excludeExternals: true,
includeDeclarations: true,
ignoreCompilerErrors: true
}Environment
- Typedoc version: 0.17.8
- TypeScript version: 3.9.5
- Node.js version: 10.16.3
- OS: mac
Metadata
Metadata
Assignees
Labels
needs reproductionNeeds a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05dNeeds a minimal reproducible case - https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d