sindresorhus / got

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

Got 12.5.3, TypeScript 4.9.4 - error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`. #2192

Closed codyfrisch closed 1 year ago

codyfrisch commented 1 year ago

Describe the bug

Despite moduleResolution being set to Node16 the TS1452 error occurs.

package.json includes "type":"module" as well, and has no exports. I have tried all the conceivable permutations I can think of. I admit I'm likely nowhere near as adept as many of you with TypeScript, my actual code is just importing Got and then got.extend

Actual behavior

../../node_modules/cacheable-request/dist/types.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/cacheable-request/dist/types.d.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/cacheable-request/dist/types.d.ts(3,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/cacheable-request/dist/types.d.ts(4,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/form-data-encoder/@type/FormDataEncoder.d.ts(19,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
../../node_modules/got/dist/source/as-promise/types.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/errors.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/index.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/index.d.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/index.d.ts(3,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/index.d.ts(4,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/index.d.ts(5,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(3,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(4,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(5,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(6,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(7,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(8,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(9,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/options.d.ts(13,8): error TS1192: Module '"node:http"' has no default export.
../../node_modules/got/dist/source/core/options.d.ts(14,8): error TS1192: Module '"node:https"' has no default export.
../../node_modules/got/dist/source/core/options.d.ts(21,8): error TS1192: Module '"/home/codyfrisch/src/monday-sdk-nodejs/node_modules/http2-wrapper/index"' has no default export.
../../node_modules/got/dist/source/core/response.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/core/response.d.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/types.d.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
../../node_modules/got/dist/source/types.d.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.

Expected behavior

Successfully build using tsc.

Code to reproduce

Below is the tsconfig.json which is shows moduleResolution is node16.

{
  "compilerOptions": {
    "target": "ES2022", 
    "lib": ["ES2022"],
    "module": "node16",
    "moduleResolution": "node16",
    "moduleDetection": "force",
    "resolveJsonModule": false,
    "declaration": true,
    "pretty": true,
    "declarationMap": true,
    "sourceMap": true,
    "stripInternal": true,
    "noEmitOnError": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true, 
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "skipLibCheck": true
  }
}

Checklist

codyfrisch commented 1 year ago

Well this is entirely on me. my build script was tsc index.mts and it works fine as just "tsc". mea culpa, only been doing this six months, and self taught. bound to be human error.