velsa / notion-ts-client

Generates an easy to use and fully typed API to access and modify the data in Notion Databases
MIT License
16 stars 1 forks source link

Recommend a project and compilation configuration #4

Closed dghelm closed 6 months ago

dghelm commented 6 months ago

Really happy to stumble across this project while wrestling with the official Notion SDK in ts.

Unfortunately, though, I can't get my project configurations correct to build my project with the generated code. I'm not sure if it's NodeNext or something else, but files are not linking -- I think because the lack of explicit file extensions. That said, even after adding .js to imports throughout, I'm getting a lot of errors about implicit 'any' type.

Would love an example project or similar to just use as a template even.

Config:

{
  "compilerOptions": {
    "strict": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "preserveWatchOutput": true,
    "noEmit": true,
    "module": "NodeNext",
    "target": "ES2021",
    "moduleResolution": "NodeNext",
    "sourceMap": true,
    "outDir": "build",
    "rootDir": ".",
    "paths": {
      "#root/*": ["./src/*"]
    }
  },
  "include": ["src/**/*"]
}

And an excerpt of the errors:

src/notion-sdk/core/src/generic-db.ts(39,19): error TS7008: Member 't' implicitly has an 'any' type.
src/notion-sdk/core/src/p-throttle.ts(44,9): error TS7034: Variable 'strictTicks' implicitly has type 'any[]' in some locations where its type cannot be determined.
src/notion-sdk/core/src/p-throttle.ts(50,41): error TS7005: Variable 'strictTicks' implicitly has an 'any[]' type.
src/notion-sdk/core/src/p-throttle.ts(62,31): error TS7005: Variable 'strictTicks' implicitly has an 'any[]' type.
src/notion-sdk/core/src/p-throttle.ts(65,5): error TS7005: Variable 'strictTicks' implicitly has an 'any[]' type.
src/notion-sdk/core/src/p-throttle.ts(74,11): error TS7006: Parameter 'function_' implicitly has an 'any' type.
src/notion-sdk/core/src/p-throttle.ts(75,33): error TS7019: Rest parameter 'arguments_' implicitly has an 'any[]' type.
src/notion-sdk/core/src/p-throttle.ts(77,51): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
src/notion-sdk/core/src/p-throttle.ts(80,11): error TS7034: Variable 'timeoutId' implicitly has type 'any' in some locations where its type cannot be determined.
src/notion-sdk/core/src/p-throttle.ts(84,35): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
src/notion-sdk/core/src/p-throttle.ts(85,24): error TS7005: Variable 'timeoutId' implicitly has an 'any' type.
src/notion-sdk/core/src/p-throttle.ts(106,7): error TS7005: Variable 'strictTicks' implicitly has an 'any[]' type.
src/notion-sdk/dbs/support-requests/db.ts(30,11): error TS7053: Element implicitly has an 'any' type because expression of type '"and" | "or"' can't be used to index type '{}'.
  Property 'and' does not exist on type '{}'.
src/notion-sdk/dbs/support-requests/db.ts(39,26): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ readonly due: "date"; readonly resolved: "date"; readonly assignee: "people"; readonly contactName: "rich_text"; readonly tags: "multi_select"; readonly email: "email"; readonly description: "rich_text"; ... 4 more ...; readonly replyTs: "rich_text"; }'.
  No index signature with a parameter of type 'string' was found on type '{ readonly due: "date"; readonly resolved: "date"; readonly assignee: "people"; readonly contactName: "rich_text"; readonly tags: "multi_select"; readonly email: "email"; readonly description: "rich_text"; ... 4 more ...; readonly replyTs: "rich_text"; }'.
src/notion-sdk/dbs/support-requests/db.ts
dghelm commented 6 months ago

Well, tsup seems happier with everything. If anyone else runs into this, try using it instead of tsc.

Here is the command in package.json: "dev": "tsup src/main.ts --watch --onSuccess \"node dist/main.cjs\"",