Skip to content

Commit c871a27

Browse files
committed
Fix the test case of verbatimModuleSyntax changes
1 parent 1012104 commit c871a27

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

src/compiler/commandLineParser.ts

+3
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
813813
{
814814
name: "verbatimModuleSyntax",
815815
type: "boolean",
816+
affectsEmit: true,
817+
affectsSemanticDiagnostics: true,
818+
affectsBuildInfo: true,
816819
category: Diagnostics.Interop_Constraints,
817820
description: Diagnostics.Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting,
818821
defaultValueDescription: false,

tests/baselines/reference/tscWatch/programUpdates/updates-errors-and-emit-when-verbatimModuleSyntax-changes.js

+43-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,33 @@ Output::
124124
>> Screen clear
125125
[12:00:32 AM] File change detected. Starting incremental compilation...
126126

127-
[[90m12:00:33 AM[0m] Found 0 errors. Watching for file changes.
127+
[96ma.ts[0m:[93m1[0m:[93m1[0m - [91merror[0m[90m TS1287: [0mA top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
128128

129+
1 export class C {}
130+
  ~~~~~~
131+
132+
b.ts:1:9 - error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.
133+
134+
1 import {C} from './a';
135+
   ~
136+
137+
b.ts:2:1 - error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
138+
139+
2 export function f(p: C) { return p; }
140+
  ~~~~~~
141+
142+
[12:00:39 AM] Found 3 errors. Watching for file changes.
143+
144+
145+
146+
//// [/user/username/projects/myproject/a.js] file written with same contents
147+
//// [/user/username/projects/myproject/b.js]
148+
"use strict";
149+
Object.defineProperty(exports, "__esModule", { value: true });
150+
exports.f = void 0;
151+
var a_1 = require("./a");
152+
function f(p) { return p; }
153+
exports.f = f;
129154

130155

131156

@@ -146,6 +171,9 @@ Program files::
146171
/user/username/projects/myproject/b.ts
147172

148173
Semantic diagnostics in builder refreshed for::
174+
/a/lib/lib.d.ts
175+
/user/username/projects/myproject/a.ts
176+
/user/username/projects/myproject/b.ts
149177

150178
No shapes updated in the builder::
151179

@@ -171,12 +199,21 @@ Before running Timeout callback:: count: 1
171199
After running Timeout callback:: count: 0
172200
Output::
173201
>> Screen clear
174-
[[90m12:00:37 AM[0m] File change detected. Starting incremental compilation...
202+
[[90m12:00:43 AM[0m] File change detected. Starting incremental compilation...
175203

176-
[[90m12:00:38 AM[0m] Found 0 errors. Watching for file changes.
204+
[[90m12:00:50 AM[0m] Found 0 errors. Watching for file changes.
177205

178206

179207

208+
//// [/user/username/projects/myproject/a.js] file written with same contents
209+
//// [/user/username/projects/myproject/b.js]
210+
"use strict";
211+
Object.defineProperty(exports, "__esModule", { value: true });
212+
exports.f = void 0;
213+
function f(p) { return p; }
214+
exports.f = f;
215+
216+
180217

181218

182219
Program root files: [
@@ -195,6 +232,9 @@ Program files::
195232
/user/username/projects/myproject/b.ts
196233

197234
Semantic diagnostics in builder refreshed for::
235+
/a/lib/lib.d.ts
236+
/user/username/projects/myproject/a.ts
237+
/user/username/projects/myproject/b.ts
198238

199239
No shapes updated in the builder::
200240

0 commit comments

Comments
 (0)