sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

transpilation errors raised due to got in typescript #2137

Closed luichooy closed 2 years ago

luichooy commented 2 years ago

Describe the bug

Actual behavior

I installed got@12 as devDependencies for benchmark test and not use in source directory (src) I guess some tools use it when i run npm run build

when i use typescript to compile the project, transpilation errors raised due to got. Errors are as follow:

node_modules/got/dist/source/core/index.d.ts:15:24 - error TS1005: ',' expected.

15 import Options, { type NativeRequestOptions } from './options.js';
                          ~~~~~~~~~~~~~~~~~~~~

node_modules/got/dist/source/core/index.d.ts:16:15 - error TS1005: ',' expected.

16 import { type PlainResponse, type Response } from './response.js';
                 ~~~~~~~~~~~~~

node_modules/got/dist/source/core/index.d.ts:16:35 - error TS1005: ',' expected.

16 import { type PlainResponse, type Response } from './response.js';
                                     ~~~~~~~~

node_modules/got/dist/source/core/options.d.ts:21:29 - error TS1005: ',' expected.

21 import http2wrapper, { type ClientHttp2Session } from 'http2-wrapper';

I solved it by downgrading Got to 11.x.x. Because version 11.x.x has no import typesyntax.

Expected behavior

I'm confused about whether this is a got problem or a typescript problem

Code to reproduce

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "outDir": "./lib",
    "skipLibCheck": true
  },
  "include": ["src/**/*", "./types/*.d.ts"],
}

Checklist

proton-ab commented 2 years ago

Duplicate of https://github.com/sindresorhus/got/issues/2129