Skip to content

Commit c106820

Browse files
authored
fix: Use the correct default lib path in bun-types integration test (#21825)
1 parent a4555ee commit c106820

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

test/integration/bun-types/bun-types.test.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fileURLToPath, $ as Shell } from "bun";
22
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
3-
import { existsSync, readFileSync } from "node:fs";
3+
import { readFileSync } from "node:fs";
44
import { cp, mkdtemp, rm } from "node:fs/promises";
55
import { tmpdir } from "node:os";
66
import { dirname, join, relative } from "node:path";
@@ -113,23 +113,22 @@ async function diagnose(
113113
const host: ts.LanguageServiceHost = {
114114
getScriptFileNames: () => files,
115115
getScriptVersion: () => "0",
116-
getScriptSnapshot: fileName => {
116+
getScriptSnapshot: absolutePath => {
117117
if (extraFiles) {
118-
const relativePath = relative(fixtureDir, fileName);
118+
const relativePath = relative(fixtureDir, absolutePath);
119119
if (relativePath in extraFiles) {
120120
return ts.ScriptSnapshot.fromString(extraFiles[relativePath]);
121121
}
122122
}
123123

124-
if (!existsSync(fileName)) {
125-
return undefined;
126-
}
127-
128-
return ts.ScriptSnapshot.fromString(readFileSync(fileName).toString());
124+
return ts.ScriptSnapshot.fromString(readFileSync(absolutePath).toString());
129125
},
130126
getCurrentDirectory: () => fixtureDir,
131127
getCompilationSettings: () => options,
132-
getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),
128+
getDefaultLibFileName: options => {
129+
const defaultLibFileName = ts.getDefaultLibFileName(options);
130+
return join(fixtureDir, "node_modules", "typescript", "lib", defaultLibFileName);
131+
},
133132
fileExists: ts.sys.fileExists,
134133
readFile: ts.sys.readFile,
135134
readDirectory: ts.sys.readDirectory,
@@ -360,32 +359,32 @@ describe("@types/bun integration test", () => {
360359
code: 2339,
361360
},
362361
{
363-
line: "streams.ts:16:3",
362+
line: "streams.ts:18:3",
364363
message: "No overload matches this call.",
365364
code: 2769,
366365
},
367366
{
368-
line: "streams.ts:18:16",
367+
line: "streams.ts:20:16",
369368
message: "Property 'write' does not exist on type 'ReadableByteStreamController'.",
370369
code: 2339,
371370
},
372371
{
373-
line: "streams.ts:44:19",
372+
line: "streams.ts:46:19",
374373
message: "Property 'json' does not exist on type 'ReadableStream<Uint8Array<ArrayBufferLike>>'.",
375374
code: 2339,
376375
},
377376
{
378-
line: "streams.ts:45:19",
377+
line: "streams.ts:47:19",
379378
message: "Property 'bytes' does not exist on type 'ReadableStream<Uint8Array<ArrayBufferLike>>'.",
380379
code: 2339,
381380
},
382381
{
383-
line: "streams.ts:46:19",
382+
line: "streams.ts:48:19",
384383
message: "Property 'text' does not exist on type 'ReadableStream<Uint8Array<ArrayBufferLike>>'.",
385384
code: 2339,
386385
},
387386
{
388-
line: "streams.ts:47:19",
387+
line: "streams.ts:49:19",
389388
message: "Property 'blob' does not exist on type 'ReadableStream<Uint8Array<ArrayBufferLike>>'.",
390389
code: 2339,
391390
},

test/integration/bun-types/fixture/streams.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { expectType } from "./utilities";
22

3-
new ReadableStream({
3+
new ReadableStream<string>({
44
start(controller) {
55
controller.enqueue("hello");
66
controller.enqueue("world");
7+
// @ts-expect-error
8+
controller.enqueue(2);
79
controller.close();
810
},
911
});

0 commit comments

Comments
 (0)