GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge branch 'main' into fix44572 · microsoft/TypeScript@813b04b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • package-lock.json
  • package.json
  • src
    • compiler
      • checker.ts
      • factory
        • utilities.ts
      • moduleNameResolver.ts
      • program.ts
      • sys.ts
      • types.ts
      • utilities.ts
    • harness
      • client.ts
      • fourslashImpl.ts
      • fourslashInterfaceImpl.ts
      • harnessLanguageService.ts
    • lib
      • es5.d.ts
    • loc/lcl
      • chs/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • cht/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • csy/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • deu/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • esn/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • fra/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • ita/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • jpn/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • kor/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • plk/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • ptb/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • rus/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
      • trk/diagnosticMessages
        • diagnosticMessages.generated.json.lcl
    • server
      • project.ts
    • services
      • completions.ts
    • testRunner/unittests
      • moduleResolution.ts
  • tests
    • baselines/reference
      • api
        • tsserverlibrary.d.ts
        • typescript.d.ts
      • intersectionTypeReadonly.errors.txt
      • intersectionTypeReadonly.js
      • intersectionTypeReadonly.symbols
      • intersectionTypeReadonly.types
      • intersectionsAndReadonlyProperties.errors.txt
      • intersectionsAndReadonlyProperties.js
      • intersectionsAndReadonlyProperties.symbols
      • intersectionsAndReadonlyProperties.types
      • jsdocTypeTagCast.errors.txt
      • jsdocTypeTagCast.js
      • jsdocTypeTagCast.symbols
      • jsdocTypeTagCast.types
      • mappedTypeRecursiveInference.types
    • cases
      • compiler
        • intersectionsAndReadonlyProperties.ts
      • conformance
        • jsdoc
          • jsdocTypeTagCast.ts
        • types/intersection
          • intersectionTypeReadonly.ts
      • fourslash
        • completionsEnum.ts
        • fourslash.ts
        • getJavaScriptCompletions22.ts
        • server
          • autoImportSymlinkedJsPackages.ts
          • configurePlugin.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎package-lock.json‎

Copy file name to clipboardExpand all lines: package-lock.json
+178-366Lines changed: 178 additions & 366 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@types/chai": "latest",
3535
"@types/convert-source-map": "latest",
3636
"@types/glob": "latest",
37-
"@types/gulp": "^4.0.5",
37+
"@types/gulp": "^4.0.9",
3838
"@types/gulp-concat": "latest",
3939
"@types/gulp-newer": "latest",
4040
"@types/gulp-rename": "0.0.33",
@@ -57,7 +57,7 @@
5757
"@typescript-eslint/experimental-utils": "^4.28.0",
5858
"@typescript-eslint/parser": "^4.28.0",
5959
"async": "latest",
60-
"azure-devops-node-api": "^10.1.0",
60+
"azure-devops-node-api": "^11.0.1",
6161
"browser-resolve": "^1.11.2",
6262
"browserify": "latest",
6363
"chai": "latest",
@@ -86,12 +86,11 @@
8686
"mocha": "latest",
8787
"mocha-fivemat-progress-reporter": "latest",
8888
"ms": "latest",
89-
"node-fetch": "^2.6.0",
89+
"node-fetch": "^2.6.1",
9090
"plugin-error": "latest",
9191
"pretty-hrtime": "^1.0.3",
9292
"prex": "^0.4.3",
9393
"q": "latest",
94-
"remove-internal": "^2.9.2",
9594
"source-map-support": "latest",
9695
"through2": "latest",
9796
"typescript": "^4.2.3",
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+32-15Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8402,12 +8402,12 @@ namespace ts {
84028402
}
84038403

84048404
function isNullOrUndefined(node: Expression) {
8405-
const expr = skipParentheses(node);
8405+
const expr = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
84068406
return expr.kind === SyntaxKind.NullKeyword || expr.kind === SyntaxKind.Identifier && getResolvedSymbol(expr as Identifier) === undefinedSymbol;
84078407
}
84088408

84098409
function isEmptyArrayLiteral(node: Expression) {
8410-
const expr = skipParentheses(node);
8410+
const expr = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
84118411
return expr.kind === SyntaxKind.ArrayLiteralExpression && (expr as ArrayLiteralExpression).elements.length === 0;
84128412
}
84138413

@@ -11800,7 +11800,7 @@ namespace ts {
1180011800
// Flags we want to propagate to the result if they exist in all source symbols
1180111801
let optionalFlag = isUnion ? SymbolFlags.None : SymbolFlags.Optional;
1180211802
let syntheticFlag = CheckFlags.SyntheticMethod;
11803-
let checkFlags = 0;
11803+
let checkFlags = isUnion ? 0 : CheckFlags.Readonly;
1180411804
let mergedInstantiations = false;
1180511805
for (const current of containingType.types) {
1180611806
const type = getApparentType(current);
@@ -11839,8 +11839,13 @@ namespace ts {
1183911839
}
1184011840
}
1184111841
}
11842-
checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) |
11843-
(!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) |
11842+
if (isUnion && isReadonlySymbol(prop)) {
11843+
checkFlags |= CheckFlags.Readonly;
11844+
}
11845+
else if (!isUnion && !isReadonlySymbol(prop)) {
11846+
checkFlags &= ~CheckFlags.Readonly;
11847+
}
11848+
checkFlags |= (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) |
1184411849
(modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) |
1184511850
(modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) |
1184611851
(modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0);
@@ -22966,7 +22971,7 @@ namespace ts {
2296622971
}
2296722972

2296822973
function isFalseExpression(expr: Expression): boolean {
22969-
const node = skipParentheses(expr);
22974+
const node = skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true);
2297022975
return node.kind === SyntaxKind.FalseKeyword || node.kind === SyntaxKind.BinaryExpression && (
2297122976
(node as BinaryExpression).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken && (isFalseExpression((node as BinaryExpression).left) || isFalseExpression((node as BinaryExpression).right)) ||
2297222977
(node as BinaryExpression).operatorToken.kind === SyntaxKind.BarBarToken && isFalseExpression((node as BinaryExpression).left) && isFalseExpression((node as BinaryExpression).right));
@@ -23288,7 +23293,7 @@ namespace ts {
2328823293
}
2328923294

2329023295
function narrowTypeByAssertion(type: Type, expr: Expression): Type {
23291-
const node = skipParentheses(expr);
23296+
const node = skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true);
2329223297
if (node.kind === SyntaxKind.FalseKeyword) {
2329323298
return unreachableNeverType;
2329423299
}
@@ -25872,7 +25877,9 @@ namespace ts {
2587225877
case SyntaxKind.ParenthesizedExpression: {
2587325878
// Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast.
2587425879
const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined;
25875-
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent as ParenthesizedExpression, contextFlags);
25880+
return !tag ? getContextualType(parent as ParenthesizedExpression, contextFlags) :
25881+
isJSDocTypeTag(tag) && isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent as ParenthesizedExpression) :
25882+
getTypeFromTypeNode(tag.typeExpression.type);
2587625883
}
2587725884
case SyntaxKind.NonNullExpression:
2587825885
return getContextualType(parent as NonNullExpression, contextFlags);
@@ -32855,8 +32862,10 @@ namespace ts {
3285532862
}
3285632863

3285732864
function isTypeAssertion(node: Expression) {
32858-
node = skipParentheses(node);
32859-
return node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression;
32865+
node = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
32866+
return node.kind === SyntaxKind.TypeAssertionExpression ||
32867+
node.kind === SyntaxKind.AsExpression ||
32868+
isJSDocTypeAssertion(node);
3286032869
}
3286132870

3286232871
function checkDeclarationInitializer(declaration: HasExpressionInitializer, contextualType?: Type | undefined) {
@@ -32931,6 +32940,7 @@ namespace ts {
3293132940
function isConstContext(node: Expression): boolean {
3293232941
const parent = node.parent;
3293332942
return isAssertionExpression(parent) && isConstTypeReference(parent.type) ||
32943+
isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) ||
3293432944
(isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) ||
3293532945
(isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
3293632946
}
@@ -33143,7 +33153,14 @@ namespace ts {
3314333153
}
3314433154

3314533155
function getQuickTypeOfExpression(node: Expression) {
33146-
const expr = skipParentheses(node);
33156+
let expr = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
33157+
if (isJSDocTypeAssertion(expr)) {
33158+
const type = getJSDocTypeAssertionType(expr);
33159+
if (!isConstTypeReference(type)) {
33160+
return getTypeFromTypeNode(type);
33161+
}
33162+
}
33163+
expr = skipParentheses(node);
3314733164
// Optimize for the common case of a call to a function with a single non-generic call
3314833165
// signature where we can just fetch the return type without checking the arguments.
3314933166
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
@@ -33230,9 +33247,9 @@ namespace ts {
3323033247
}
3323133248

3323233249
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
33233-
const tag = isInJSFile(node) ? getJSDocTypeTag(node) : undefined;
33234-
if (tag) {
33235-
return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode);
33250+
if (isJSDocTypeAssertion(node)) {
33251+
const type = getJSDocTypeAssertionType(node);
33252+
return checkAssertionWorker(type, type, node.expression, checkMode);
3323633253
}
3323733254
return checkExpression(node.expression, checkMode);
3323833255
}
@@ -36182,7 +36199,7 @@ namespace ts {
3618236199
if (getFalsyFlags(type)) return;
3618336200

3618436201
const location = isBinaryExpression(condExpr) ? condExpr.right : condExpr;
36185-
if (isPropertyAccessExpression(location) && isAssertionExpression(skipParentheses(location.expression))) {
36202+
if (isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) {
3618636203
return;
3618736204
}
3618836205

Collapse file

‎src/compiler/factory/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/factory/utilities.ts
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,24 @@ namespace ts {
416416
node.kind === SyntaxKind.CommaListExpression;
417417
}
418418

419+
export function isJSDocTypeAssertion(node: Node): node is JSDocTypeAssertion {
420+
return isParenthesizedExpression(node)
421+
&& isInJSFile(node)
422+
&& !!getJSDocTypeTag(node);
423+
}
424+
425+
export function getJSDocTypeAssertionType(node: JSDocTypeAssertion) {
426+
const type = getJSDocType(node);
427+
Debug.assertIsDefined(type);
428+
return type;
429+
}
430+
419431
export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All): node is OuterExpression {
420432
switch (node.kind) {
421433
case SyntaxKind.ParenthesizedExpression:
434+
if (kinds & OuterExpressionKinds.ExcludeJSDocTypeAssertion && isJSDocTypeAssertion(node)) {
435+
return false;
436+
}
422437
return (kinds & OuterExpressionKinds.Parentheses) !== 0;
423438
case SyntaxKind.TypeAssertionExpression:
424439
case SyntaxKind.AsExpression:
Collapse file

‎src/compiler/moduleNameResolver.ts‎

Copy file name to clipboardExpand all lines: src/compiler/moduleNameResolver.ts
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ namespace ts {
280280
}
281281
const nodeModulesAtTypes = combinePaths("node_modules", "@types");
282282

283+
function arePathsEqual(path1: string, path2: string, host: ModuleResolutionHost): boolean {
284+
const useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
285+
return comparePaths(path1, path2, !useCaseSensitiveFileNames) === Comparison.EqualTo;
286+
}
287+
283288
/**
284289
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
285290
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
@@ -343,7 +348,7 @@ namespace ts {
343348
resolvedTypeReferenceDirective = {
344349
primary,
345350
resolvedFileName,
346-
originalPath: fileName === resolvedFileName ? undefined : fileName,
351+
originalPath: arePathsEqual(fileName, resolvedFileName, host) ? undefined : fileName,
347352
packageId,
348353
isExternalLibraryImport: pathContainsNodeModules(fileName),
349354
};
@@ -1078,9 +1083,8 @@ namespace ts {
10781083
}
10791084

10801085
/* @internal */
1081-
export function tryResolveJSModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string | undefined {
1082-
const { resolvedModule } = tryResolveJSModuleWorker(moduleName, initialDir, host);
1083-
return resolvedModule && resolvedModule.resolvedFileName;
1086+
export function tryResolveJSModule(moduleName: string, initialDir: string, host: ModuleResolutionHost) {
1087+
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
10841088
}
10851089

10861090
const jsOnlyExtensions = [Extensions.JavaScript];
@@ -1123,7 +1127,7 @@ namespace ts {
11231127
let resolvedValue = resolved.value;
11241128
if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
11251129
const path = realPath(resolvedValue.path, host, traceEnabled);
1126-
const originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
1130+
const originalPath = arePathsEqual(path, resolvedValue.path, host) ? undefined : resolvedValue.path;
11271131
resolvedValue = { ...resolvedValue, path, originalPath };
11281132
}
11291133
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.