Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions integration-tests/typescript-versions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ describe.each(TS_VERSIONS)('with typescript@%s', (version) => {
INSTALL_AND_BUILD_TIMEOUT,
);

it(
'should build a .ts file when tsconfig.json is present in the CWD but no --tsconfig flag is passed (TS5112 regression)',
async () => {
// TS 7 errors with TS5112 when a file is passed on the CLI and an ambient
// tsconfig.json exists in the CWD. --ignoreConfig suppresses it; this test
// locks the exact invocation so the flag cannot be silently dropped.
expect.assertions(2);
const { execute, cleanup, writeFile } = await setup();
await writeFile('input.ts', VALID_TS);
await writeFile('tsconfig.json', JSON.stringify({ compilerOptions: { strict: true } }));

const { code, stdout } = await execute(
'node',
'./bin/fastedge-build.js input.ts dist/output.wasm',
);

expect(code).toBe(0);
expect(stdout[0]).toContain('Build success!!');
await cleanup();
},
INSTALL_AND_BUILD_TIMEOUT,
);

it(
'should reject a TypeScript entrypoint with a type error',
async () => {
Expand Down
7 changes: 7 additions & 0 deletions src/utils/syntax-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ function containsTypeScriptSyntaxErrors(tsInput: string, tsConfigPath?: string):
// TS infers from `--target esnext` is es2015, which rejects `import.meta`
// with TS1343 even though it is valid ESM that the runtime supports.
// `esnext` matches how input is actually consumed: esbuild bundles ESM.

// TS 6+ errors with TS5112 when a file is passed on the command line and a
// tsconfig.json exists in the CWD. We control all flags explicitly here, so
// ignoring any ambient tsconfig is correct.
const ignoreConfig = typescript.major >= 6 ? ['--ignoreConfig'] : [];

const defaultTscBuildFlags = [
'--noEmit',
'--skipLibCheck',
Expand All @@ -138,6 +144,7 @@ function containsTypeScriptSyntaxErrors(tsInput: string, tsConfigPath?: string):
'esnext',
'--moduleResolution',
moduleResolution,
...ignoreConfig,
...includeFastEdgeTypes,
tsInput,
];
Expand Down
Loading