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

type script compilation error #388

Open
omarcovitch opened this issue Jul 11, 2022 · 1 comment
Open

type script compilation error #388

omarcovitch opened this issue Jul 11, 2022 · 1 comment

Comments

@omarcovitch
Copy link

omarcovitch commented Jul 11, 2022

Typescript failed to compile because of missing interfaces.

Adding typescript lib (dom/webworker), in tsconfig file, fix the problem but I compile it in a BE so How can I compile my service with pdjs without adding "dom" or "webworker" to typescript lib?

Compilation error output:

`node_modules/@pagerduty/pdjs/build/src/api.d.ts:29:38 - error TS2304: Cannot find name 'Response'.

29 export interface APIResponse extends Response {
~~~~~~~~

node_modules/@pagerduty/pdjs/build/src/api.d.ts:32:15 - error TS2304: Cannot find name 'Response'.

32 response: Response;
~~~~~~~~

node_modules/@pagerduty/pdjs/build/src/common.d.ts:2:41 - error TS2304: Cannot find name 'RequestInit'.

2 export interface RequestOptions extends RequestInit {
~~~~~~~~~~~

node_modules/@pagerduty/pdjs/build/src/common.d.ts:10:47 - error TS2304: Cannot find name 'URL'.

10 export declare function request(url: string | URL, options?: RequestOptions): Promise;
~~~

node_modules/@pagerduty/pdjs/build/src/common.d.ts:10:87 - error TS2304: Cannot find name 'Response'.

10 export declare function request(url: string | URL, options?: RequestOptions): Promise;
~~~~~~~~

node_modules/@pagerduty/pdjs/build/src/events.d.ts:4:40 - error TS2304: Cannot find name 'Response'.

4 export interface EventResponse extends Response {
~~~~~~~~

node_modules/@pagerduty/pdjs/build/src/events.d.ts:6:15 - error TS2304: Cannot find name 'Response'.

6 response: Response;
~~~~~~~~

Found 7 errors in 3 files.

Errors Files
2 node_modules/@pagerduty/pdjs/build/src/api.d.ts:29
3 node_modules/@pagerduty/pdjs/build/src/common.d.ts:2
2 node_modules/@pagerduty/pdjs/build/src/events.d.ts:4`

tsconfig:

{
"compilerOptions": {
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"rootDir": "./src",
"sourceMap": true,
"declaration": true,
"module": "commonjs",
"target": "es2017",
"outDir": "./lib",
"lib": ["es2017"] // adding here "dom" or "webworker" fix the problem but we want to avoid adding them
},
"include": ["src//*"],
"exclude": ["node_modules", "
/*.spec.ts"]
}

@parkeyparker
Copy link
Contributor

This has come up a few times on various projects but there doesn't seem to be a general consensus on the best approach yet - some informative links on this issue on AWS SDK: aws/aws-sdk-js-v3#3063

Essentially, the quick workarounds are what you've mentioned above (adding dom) or adding skipLibCheck: true. The Microsoft thread is much more in-depth and currently still open: microsoft/TypeScript#31894

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

2 participants