Skip to content

Commit 9175a3c

Browse files
committed
Merge branch 'main' of github.com:c0sta/TypeScript into fix/15506
2 parents 875169e + 63babdf commit 9175a3c

File tree

147 files changed

+7215
-709
lines changed

Some content is hidden

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

147 files changed

+7215
-709
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
49+
uses: github/codeql-action/init@c0d1daa7f7e14667747d73a7dbbe8c074bc8bfe2 # v2.22.9
5050
with:
5151
config-file: ./.github/codeql/codeql-configuration.yml
5252
# Override language selection by uncommenting this and choosing your languages
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below).
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
59+
uses: github/codeql-action/autobuild@c0d1daa7f7e14667747d73a7dbbe8c074bc8bfe2 # v2.22.9
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,4 +70,4 @@ jobs:
7070
# make release
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
73+
uses: github/codeql-action/analyze@c0d1daa7f7e14667747d73a7dbbe8c074bc8bfe2 # v2.22.9

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the results to GitHub's code scanning dashboard.
5757
- name: 'Upload to code-scanning'
58-
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
58+
uses: github/codeql-action/upload-sarif@c0d1daa7f7e14667747d73a7dbbe8c074bc8bfe2 # v2.22.9
5959
with:
6060
sarif_file: results.sarif

package-lock.json

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"playwright": "^1.38.0",
7979
"source-map-support": "^0.5.21",
8080
"tslib": "^2.5.0",
81-
"typescript": "^5.3.2",
81+
"typescript": "5.4.0-dev.20231206",
8282
"which": "^2.0.2"
8383
},
8484
"overrides": {
@@ -91,7 +91,6 @@
9191
"build:compiler": "hereby local",
9292
"build:tests": "hereby tests",
9393
"build:tests:notypecheck": "hereby tests --no-typecheck",
94-
"start": "node lib/tsc",
9594
"clean": "hereby clean",
9695
"gulp": "hereby",
9796
"lint": "hereby lint",

src/compiler/checker.ts

Lines changed: 82 additions & 49 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
CommandLineOptionOfListType,
1616
CompilerOptions,
1717
CompilerOptionsValue,
18+
computedOptions,
1819
ConfigFileSpecs,
1920
containsPath,
2021
convertToRelativePath,
@@ -103,6 +104,7 @@ import {
103104
removeTrailingDirectorySeparator,
104105
returnTrue,
105106
ScriptTarget,
107+
some,
106108
startsWith,
107109
StringLiteral,
108110
SyntaxKind,
@@ -2475,9 +2477,10 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
24752477
),
24762478
f => getRelativePathFromFile(getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName),
24772479
);
2478-
const optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
2480+
const pathOptions = { configFilePath: getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames };
2481+
const optionMap = serializeCompilerOptions(configParseResult.options, pathOptions);
24792482
const watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
2480-
const config = {
2483+
const config: TSConfig & { watchOptions?: object; } = {
24812484
compilerOptions: {
24822485
...optionMapToObject(optionMap),
24832486
showConfig: undefined,
@@ -2500,6 +2503,19 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
25002503
} : {}),
25012504
compileOnSave: !!configParseResult.compileOnSave ? true : undefined,
25022505
};
2506+
2507+
const providedKeys = new Set(optionMap.keys());
2508+
const impliedCompilerOptions: Record<string, CompilerOptionsValue> = {};
2509+
for (const option in computedOptions) {
2510+
if (!providedKeys.has(option) && some(computedOptions[option as keyof typeof computedOptions].dependencies, dep => providedKeys.has(dep))) {
2511+
const implied = computedOptions[option as keyof typeof computedOptions].computeValue(configParseResult.options);
2512+
const defaultValue = computedOptions[option as keyof typeof computedOptions].computeValue({});
2513+
if (implied !== defaultValue) {
2514+
impliedCompilerOptions[option] = computedOptions[option as keyof typeof computedOptions].computeValue(configParseResult.options);
2515+
}
2516+
}
2517+
}
2518+
assign(config.compilerOptions, optionMapToObject(serializeCompilerOptions(impliedCompilerOptions, pathOptions)));
25032519
return config;
25042520
}
25052521

src/compiler/diagnosticMessages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,6 +3731,18 @@
37313731
"category": "Error",
37323732
"code": 2865
37333733
},
3734+
"Import '{0}' conflicts with global value used in this file, so must be declared with a type-only import when 'isolatedModules' is enabled.": {
3735+
"category": "Error",
3736+
"code": 2866
3737+
},
3738+
"Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`.": {
3739+
"category": "Error",
3740+
"code": 2867
3741+
},
3742+
"Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig.": {
3743+
"category": "Error",
3744+
"code": 2868
3745+
},
37343746

37353747
"Import declaration '{0}' is using private name '{1}'.": {
37363748
"category": "Error",

src/compiler/emitter.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ import {
223223
isGeneratedIdentifier,
224224
isGeneratedPrivateIdentifier,
225225
isIdentifier,
226+
isImportAttributes,
226227
isIncrementalCompilation,
227228
isInJsonFile,
228229
isInternalDeclaration,
@@ -1840,6 +1841,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
18401841
if (hint === EmitHint.IdentifierName) return emitIdentifier(cast(node, isIdentifier));
18411842
if (hint === EmitHint.JsxAttributeValue) return emitLiteral(cast(node, isStringLiteral), /*jsxAttributeEscape*/ true);
18421843
if (hint === EmitHint.MappedTypeParameter) return emitMappedTypeParameter(cast(node, isTypeParameterDeclaration));
1844+
if (hint === EmitHint.ImportTypeNodeAttributes) return emitImportTypeNodeAttributes(cast(node, isImportAttributes));
18431845
if (hint === EmitHint.EmbeddedStatement) {
18441846
Debug.assertNode(node, isEmptyStatement);
18451847
return emitEmptyStatement(/*isEmbeddedStatement*/ true);
@@ -2944,15 +2946,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
29442946
if (node.attributes) {
29452947
writePunctuation(",");
29462948
writeSpace();
2947-
writePunctuation("{");
2948-
writeSpace();
2949-
writeKeyword(node.attributes.token === SyntaxKind.AssertKeyword ? "assert" : "with");
2950-
writePunctuation(":");
2951-
writeSpace();
2952-
const elements = node.attributes.elements;
2953-
emitList(node.attributes, elements, ListFormat.ImportAttributes);
2954-
writeSpace();
2955-
writePunctuation("}");
2949+
pipelineEmit(EmitHint.ImportTypeNodeAttributes, node.attributes);
29562950
}
29572951
writePunctuation(")");
29582952
if (node.qualifier) {
@@ -4077,6 +4071,18 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
40774071
writeTrailingSemicolon();
40784072
}
40794073

4074+
function emitImportTypeNodeAttributes(node: ImportAttributes) {
4075+
writePunctuation("{");
4076+
writeSpace();
4077+
writeKeyword(node.token === SyntaxKind.AssertKeyword ? "assert" : "with");
4078+
writePunctuation(":");
4079+
writeSpace();
4080+
const elements = node.elements;
4081+
emitList(node, elements, ListFormat.ImportAttributes);
4082+
writeSpace();
4083+
writePunctuation("}");
4084+
}
4085+
40804086
function emitImportAttributes(node: ImportAttributes) {
40814087
emitTokenWithComment(node.token, node.pos, writeKeyword, node);
40824088
writeSpace();

src/compiler/factory/nodeFactory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
CaseOrDefaultClause,
4545
cast,
4646
CatchClause,
47+
CharacterCodes,
4748
ClassDeclaration,
4849
ClassElement,
4950
ClassExpression,
@@ -1254,8 +1255,10 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
12541255

12551256
// @api
12561257
function createNumericLiteral(value: string | number, numericLiteralFlags: TokenFlags = TokenFlags.None): NumericLiteral {
1258+
const text = typeof value === "number" ? value + "" : value;
1259+
Debug.assert(text.charCodeAt(0) !== CharacterCodes.minus, "Negative numbers should be created in combination with createPrefixUnaryExpression");
12571260
const node = createBaseDeclaration<NumericLiteral>(SyntaxKind.NumericLiteral);
1258-
node.text = typeof value === "number" ? value + "" : value;
1261+
node.text = text;
12591262
node.numericLiteralFlags = numericLiteralFlags;
12601263
if (numericLiteralFlags & TokenFlags.BinaryOrOctalSpecifier) node.transformFlags |= TransformFlags.ContainsES2015;
12611264
return node;

src/compiler/moduleNameResolver.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import {
8989
removeExtension,
9090
removeFileExtension,
9191
removePrefix,
92+
replaceFirstStar,
9293
ResolutionMode,
9394
ResolvedModuleWithFailedLookupLocations,
9495
ResolvedProjectReference,
@@ -2286,8 +2287,8 @@ function loadEntrypointsFromExportMap(
22862287
/*excludes*/ undefined,
22872288
[
22882289
isDeclarationFileName(target)
2289-
? target.replace("*", "**/*")
2290-
: changeAnyExtension(target.replace("*", "**/*"), getDeclarationEmitExtensionForPath(target)),
2290+
? replaceFirstStar(target, "**/*")
2291+
: changeAnyExtension(replaceFirstStar(target, "**/*"), getDeclarationEmitExtensionForPath(target)),
22912292
],
22922293
).forEach(entry => {
22932294
entrypoints = appendIfUnique(entrypoints, {
@@ -3096,7 +3097,7 @@ function tryLoadModuleUsingPaths(extensions: Extensions, moduleName: string, bas
30963097
trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
30973098
}
30983099
const resolved = forEach(paths[matchedPatternText], subst => {
3099-
const path = matchedStar ? subst.replace("*", matchedStar) : subst;
3100+
const path = matchedStar ? replaceFirstStar(subst, matchedStar) : subst;
31003101
// When baseUrl is not specified, the command line parser resolves relative paths to the config file location.
31013102
const candidate = normalizePath(combinePaths(baseDirectory, path));
31023103
if (state.traceEnabled) {

src/compiler/moduleSpecifiers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import {
9393
removeFileExtension,
9494
removeSuffix,
9595
removeTrailingDirectorySeparator,
96+
replaceFirstStar,
9697
ResolutionMode,
9798
resolvePath,
9899
ScriptKind,
@@ -810,7 +811,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike<rea
810811
) {
811812
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
812813
if (!pathIsRelative(matchedStar)) {
813-
return key.replace("*", matchedStar);
814+
return replaceFirstStar(key, matchedStar);
814815
}
815816
}
816817
}
@@ -864,11 +865,11 @@ function tryGetModuleNameFromExports(options: CompilerOptions, targetFilePath: s
864865
const trailingSlice = pathOrPattern.slice(starPos + 1);
865866
if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
866867
const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
867-
return { moduleFileToTry: packageName.replace("*", starReplacement) };
868+
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
868869
}
869870
if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
870871
const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
871-
return { moduleFileToTry: packageName.replace("*", starReplacement) };
872+
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
872873
}
873874
break;
874875
}

src/compiler/parser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,8 +3845,7 @@ namespace Parser {
38453845
function parseJSDocFunctionType(): JSDocFunctionType | TypeReferenceNode {
38463846
const pos = getNodePos();
38473847
const hasJSDoc = hasPrecedingJSDocComment();
3848-
if (lookAhead(nextTokenIsOpenParen)) {
3849-
nextToken();
3848+
if (tryParse(nextTokenIsOpenParen)) {
38503849
const parameters = parseParameters(SignatureFlags.Type | SignatureFlags.JSDoc);
38513850
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
38523851
return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc);
@@ -9711,8 +9710,9 @@ namespace Parser {
97119710
if (isBracketed) {
97129711
skipWhitespace();
97139712
}
9714-
const name = parseJSDocIdentifierName(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
97159713

9714+
const modifiers = parseModifiers(/*allowDecorators*/ false, /*permitConstAsModifier*/ true);
9715+
const name = parseJSDocIdentifierName(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
97169716
let defaultType: TypeNode | undefined;
97179717
if (isBracketed) {
97189718
skipWhitespace();
@@ -9724,7 +9724,7 @@ namespace Parser {
97249724
if (nodeIsMissing(name)) {
97259725
return undefined;
97269726
}
9727-
return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, /*constraint*/ undefined, defaultType), typeParameterPos);
9727+
return finishNode(factory.createTypeParameterDeclaration(modifiers, name, /*constraint*/ undefined, defaultType), typeParameterPos);
97289728
}
97299729

97309730
function parseTemplateTagTypeParameters() {

0 commit comments

Comments
 (0)