Compile errors building `bun-types/types.d.ts` with `tsc`
What version of Bun is running?
1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a
What platform is your computer?
Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
Compiling a TypeScript application with tsc after adding bun-types fails with errors related to the FFI types.
What is the expected behavior?
The application should be compiled successfully an maintain the backwards compatibility with node.
What do you see instead?
node_modules/bun-types/types.d.ts:21949:47 - error TS1005: '?' expected.
21949 ...args: Fns[K]["args"] extends infer A extends readonly FFITypeOrString[]
~~~~~~~
node_modules/bun-types/types.d.ts:21949:55 - error TS1005: ':' expected.
21949 ...args: Fns[K]["args"] extends infer A extends readonly FFITypeOrString[]
~~~~~~~~
node_modules/bun-types/types.d.ts:21950:9 - error TS1005: ',' expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:11 - error TS1005: ',' expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:25 - error TS1005: ']' expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:26 - error TS1005: ',' expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:27 - error TS1131: Property or signature expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:29 - error TS1131: Property or signature expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~~~~~~~~~~~~~~~~~
node_modules/bun-types/types.d.ts:21950:62 - error TS1005: '(' expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21950:64 - error TS1135: Argument expression expected.
21950 ? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
~
node_modules/bun-types/types.d.ts:21951:9 - error TS1128: Declaration or statement expected.
21951 : [unknown] extends [Fns[K]["args"]]
~
node_modules/bun-types/types.d.ts:21951:21 - error TS1005: ';' expected.
21951 : [unknown] extends [Fns[K]["args"]]
~~~~~~~
node_modules/bun-types/types.d.ts:21954:5 - error TS1128: Declaration or statement expected.
21954 ) => [unknown] extends [Fns[K]["returns"]]
~
node_modules/bun-types/types.d.ts:21954:7 - error TS1128: Declaration or statement expected.
21954 ) => [unknown] extends [Fns[K]["returns"]]
~~
node_modules/bun-types/types.d.ts:21954:20 - error TS1005: ';' expected.
21954 ) => [unknown] extends [Fns[K]["returns"]]
~~~~~~~
node_modules/bun-types/types.d.ts:21956:7 - error TS1109: Expression expected.
21956 : FFITypeToReturnsType[ToFFIType<NonNullable<Fns[K]["returns"]>>];
~
node_modules/bun-types/types.d.ts:21956:71 - error TS1005: '(' expected.
21956 : FFITypeToReturnsType[ToFFIType<NonNullable<Fns[K]["returns"]>>];
~
node_modules/bun-types/types.d.ts:21956:72 - error TS1005: ')' expected.
21956 : FFITypeToReturnsType[ToFFIType<NonNullable<Fns[K]["returns"]>>];
~
node_modules/bun-types/types.d.ts:21957:3 - error TS1128: Declaration or statement expected.
21957 };
~
node_modules/bun-types/types.d.ts:22444:1 - error TS1128: Declaration or statement expected.
22444 }
~
Found 20 errors in the same file, starting at: node_modules/bun-types/types.d.ts:21949
Additional information
Dependency versions:
-
typescript: 4.6.3 -
bun-types: 1.0.3
Contents of tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"types": [
"bun-types"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Confirming that this is still an issue with Bun 1.0.5
I'm also seeing it with Bun version 1.1.38 and tsc version 5.7.2
bun init
tsc --noEmit indext.ts
I'm also seeing it with Bun version 1.1.38 and tsc version 5.7.2
bun init tsc --noEmit indext.ts
use SkipLibCheck in tsconfig
bun init creates a tsconfig.json that sets skipLibCheck to true:
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}
Closing this one as types.d.ts no longer exists and #18024 introduces a test case for avoiding errors in @types/bun