Skip to content

Commit 859abb6

Browse files
committed
Merge branch 'mjscjs-support' into imports-exports-selfs
2 parents 093002c + 5bf44ac commit 859abb6

File tree

294 files changed

+9386
-7386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+9386
-7386
lines changed

Gulpfile.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,6 @@ task("watch-local").flags = {
437437
" --built": "Compile using the built version of the compiler."
438438
};
439439

440-
const generateCodeCoverage = () => exec("istanbul", ["cover", "node_modules/mocha/bin/_mocha", "--", "-R", "min", "-t", "" + cmdLineOptions.testTimeout, "built/local/run.js"]);
441-
task("generate-code-coverage", series(preBuild, buildTests, generateCodeCoverage));
442-
task("generate-code-coverage").description = "Generates code coverage data via istanbul";
443-
444440
const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
445441
preTest.displayName = "preTest";
446442

lib/lib.es2021.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ and limitations under the License.
2222
/// <reference lib="es2021.promise" />
2323
/// <reference lib="es2021.string" />
2424
/// <reference lib="es2021.weakref" />
25+
/// <reference lib="es2021.intl" />

package-lock.json

Lines changed: 48 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"gulp-newer": "latest",
8080
"gulp-rename": "latest",
8181
"gulp-sourcemaps": "latest",
82-
"istanbul": "latest",
8382
"merge2": "latest",
8483
"minimist": "latest",
8584
"mkdirp": "latest",

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ namespace ts {
33883388

33893389
function bindTypeParameter(node: TypeParameterDeclaration) {
33903390
if (isJSDocTemplateTag(node.parent)) {
3391-
const container = find((node.parent.parent as JSDoc).tags!, isJSDocTypeAlias) || getHostSignatureFromJSDoc(node.parent); // TODO: GH#18217
3391+
const container = getEffectiveContainerForJSDocTemplateTag(node.parent);
33923392
if (container) {
33933393
if (!container.locals) {
33943394
container.locals = createSymbolTable();

src/compiler/checker.ts

Lines changed: 425 additions & 149 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace ts {
7171
["es2021.promise", "lib.es2021.promise.d.ts"],
7272
["es2021.string", "lib.es2021.string.d.ts"],
7373
["es2021.weakref", "lib.es2021.weakref.d.ts"],
74+
["es2021.intl", "lib.es2021.intl.d.ts"],
7475
["esnext.array", "lib.es2019.array.d.ts"],
7576
["esnext.symbol", "lib.es2019.symbol.d.ts"],
7677
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
@@ -572,7 +573,7 @@ namespace ts {
572573
type: new Map(getEntries({
573574
remove: ImportsNotUsedAsValues.Remove,
574575
preserve: ImportsNotUsedAsValues.Preserve,
575-
error: ImportsNotUsedAsValues.Error
576+
error: ImportsNotUsedAsValues.Error,
576577
})),
577578
affectsEmit: true,
578579
affectsSemanticDiagnostics: true,
@@ -1170,6 +1171,14 @@ namespace ts {
11701171
description: Diagnostics.Emit_ECMAScript_standard_compliant_class_fields,
11711172
defaultValueDescription: Diagnostics.true_for_ES2022_and_above_including_ESNext
11721173
},
1174+
{
1175+
name: "preserveValueImports",
1176+
type: "boolean",
1177+
affectsEmit: true,
1178+
category: Diagnostics.Emit,
1179+
description: Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
1180+
},
1181+
11731182
{
11741183
name: "keyofStringsOnly",
11751184
type: "boolean",
@@ -2854,6 +2863,7 @@ namespace ts {
28542863
let typeAcquisition: TypeAcquisition | undefined, typingOptionstypeAcquisition: TypeAcquisition | undefined;
28552864
let watchOptions: WatchOptions | undefined;
28562865
let extendedConfigPath: string | undefined;
2866+
let rootCompilerOptions: PropertyName[] | undefined;
28572867

28582868
const optionsIterator: JsonConversionNotifier = {
28592869
onSetValidOptionKeyValueInParent(parentOption: string, option: CommandLineOption, value: CompilerOptionsValue) {
@@ -2896,6 +2906,9 @@ namespace ts {
28962906
if (key === "excludes") {
28972907
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, keyNode, Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
28982908
}
2909+
if (find(commandOptionsWithoutBuild, (opt) => opt.name === key)) {
2910+
rootCompilerOptions = append(rootCompilerOptions, keyNode);
2911+
}
28992912
}
29002913
};
29012914
const json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator);
@@ -2915,6 +2928,10 @@ namespace ts {
29152928
}
29162929
}
29172930

2931+
if (rootCompilerOptions && json && json.compilerOptions === undefined) {
2932+
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, rootCompilerOptions[0], Diagnostics._0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file, getTextOfPropertyName(rootCompilerOptions[0]) as string));
2933+
}
2934+
29182935
return { raw: json, options, watchOptions, typeAcquisition, extendedConfigPath };
29192936
}
29202937

src/compiler/diagnosticMessages.json

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,13 +1372,30 @@
13721372
"category": "Error",
13731373
"code": 1443
13741374
},
1375-
"The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": {
1375+
"'{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.": {
13761376
"category": "Error",
13771377
"code": 1444
13781378
},
1379+
"'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.": {
1380+
"category": "Error",
1381+
"code": 1446
1382+
},
1383+
"'{0}' resolves to a type-only declaration and must be re-exported using a type-only re-export when 'isolatedModules' is enabled.": {
1384+
"category": "Error",
1385+
"code": 1448
1386+
},
1387+
"Preserve unused imported values in the JavaScript output that would otherwise be removed.": {
1388+
"category": "Message",
1389+
"code": 1449
1390+
},
1391+
1392+
"The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": {
1393+
"category": "Error",
1394+
"code": 1470
1395+
},
13791396
"Module '{0}' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead.": {
13801397
"category": "Error",
1381-
"code": 1445
1398+
"code": 1471
13821399
},
13831400

13841401
"The types of '{0}' are incompatible between these types.": {
@@ -3292,6 +3309,10 @@
32923309
"category": "Error",
32933310
"code": 2819
32943311
},
3312+
"Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?": {
3313+
"category": "Error",
3314+
"code": 2820
3315+
},
32953316

32963317
"Import declaration '{0}' is using private name '{1}'.": {
32973318
"category": "Error",
@@ -3918,6 +3939,10 @@
39183939
"category": "Error",
39193940
"code": 5094
39203941
},
3942+
"Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later.": {
3943+
"category": "Error",
3944+
"code": 5095
3945+
},
39213946

39223947
"Generates a sourcemap for each corresponding '.d.ts' file.": {
39233948
"category": "Message",
@@ -3931,10 +3956,6 @@
39313956
"category": "Message",
39323957
"code": 6002
39333958
},
3934-
"Specify the location where debugger should locate map files instead of generated locations.": {
3935-
"category": "Message",
3936-
"code": 6003
3937-
},
39383959
"Specify the location where debugger should locate TypeScript files instead of source locations.": {
39393960
"category": "Message",
39403961
"code": 6004
@@ -4501,10 +4522,6 @@
45014522
"category": "Message",
45024523
"code": 6163
45034524
},
4504-
"Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.": {
4505-
"category": "Message",
4506-
"code": 6164
4507-
},
45084525
"Do not truncate error messages.": {
45094526
"category": "Message",
45104527
"code": 6165
@@ -4842,6 +4859,10 @@
48424859
"category": "Message",
48434860
"code": 6257
48444861
},
4862+
"'{0}' should be set inside the 'compilerOptions' object of the config json file": {
4863+
"category": "Error",
4864+
"code": 6258
4865+
},
48454866

48464867
"Directory '{0}' has no containing package.json scope. Imports will not resolve.": {
48474868
"category": "Message",

src/compiler/factory/nodeFactory.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4939,14 +4939,16 @@ namespace ts {
49394939
}
49404940

49414941
// @api
4942-
function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block) {
4942+
function createCatchClause(variableDeclaration: string | BindingName | VariableDeclaration | undefined, block: Block) {
49434943
const node = createBaseNode<CatchClause>(SyntaxKind.CatchClause);
4944-
variableDeclaration = !isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(
4945-
variableDeclaration,
4946-
/*exclamationToken*/ undefined,
4947-
/*type*/ undefined,
4948-
/*initializer*/ undefined
4949-
);
4944+
if (typeof variableDeclaration === "string" || variableDeclaration && !isVariableDeclaration(variableDeclaration)) {
4945+
variableDeclaration = createVariableDeclaration(
4946+
variableDeclaration,
4947+
/*exclamationToken*/ undefined,
4948+
/*type*/ undefined,
4949+
/*initializer*/ undefined
4950+
);
4951+
}
49504952
node.variableDeclaration = variableDeclaration;
49514953
node.block = block;
49524954
node.transformFlags |=

src/compiler/parser.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8441,11 +8441,24 @@ namespace ts {
84418441

84428442
function parseTemplateTagTypeParameter() {
84438443
const typeParameterPos = getNodePos();
8444+
const isBracketed = parseOptionalJsdoc(SyntaxKind.OpenBracketToken);
8445+
if (isBracketed) {
8446+
skipWhitespace();
8447+
}
84448448
const name = parseJSDocIdentifierName(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
8449+
8450+
let defaultType: TypeNode | undefined;
8451+
if (isBracketed) {
8452+
skipWhitespace();
8453+
parseExpected(SyntaxKind.EqualsToken);
8454+
defaultType = doInsideOfContext(NodeFlags.JSDoc, parseJSDocType);
8455+
parseExpected(SyntaxKind.CloseBracketToken);
8456+
}
8457+
84458458
if (nodeIsMissing(name)) {
84468459
return undefined;
84478460
}
8448-
return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos);
8461+
return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, defaultType), typeParameterPos);
84498462
}
84508463

84518464
function parseTemplateTagTypeParameters() {

0 commit comments

Comments
 (0)