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

Filter symbols by both name and fully qualified name #580

Open
steven87vt opened this issue Oct 24, 2023 · 0 comments
Open

Filter symbols by both name and fully qualified name #580

steven87vt opened this issue Oct 24, 2023 · 0 comments

Comments

@steven87vt
Copy link

According to the README you are supposed to be able to filter by fully qualified type name, however I cannot see how it would operate from looking at the code.

I would want to use this during cli to generate the correct type given multiple types by the same name. This is happening because of custom file extension support vue. Excluding all .vue files has no effect on the issue. So in my case I just want to filter any type not mine.

Example:

//node_modules/@vue/runtime-core/dist/runtime-core.d.ts
export interface AppConfig {
  ...
  // going to get sucked up by anything that includes a .vue file because of default definition files under node_modules
}

//my_project/src/types.ts
export interface AppConfig {
  some_item: string
}
npx typescript-json-schema my_project/tsconfig.app.json '"/my_project/src/store/types".AppConfig' --uniqueNames

Error: 2 definitions found for requested type ""/my_project/src/store/types".AppConfig".

Looking at #151 symbols are filtered by the type name value. But should it be filtered by either type name or fully qualified name?

return this.symbols.filter((symbol) => symbol.typeName === name);

public getSymbols(name?: string): SymbolRef[] {
  if (name === void 0) {
    return this.symbols;
  }

  return this.symbols.filter(function (symbol) { return symbol.typeName === name || symbol.fullyQualifiedName === name; });
  // return this.symbols.filter(function (symbol) { return symbol.typeName === name });
}

After making that change locally the cli generated the schema properly.

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

1 participant