glutinum-org / cli

https://glutinum.net/
58 stars 4 forks source link

error generating types for pg #131

Open joprice opened 2 weeks ago

joprice commented 2 weeks ago

When trying to generate types for pg using https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg/index.d.ts#L317, I get the error below. Unlike other errors, this one is failing due to an unexpected null value of parent. Oddly, if I copy that file out of node_modules into my local project directory, it successfully. I thought it might have to do with pnpm symlinks, but it fails in npm as well. I tried narrowing down what part of the file is causing this and found that the uses of export const ... typeof trigger the error.

 export const types: typeof pgTypes;

  export const defaults: Defaults & ClientConfig;

  import * as Pg from ".";

  export const native: typeof Pg | null;
file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/Report.js:18
    return toText(interpolate("%s%P(): Error while reading %s%P() from:\n%s%P()(%d%P(),%d%P())\n\n%s%P()\n\n--- Text ---\n%s%P()\n---\n\n--- Parent text ---\n%s%P()\n---", [replace(toText(interpolate("%s%P()(%d%P())", ["./" + substring(filePath, filePath.indexOf("src/Glutinum.Converter")), fileLine])), "\\", "/"), errorContext, replace(sourceFile.fileName, "\\", "/"), line, column, reason, node.getFullText(), node.parent.getFullText()]));
                                                                                                                                                                                                                                                                                                                                                                                                                                         ^

TypeError: Cannot read properties of undefined (reading 'getFullText')
    at Report_readerError_Z19516DCE (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/Report.js:18:426)
    at readNode (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/Node.js:37:29)
    at Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055 (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/TypeScriptReader.js:63:21)
    at readTypeQueryNode (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/TypeQueryNode.js:31:108)
    at readTypeNode (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/TypeNode.js:185:20)
    at Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2 (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/TypeScriptReader.js:77:84)
    at Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD (file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/TypeScriptReader.js:73:96)
    at file:///Users/dev/glutinum-cli/dist/Glutinum.Converter/Reader/UnionTypeNode.js:90:110
    at file:///Users/dev/glutinum-cli/dist/fable_modules/fable-library-js.4.14.0/List.js:826:28
    at fold (file:///Users/dev/glutinum-cli/dist/fable_modules/fable-library-js.4.14.0/List.js:363:15)
joprice commented 2 weeks ago

Also, I'm not blocked by this as bindings were provided in https://github.com/glutinum-org/binding-requests/issues/5 for this lib. Just reporting to help improve the tool.