Skip to content

Commit 92ec29e

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/errors-from-requests-with-blocked-inference
# Conflicts: # src/compiler/checker.ts
2 parents dbd8664 + 1513649 commit 92ec29e

File tree

102 files changed

+5436
-522
lines changed

Some content is hidden

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

102 files changed

+5436
-522
lines changed

package-lock.json

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

src/compiler/builder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
generateDjb2Hash,
4646
getDirectoryPath,
4747
getEmitDeclarations,
48+
getIsolatedModules,
4849
getNormalizedAbsolutePath,
4950
getOptionsNameMap,
5051
getOwnKeys,
@@ -763,7 +764,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(
763764

764765
// Since isolated modules dont change js files, files affected by change in signature is itself
765766
// But we need to cleanup semantic diagnostics and queue dts emit for affected files
766-
if (state.compilerOptions.isolatedModules) {
767+
if (getIsolatedModules(state.compilerOptions)) {
767768
const seenFileNamesMap = new Map<Path, true>();
768769
seenFileNamesMap.set(affectedFile.resolvedPath, true);
769770
const queue = BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);

src/compiler/builderState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ExportedModulesFromDeclarationEmit,
1010
GetCanonicalFileName,
1111
getDirectoryPath,
12+
getIsolatedModules,
1213
getSourceFileOfNode,
1314
HostForComputeHash,
1415
isDeclarationFileName,
@@ -635,7 +636,7 @@ export namespace BuilderState {
635636
}
636637

637638
const compilerOptions = programOfThisState.getCompilerOptions();
638-
if (compilerOptions && (compilerOptions.isolatedModules || outFile(compilerOptions))) {
639+
if (compilerOptions && (getIsolatedModules(compilerOptions) || outFile(compilerOptions))) {
639640
return [sourceFileWithUpdatedShape];
640641
}
641642

src/compiler/checker.ts

Lines changed: 150 additions & 75 deletions
Large diffs are not rendered by default.

src/compiler/parser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2684,7 +2684,6 @@ namespace Parser {
26842684
return canFollowExportModifier();
26852685
case SyntaxKind.DefaultKeyword:
26862686
return nextTokenCanFollowDefaultKeyword();
2687-
case SyntaxKind.AccessorKeyword:
26882687
case SyntaxKind.StaticKeyword:
26892688
case SyntaxKind.GetKeyword:
26902689
case SyntaxKind.SetKeyword:

src/compiler/program.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ import {
118118
getEmitScriptTarget,
119119
getErrorSpanForNode,
120120
getExternalModuleName,
121+
getIsolatedModules,
121122
getJSXImplicitImportBase,
122123
getJSXRuntimeImport,
123124
getLineAndCharacterOfPosition,
@@ -3186,7 +3187,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
31863187

31873188
// If we are importing helpers, we need to add a synthetic reference to resolve the
31883189
// helpers library.
3189-
if ((options.isolatedModules || isExternalModuleFile)
3190+
if ((getIsolatedModules(options) || isExternalModuleFile)
31903191
&& !file.isDeclarationFile) {
31913192
if (options.importHelpers) {
31923193
// synthesize 'import "tslib"' declaration
@@ -3992,13 +3993,13 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
39923993
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "exactOptionalPropertyTypes", "strictNullChecks");
39933994
}
39943995

3995-
if (options.isolatedModules) {
3996+
if (options.isolatedModules || options.verbatimModuleSyntax) {
39963997
if (options.out) {
3997-
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
3998+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", options.verbatimModuleSyntax ? "verbatimModuleSyntax" : "isolatedModules");
39983999
}
39994000

40004001
if (options.outFile) {
4001-
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
4002+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", options.verbatimModuleSyntax ? "verbatimModuleSyntax" : "isolatedModules");
40024003
}
40034004
}
40044005

src/compiler/transformers/module/esnextAnd2015.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getEmitModuleKind,
1717
getEmitScriptTarget,
1818
getExternalModuleNameLiteral,
19+
getIsolatedModules,
1920
hasSyntacticModifier,
2021
Identifier,
2122
idText,
@@ -76,7 +77,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
7677
return node;
7778
}
7879

79-
if (isExternalModule(node) || compilerOptions.isolatedModules) {
80+
if (isExternalModule(node) || getIsolatedModules(compilerOptions)) {
8081
currentSourceFile = node;
8182
importRequireStatements = undefined;
8283
let result = updateExternalModule(node);
@@ -286,7 +287,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
286287
*/
287288
function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void {
288289
if (isSourceFile(node)) {
289-
if ((isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
290+
if ((isExternalModule(node) || getIsolatedModules(compilerOptions)) && compilerOptions.importHelpers) {
290291
helperNameSubstitutions = new Map<string, Identifier>();
291292
}
292293
previousOnEmitNode(hint, node, emitCallback);

src/compiler/transformers/ts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
getEmitScriptTarget,
5555
getFirstConstructorWithBody,
5656
getInitializedVariables,
57+
getIsolatedModules,
5758
getOriginalNode,
5859
getParseTreeNode,
5960
getProperties,
@@ -2706,7 +2707,7 @@ export function transformTypeScript(context: TransformationContext) {
27062707
}
27072708

27082709
function tryGetConstEnumValue(node: Node): string | number | undefined {
2709-
if (compilerOptions.isolatedModules) {
2710+
if (getIsolatedModules(compilerOptions)) {
27102711
return undefined;
27112712
}
27122713

src/compiler/types.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5997,6 +5997,7 @@ export interface NodeLinks {
59975997
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
59985998
serializedTypes?: Map<string, SerializedTypeEntry>; // Collection of types serialized at this location
59995999
decoratorSignature?: Signature; // Signature for decorator as if invoked by the runtime.
6000+
parameterInitializerContainsUndefined?: boolean; // True if this is a parameter declaration whose type annotation contains "undefined".
60006001
}
60016002

60026003
/** @internal */
@@ -6042,7 +6043,8 @@ export const enum TypeFlags {
60426043
/** @internal */
60436044
Nullable = Undefined | Null,
60446045
Literal = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral,
6045-
Unit = Literal | UniqueESSymbol | Nullable,
6046+
Unit = Enum | Literal | UniqueESSymbol | Nullable,
6047+
Freshable = Enum | Literal,
60466048
StringOrNumberLiteral = StringLiteral | NumberLiteral,
60476049
/** @internal */
60486050
StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol,
@@ -6052,7 +6054,7 @@ export const enum TypeFlags {
60526054
/** @internal */
60536055
Intrinsic = Any | Unknown | String | Number | BigInt | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
60546056
/** @internal */
6055-
Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol,
6057+
Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol | TemplateLiteral,
60566058
StringLike = String | StringLiteral | TemplateLiteral | StringMapping,
60576059
NumberLike = Number | NumberLiteral | Enum,
60586060
BigIntLike = BigInt | BigIntLiteral,
@@ -6136,22 +6138,20 @@ export interface NullableType extends IntrinsicType {
61366138
objectFlags: ObjectFlags;
61376139
}
61386140

6139-
/** @internal */
6140-
export interface FreshableIntrinsicType extends IntrinsicType {
6141-
freshType: IntrinsicType; // Fresh version of type
6142-
regularType: IntrinsicType; // Regular version of type
6141+
export interface FreshableType extends Type {
6142+
freshType: FreshableType; // Fresh version of type
6143+
regularType: FreshableType; // Regular version of type
61436144
}
61446145

61456146
/** @internal */
6146-
export type FreshableType = LiteralType | FreshableIntrinsicType;
6147+
export interface FreshableIntrinsicType extends FreshableType, IntrinsicType {
6148+
}
61476149

61486150
// String literal types (TypeFlags.StringLiteral)
61496151
// Numeric literal types (TypeFlags.NumberLiteral)
61506152
// BigInt literal types (TypeFlags.BigIntLiteral)
6151-
export interface LiteralType extends Type {
6153+
export interface LiteralType extends FreshableType {
61526154
value: string | number | PseudoBigInt; // Value of literal
6153-
freshType: LiteralType; // Fresh version of type
6154-
regularType: LiteralType; // Regular version of type
61556155
}
61566156

61576157
// Unique symbol types (TypeFlags.UniqueESSymbol)
@@ -6173,7 +6173,7 @@ export interface BigIntLiteralType extends LiteralType {
61736173
}
61746174

61756175
// Enum types (TypeFlags.Enum)
6176-
export interface EnumType extends Type {
6176+
export interface EnumType extends FreshableType {
61776177
}
61786178

61796179
// Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags

src/compiler/utilities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ function isCommonJSContainingModuleKind(kind: ModuleKind) {
17811781

17821782
/** @internal */
17831783
export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) {
1784-
return isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
1784+
return isExternalModule(node) || getIsolatedModules(compilerOptions) || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
17851785
}
17861786

17871787
/**
@@ -1812,7 +1812,7 @@ export function isEffectiveStrictModeSourceFile(node: SourceFile, compilerOption
18121812
if (startsWithUseStrict(node.statements)) {
18131813
return true;
18141814
}
1815-
if (isExternalModule(node) || compilerOptions.isolatedModules) {
1815+
if (isExternalModule(node) || getIsolatedModules(compilerOptions)) {
18161816
// ECMAScript Modules are always strict.
18171817
if (getEmitModuleKind(compilerOptions) >= ModuleKind.ES2015) {
18181818
return true;
@@ -8443,7 +8443,7 @@ export function getEmitDeclarations(compilerOptions: CompilerOptions): boolean {
84438443

84448444
/** @internal */
84458445
export function shouldPreserveConstEnums(compilerOptions: CompilerOptions): boolean {
8446-
return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules);
8446+
return !!(compilerOptions.preserveConstEnums || getIsolatedModules(compilerOptions));
84478447
}
84488448

84498449
/** @internal */

0 commit comments

Comments
 (0)