Skip to content

type script compilation error #388

@omarcovitch

Description

@omarcovitch

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"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions