Skip to content

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

@mcflis

Description

@mcflis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions