Giter VIP home page Giter VIP logo

Comments (3)

Gerrit0 avatar Gerrit0 commented on June 7, 2024

For this you'd have to write a custom plugin to overwrite the type with a stringified version, here's an example of how to do that for parameters.

$ npx typedoc src/gh2472.ts --plugin ./path/to/plugin.mjs
// @ts-check
import td from "typedoc";

/** @param {td.Application} app */
export function load(app) {
    /** @type {Map<td.ParameterReflection, td.SomeType>} */
    const replacements = new Map();

    app.converter.on(td.Converter.EVENT_CREATE_PARAMETER, replaceTypesWithStrings);

    app.converter.on(td.Converter.EVENT_RESOLVE_BEGIN, () => {
        for (const [param, type] of replacements) {
            param.type = type;
        }
        replacements.clear();
    });

    /**
     * @param {td.Context} context
     * @param {td.ParameterReflection} reflection
     * @param {td.TypeScript.Node?} node
     */
    function replaceTypesWithStrings(context, reflection, node) {
        const symbol = context.project.getSymbolFromReflection(reflection);
        if (!symbol) return;

        const type = context.checker.typeToString(context.checker.getTypeOfSymbol(symbol));
        replacements.set(reflection, new td.UnknownType(type));
    }
}

from typedoc.

Mizugorou avatar Mizugorou commented on June 7, 2024

Great one! Look like it need to do custom callback to each places.
Could I ask more? I want this results apply to all places such as 'return', not just parameter. Could you another guide me? Or have any more detail document for this?

  // for example. I want to get results as K[] and T[]
  public myFunction(params: K[]): T[] {
     ...
     return 
  }

from typedoc.

Gerrit0 avatar Gerrit0 commented on June 7, 2024

You'll have to add listeners for the other CREATE events on the converter, and replace the type field on those too: https://typedoc.org/api/classes/Converter.html#EVENT_CREATE_DECLARATION is the big one, but there's also one for parameters and signatures

from typedoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.