Skip to content
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

TypeError: Cannot read property 'find' of undefined #48

Closed
mcflis opened this issue Jan 18, 2019 · 1 comment
Closed

TypeError: Cannot read property 'find' of undefined #48

mcflis opened this issue Jan 18, 2019 · 1 comment

Comments

@mcflis
Copy link

mcflis commented Jan 18, 2019

Im getting a TypeError when running ./node_modules/.bin/typedoc --theme markdown --out examples/md-doc ./src/reflect/var-name.ts

Version

{
    "typedoc": "^0.14.2",
    "typedoc-plugin-markdown": "^1.1.21",
    "typescript": "^3.2.2"
}

Output

Loaded plugin ./node_modules/typedoc-plugin-markdown

Using TypeScript 3.2.2 from ./node_modules/typescript/lib
./node_modules/typedoc-plugin-markdown/dist/theme/helpers/getParamatersTableHeaders.js:5
    const hasDefaultValues = parameters.find((param) => {
                                       ^

TypeError: Cannot read property 'find' of undefined
    at ParameterReflection.getParametersTableHeaders (./node_modules/typedoc-plugin-markdown/dist/theme/helpers/getParamatersTableHeaders.js:5:40)
    at eval (eval at createFunctionContext (./node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:5:146)
    at Object.prog [as fn] (./node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12)
    at ParameterReflection.<anonymous> (./node_modules/handlebars/dist/cjs/handlebars/helpers/if.js:19:22)
    at eval (eval at createFunctionContext (./node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:14:32)
    at prog (./node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12)
    at execIteration (./node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:51:19)
    at SignatureReflection.<anonymous> (./node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:61:13)
    at eval (eval at createFunctionContext (./node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:31)
    at Object.prog [as fn] (./node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12)

Process finished with exit code 1

var-name.ts

const varExtractor = new RegExp('(return|=>) ([^;]+);?');
export function varName<TResult>(name: () => TResult, opts: {basename: boolean} = { basename: true}) {
    const m = varExtractor.exec(name + '');
    if (m == null) {
        throw new Error("The function does not contain a statement matching 'return variableName;'");
    }
    return !opts.basename ? m[2] : m[2].split('.').pop() + '';
}

Type of this is ParameterReflection in getParamatersTableHeaders when the error occurs.

@tgreyuk
Copy link
Member

tgreyuk commented Jan 18, 2019

Have fixed the error in 1.1.22 . Will look at improving the UI in this scenario in due course. thanks.

@tgreyuk tgreyuk closed this as completed Jan 18, 2019
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

2 participants