@typescript-deploys/pr-build 5.3.0-pr-55567-5 → 5.3.0-pr-55887-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -4839,11 +4839,12 @@ var sys = (() => {
4839
4839
  let activeSession;
4840
4840
  let profilePath = "./profile.cpuprofile";
4841
4841
  const Buffer = require("buffer").Buffer;
4842
- const isWindows = process.platform === "win32";
4842
+ const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4843
+ const platform = _os.platform();
4843
4844
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
4844
- const fsRealpath = !!_fs.realpathSync.native ? isWindows ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4845
+ const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4845
4846
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
4846
- const fsSupportsRecursiveFsWatch = isWindows || process.platform === "darwin";
4847
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
4847
4848
  const getCurrentDirectory = memoize(() => process.cwd());
4848
4849
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
4849
4850
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -4862,7 +4863,7 @@ var sys = (() => {
4862
4863
  tscWatchFile: process.env.TSC_WATCHFILE,
4863
4864
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
4864
4865
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4865
- inodeWatching: !isWindows,
4866
+ inodeWatching: isLinuxOrMacOs,
4866
4867
  sysLog
4867
4868
  });
4868
4869
  const nodeSystem = {
@@ -5047,7 +5048,7 @@ var sys = (() => {
5047
5048
  return Buffer.from && Buffer.from !== Int8Array.from ? Buffer.from(input, encoding) : new Buffer(input, encoding);
5048
5049
  }
5049
5050
  function isFileSystemCaseSensitive() {
5050
- if (isWindows) {
5051
+ if (platform === "win32" || platform === "win64") {
5051
5052
  return false;
5052
5053
  }
5053
5054
  return !fileExists(swapCase(__filename));
@@ -16008,6 +16009,7 @@ function Symbol4(flags, name) {
16008
16009
  this.exportSymbol = void 0;
16009
16010
  this.constEnumOnlyModule = void 0;
16010
16011
  this.isReferenced = void 0;
16012
+ this.isInitialized = void 0;
16011
16013
  this.isAssigned = void 0;
16012
16014
  this.links = void 0;
16013
16015
  }
@@ -43523,11 +43525,16 @@ function createTypeChecker(host) {
43523
43525
  checkSourceFileWithEagerDiagnostics(file);
43524
43526
  Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
43525
43527
  diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
43526
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag2) => {
43527
- if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
43528
- (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
43529
- }
43530
- });
43528
+ checkUnusedOrUninitializedIdentifiers(
43529
+ getPotentiallyUnusedOrUninitializedIdentifiers(file),
43530
+ (containingNode, kind, diag2) => {
43531
+ if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
43532
+ (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
43533
+ }
43534
+ },
43535
+ /*checkUnused*/
43536
+ true
43537
+ );
43531
43538
  return diagnostics2 || emptyArray;
43532
43539
  } finally {
43533
43540
  cancellationToken = void 0;
@@ -44024,7 +44031,7 @@ function createTypeChecker(host) {
44024
44031
  var deferredGlobalClassAccessorDecoratorTargetType;
44025
44032
  var deferredGlobalClassAccessorDecoratorResultType;
44026
44033
  var deferredGlobalClassFieldDecoratorContextType;
44027
- var allPotentiallyUnusedIdentifiers = /* @__PURE__ */ new Map();
44034
+ var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
44028
44035
  var flowLoopStart = 0;
44029
44036
  var flowLoopCount = 0;
44030
44037
  var sharedFlowCount = 0;
@@ -44735,10 +44742,10 @@ function createTypeChecker(host) {
44735
44742
  function isConstAssertion(location) {
44736
44743
  return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
44737
44744
  }
44738
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
44739
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
44745
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
44746
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol);
44740
44747
  }
44741
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
44748
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
44742
44749
  var _a, _b, _c;
44743
44750
  const originalLocation = location;
44744
44751
  let result;
@@ -44964,6 +44971,9 @@ function createTypeChecker(host) {
44964
44971
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
44965
44972
  result.isReferenced |= meaning;
44966
44973
  }
44974
+ if (isWritten && result) {
44975
+ result.isInitialized = true;
44976
+ }
44967
44977
  if (!result) {
44968
44978
  if (lastLocation) {
44969
44979
  Debug.assertNode(lastLocation, isSourceFile);
@@ -64471,7 +64481,10 @@ function createTypeChecker(host) {
64471
64481
  node,
64472
64482
  !isWriteOnlyAccess(node),
64473
64483
  /*excludeGlobals*/
64474
- false
64484
+ false,
64485
+ /*getSpellingSuggestions*/
64486
+ void 0,
64487
+ isWriteAccess(node)
64475
64488
  ) || unknownSymbol;
64476
64489
  }
64477
64490
  return links.resolvedSymbol;
@@ -69905,6 +69918,8 @@ function createTypeChecker(host) {
69905
69918
  false,
69906
69919
  /*getSpellingSuggestions*/
69907
69920
  true,
69921
+ /*isWritten*/
69922
+ false,
69908
69923
  (symbols, name, meaning2) => {
69909
69924
  Debug.assertEqual(outerName, name, "name should equal outerName");
69910
69925
  const symbol = getSymbol(symbols, name, meaning2);
@@ -75359,7 +75374,7 @@ function createTypeChecker(host) {
75359
75374
  }
75360
75375
  }
75361
75376
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
75362
- registerForUnusedIdentifiersCheck(node);
75377
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
75363
75378
  }
75364
75379
  }
75365
75380
  }
@@ -75904,7 +75919,7 @@ function createTypeChecker(host) {
75904
75919
  }
75905
75920
  }
75906
75921
  }
75907
- registerForUnusedIdentifiersCheck(node);
75922
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
75908
75923
  }
75909
75924
  function checkTemplateLiteralType(node) {
75910
75925
  for (const span of node.templateSpans) {
@@ -76890,25 +76905,27 @@ function createTypeChecker(host) {
76890
76905
  }
76891
76906
  }
76892
76907
  }
76893
- function registerForUnusedIdentifiersCheck(node) {
76894
- addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
76895
- function registerForUnusedIdentifiersCheckDiagnostics() {
76908
+ function registerForUnusedOrUninitializedIdentifiersCheck(node) {
76909
+ addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
76910
+ function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
76896
76911
  const sourceFile = getSourceFileOfNode(node);
76897
- let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
76898
- if (!potentiallyUnusedIdentifiers) {
76899
- potentiallyUnusedIdentifiers = [];
76900
- allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
76912
+ let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
76913
+ if (!potentiallyUnusedOrUninitializedIdentifiers) {
76914
+ potentiallyUnusedOrUninitializedIdentifiers = [];
76915
+ allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
76901
76916
  }
76902
- potentiallyUnusedIdentifiers.push(node);
76917
+ potentiallyUnusedOrUninitializedIdentifiers.push(node);
76903
76918
  }
76904
76919
  }
76905
- function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
76920
+ function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
76906
76921
  for (const node of potentiallyUnusedIdentifiers) {
76907
76922
  switch (node.kind) {
76908
76923
  case 263 /* ClassDeclaration */:
76909
76924
  case 231 /* ClassExpression */:
76910
- checkUnusedClassMembers(node, addDiagnostic);
76911
- checkUnusedTypeParameters(node, addDiagnostic);
76925
+ if (checkUnused) {
76926
+ checkUnusedClassMembers(node, addDiagnostic);
76927
+ checkUnusedTypeParameters(node, addDiagnostic);
76928
+ }
76912
76929
  break;
76913
76930
  case 312 /* SourceFile */:
76914
76931
  case 267 /* ModuleDeclaration */:
@@ -76917,7 +76934,12 @@ function createTypeChecker(host) {
76917
76934
  case 248 /* ForStatement */:
76918
76935
  case 249 /* ForInStatement */:
76919
76936
  case 250 /* ForOfStatement */:
76920
- checkUnusedLocalsAndParameters(node, addDiagnostic);
76937
+ if (checkUnused) {
76938
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
76939
+ }
76940
+ if (checkUninitialized) {
76941
+ checkUninitializedLocals(node);
76942
+ }
76921
76943
  break;
76922
76944
  case 176 /* Constructor */:
76923
76945
  case 218 /* FunctionExpression */:
@@ -76926,10 +76948,15 @@ function createTypeChecker(host) {
76926
76948
  case 174 /* MethodDeclaration */:
76927
76949
  case 177 /* GetAccessor */:
76928
76950
  case 178 /* SetAccessor */:
76929
- if (node.body) {
76930
- checkUnusedLocalsAndParameters(node, addDiagnostic);
76951
+ if (checkUnused) {
76952
+ if (node.body) {
76953
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
76954
+ }
76955
+ checkUnusedTypeParameters(node, addDiagnostic);
76956
+ }
76957
+ if (checkUninitialized) {
76958
+ checkUninitializedLocals(node);
76931
76959
  }
76932
- checkUnusedTypeParameters(node, addDiagnostic);
76933
76960
  break;
76934
76961
  case 173 /* MethodSignature */:
76935
76962
  case 179 /* CallSignature */:
@@ -76938,10 +76965,14 @@ function createTypeChecker(host) {
76938
76965
  case 185 /* ConstructorType */:
76939
76966
  case 265 /* TypeAliasDeclaration */:
76940
76967
  case 264 /* InterfaceDeclaration */:
76941
- checkUnusedTypeParameters(node, addDiagnostic);
76968
+ if (checkUnused) {
76969
+ checkUnusedTypeParameters(node, addDiagnostic);
76970
+ }
76942
76971
  break;
76943
76972
  case 195 /* InferType */:
76944
- checkUnusedInferTypeParameter(node, addDiagnostic);
76973
+ if (checkUnused) {
76974
+ checkUnusedInferTypeParameter(node, addDiagnostic);
76975
+ }
76945
76976
  break;
76946
76977
  default:
76947
76978
  Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
@@ -77131,6 +77162,26 @@ function createTypeChecker(host) {
77131
77162
  }
77132
77163
  });
77133
77164
  }
77165
+ function checkUninitializedLocals(nodeWithLocals) {
77166
+ nodeWithLocals.locals.forEach((local) => {
77167
+ if (!(local.flags & 3 /* Variable */) || local.isInitialized || !local.isReferenced) {
77168
+ return;
77169
+ }
77170
+ const declaration = local.valueDeclaration;
77171
+ if (!declaration) {
77172
+ return;
77173
+ }
77174
+ if (isVariableDeclaration(declaration)) {
77175
+ if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
77176
+ return;
77177
+ }
77178
+ const type = getTypeFromTypeNode(declaration.type);
77179
+ if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
77180
+ error(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
77181
+ }
77182
+ }
77183
+ });
77184
+ }
77134
77185
  function checkPotentialUncheckedRenamedBindingElementsInTypes() {
77135
77186
  var _a;
77136
77187
  for (const node of potentialUnusedRenamedBindingElementsInTypes) {
@@ -77177,7 +77228,7 @@ function createTypeChecker(host) {
77177
77228
  forEach(node.statements, checkSourceElement);
77178
77229
  }
77179
77230
  if (node.locals) {
77180
- registerForUnusedIdentifiersCheck(node);
77231
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
77181
77232
  }
77182
77233
  }
77183
77234
  function checkCollisionWithArgumentsInGeneratedCode(node) {
@@ -77727,7 +77778,7 @@ function createTypeChecker(host) {
77727
77778
  checkExpression(node.incrementor);
77728
77779
  checkSourceElement(node.statement);
77729
77780
  if (node.locals) {
77730
- registerForUnusedIdentifiersCheck(node);
77781
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
77731
77782
  }
77732
77783
  }
77733
77784
  function checkForOfStatement(node) {
@@ -77766,7 +77817,7 @@ function createTypeChecker(host) {
77766
77817
  }
77767
77818
  checkSourceElement(node.statement);
77768
77819
  if (node.locals) {
77769
- registerForUnusedIdentifiersCheck(node);
77820
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
77770
77821
  }
77771
77822
  }
77772
77823
  function checkForInStatement(node) {
@@ -77798,7 +77849,7 @@ function createTypeChecker(host) {
77798
77849
  }
77799
77850
  checkSourceElement(node.statement);
77800
77851
  if (node.locals) {
77801
- registerForUnusedIdentifiersCheck(node);
77852
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
77802
77853
  }
77803
77854
  }
77804
77855
  function checkRightHandSideOfForOf(statement) {
@@ -78530,7 +78581,7 @@ function createTypeChecker(host) {
78530
78581
  }
78531
78582
  });
78532
78583
  if (node.caseBlock.locals) {
78533
- registerForUnusedIdentifiersCheck(node.caseBlock);
78584
+ registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
78534
78585
  }
78535
78586
  }
78536
78587
  function checkLabeledStatement(node) {
@@ -78870,7 +78921,7 @@ function createTypeChecker(host) {
78870
78921
  }
78871
78922
  function checkClassExpressionDeferred(node) {
78872
78923
  forEach(node.members, checkSourceElement);
78873
- registerForUnusedIdentifiersCheck(node);
78924
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
78874
78925
  }
78875
78926
  function checkClassDeclaration(node) {
78876
78927
  const firstDecorator = find(node.modifiers, isDecorator);
@@ -78882,7 +78933,7 @@ function createTypeChecker(host) {
78882
78933
  }
78883
78934
  checkClassLikeDeclaration(node);
78884
78935
  forEach(node.members, checkSourceElement);
78885
- registerForUnusedIdentifiersCheck(node);
78936
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
78886
78937
  }
78887
78938
  function checkClassLikeDeclaration(node) {
78888
78939
  checkGrammarClassLikeDeclaration(node);
@@ -79443,7 +79494,7 @@ function createTypeChecker(host) {
79443
79494
  forEach(node.members, checkSourceElement);
79444
79495
  addLazyDiagnostic(() => {
79445
79496
  checkTypeForDuplicateIndexSignatures(node);
79446
- registerForUnusedIdentifiersCheck(node);
79497
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
79447
79498
  });
79448
79499
  }
79449
79500
  function checkTypeAliasDeclaration(node) {
@@ -79457,7 +79508,7 @@ function createTypeChecker(host) {
79457
79508
  }
79458
79509
  } else {
79459
79510
  checkSourceElement(node.type);
79460
- registerForUnusedIdentifiersCheck(node);
79511
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
79461
79512
  }
79462
79513
  }
79463
79514
  function computeEnumMemberValues(node) {
@@ -79728,7 +79779,7 @@ function createTypeChecker(host) {
79728
79779
  if (node.body) {
79729
79780
  checkSourceElement(node.body);
79730
79781
  if (!isGlobalScopeAugmentation(node)) {
79731
- registerForUnusedIdentifiersCheck(node);
79782
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
79732
79783
  }
79733
79784
  }
79734
79785
  addLazyDiagnostic(checkModuleDeclarationDiagnostics);
@@ -80726,8 +80777,8 @@ function createTypeChecker(host) {
80726
80777
  return Debug.assertNever(kind);
80727
80778
  }
80728
80779
  }
80729
- function getPotentiallyUnusedIdentifiers(sourceFile) {
80730
- return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
80780
+ function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
80781
+ return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
80731
80782
  }
80732
80783
  function checkSourceFileWorker(node) {
80733
80784
  const links = getNodeLinks(node);
@@ -80745,15 +80796,21 @@ function createTypeChecker(host) {
80745
80796
  checkSourceElement(node.endOfFileToken);
80746
80797
  checkDeferredNodes(node);
80747
80798
  if (isExternalOrCommonJsModule(node)) {
80748
- registerForUnusedIdentifiersCheck(node);
80799
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80749
80800
  }
80750
80801
  addLazyDiagnostic(() => {
80751
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
80752
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag2) => {
80753
- if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
80754
- diagnostics.add(diag2);
80755
- }
80756
- });
80802
+ const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
80803
+ if (checkUnused || strictNullChecks) {
80804
+ checkUnusedOrUninitializedIdentifiers(
80805
+ getPotentiallyUnusedOrUninitializedIdentifiers(node),
80806
+ (containingNode, kind, diag2) => {
80807
+ if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
80808
+ diagnostics.add(diag2);
80809
+ }
80810
+ },
80811
+ checkUnused,
80812
+ strictNullChecks
80813
+ );
80757
80814
  }
80758
80815
  if (!node.isDeclarationFile) {
80759
80816
  checkPotentialUncheckedRenamedBindingElementsInTypes();
package/lib/tsserver.js CHANGED
@@ -8357,11 +8357,12 @@ var sys = (() => {
8357
8357
  let activeSession;
8358
8358
  let profilePath = "./profile.cpuprofile";
8359
8359
  const Buffer2 = require("buffer").Buffer;
8360
- const isWindows = process.platform === "win32";
8360
+ const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
8361
+ const platform = _os.platform();
8361
8362
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
8362
- const fsRealpath = !!_fs.realpathSync.native ? isWindows ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
8363
+ const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
8363
8364
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
8364
- const fsSupportsRecursiveFsWatch = isWindows || process.platform === "darwin";
8365
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
8365
8366
  const getCurrentDirectory = memoize(() => process.cwd());
8366
8367
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
8367
8368
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -8380,7 +8381,7 @@ var sys = (() => {
8380
8381
  tscWatchFile: process.env.TSC_WATCHFILE,
8381
8382
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
8382
8383
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
8383
- inodeWatching: !isWindows,
8384
+ inodeWatching: isLinuxOrMacOs,
8384
8385
  sysLog
8385
8386
  });
8386
8387
  const nodeSystem = {
@@ -8565,7 +8566,7 @@ var sys = (() => {
8565
8566
  return Buffer2.from && Buffer2.from !== Int8Array.from ? Buffer2.from(input, encoding) : new Buffer2(input, encoding);
8566
8567
  }
8567
8568
  function isFileSystemCaseSensitive() {
8568
- if (isWindows) {
8569
+ if (platform === "win32" || platform === "win64") {
8569
8570
  return false;
8570
8571
  }
8571
8572
  return !fileExists(swapCase(__filename));
@@ -20130,6 +20131,7 @@ function Symbol4(flags, name) {
20130
20131
  this.exportSymbol = void 0;
20131
20132
  this.constEnumOnlyModule = void 0;
20132
20133
  this.isReferenced = void 0;
20134
+ this.isInitialized = void 0;
20133
20135
  this.isAssigned = void 0;
20134
20136
  this.links = void 0;
20135
20137
  }
@@ -48237,11 +48239,16 @@ function createTypeChecker(host) {
48237
48239
  checkSourceFileWithEagerDiagnostics(file);
48238
48240
  Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
48239
48241
  diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
48240
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag2) => {
48241
- if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
48242
- (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
48243
- }
48244
- });
48242
+ checkUnusedOrUninitializedIdentifiers(
48243
+ getPotentiallyUnusedOrUninitializedIdentifiers(file),
48244
+ (containingNode, kind, diag2) => {
48245
+ if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
48246
+ (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
48247
+ }
48248
+ },
48249
+ /*checkUnused*/
48250
+ true
48251
+ );
48245
48252
  return diagnostics2 || emptyArray;
48246
48253
  } finally {
48247
48254
  cancellationToken = void 0;
@@ -48738,7 +48745,7 @@ function createTypeChecker(host) {
48738
48745
  var deferredGlobalClassAccessorDecoratorTargetType;
48739
48746
  var deferredGlobalClassAccessorDecoratorResultType;
48740
48747
  var deferredGlobalClassFieldDecoratorContextType;
48741
- var allPotentiallyUnusedIdentifiers = /* @__PURE__ */ new Map();
48748
+ var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
48742
48749
  var flowLoopStart = 0;
48743
48750
  var flowLoopCount = 0;
48744
48751
  var sharedFlowCount = 0;
@@ -49449,10 +49456,10 @@ function createTypeChecker(host) {
49449
49456
  function isConstAssertion(location) {
49450
49457
  return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
49451
49458
  }
49452
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
49453
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol2);
49459
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
49460
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol2);
49454
49461
  }
49455
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
49462
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
49456
49463
  var _a, _b, _c;
49457
49464
  const originalLocation = location;
49458
49465
  let result;
@@ -49678,6 +49685,9 @@ function createTypeChecker(host) {
49678
49685
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
49679
49686
  result.isReferenced |= meaning;
49680
49687
  }
49688
+ if (isWritten && result) {
49689
+ result.isInitialized = true;
49690
+ }
49681
49691
  if (!result) {
49682
49692
  if (lastLocation) {
49683
49693
  Debug.assertNode(lastLocation, isSourceFile);
@@ -69185,7 +69195,10 @@ function createTypeChecker(host) {
69185
69195
  node,
69186
69196
  !isWriteOnlyAccess(node),
69187
69197
  /*excludeGlobals*/
69188
- false
69198
+ false,
69199
+ /*getSpellingSuggestions*/
69200
+ void 0,
69201
+ isWriteAccess(node)
69189
69202
  ) || unknownSymbol;
69190
69203
  }
69191
69204
  return links.resolvedSymbol;
@@ -74619,6 +74632,8 @@ function createTypeChecker(host) {
74619
74632
  false,
74620
74633
  /*getSpellingSuggestions*/
74621
74634
  true,
74635
+ /*isWritten*/
74636
+ false,
74622
74637
  (symbols, name, meaning2) => {
74623
74638
  Debug.assertEqual(outerName, name, "name should equal outerName");
74624
74639
  const symbol = getSymbol2(symbols, name, meaning2);
@@ -80073,7 +80088,7 @@ function createTypeChecker(host) {
80073
80088
  }
80074
80089
  }
80075
80090
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
80076
- registerForUnusedIdentifiersCheck(node);
80091
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80077
80092
  }
80078
80093
  }
80079
80094
  }
@@ -80618,7 +80633,7 @@ function createTypeChecker(host) {
80618
80633
  }
80619
80634
  }
80620
80635
  }
80621
- registerForUnusedIdentifiersCheck(node);
80636
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80622
80637
  }
80623
80638
  function checkTemplateLiteralType(node) {
80624
80639
  for (const span of node.templateSpans) {
@@ -81604,25 +81619,27 @@ function createTypeChecker(host) {
81604
81619
  }
81605
81620
  }
81606
81621
  }
81607
- function registerForUnusedIdentifiersCheck(node) {
81608
- addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
81609
- function registerForUnusedIdentifiersCheckDiagnostics() {
81622
+ function registerForUnusedOrUninitializedIdentifiersCheck(node) {
81623
+ addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
81624
+ function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
81610
81625
  const sourceFile = getSourceFileOfNode(node);
81611
- let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
81612
- if (!potentiallyUnusedIdentifiers) {
81613
- potentiallyUnusedIdentifiers = [];
81614
- allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
81626
+ let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
81627
+ if (!potentiallyUnusedOrUninitializedIdentifiers) {
81628
+ potentiallyUnusedOrUninitializedIdentifiers = [];
81629
+ allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
81615
81630
  }
81616
- potentiallyUnusedIdentifiers.push(node);
81631
+ potentiallyUnusedOrUninitializedIdentifiers.push(node);
81617
81632
  }
81618
81633
  }
81619
- function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
81634
+ function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
81620
81635
  for (const node of potentiallyUnusedIdentifiers) {
81621
81636
  switch (node.kind) {
81622
81637
  case 263 /* ClassDeclaration */:
81623
81638
  case 231 /* ClassExpression */:
81624
- checkUnusedClassMembers(node, addDiagnostic);
81625
- checkUnusedTypeParameters(node, addDiagnostic);
81639
+ if (checkUnused) {
81640
+ checkUnusedClassMembers(node, addDiagnostic);
81641
+ checkUnusedTypeParameters(node, addDiagnostic);
81642
+ }
81626
81643
  break;
81627
81644
  case 312 /* SourceFile */:
81628
81645
  case 267 /* ModuleDeclaration */:
@@ -81631,7 +81648,12 @@ function createTypeChecker(host) {
81631
81648
  case 248 /* ForStatement */:
81632
81649
  case 249 /* ForInStatement */:
81633
81650
  case 250 /* ForOfStatement */:
81634
- checkUnusedLocalsAndParameters(node, addDiagnostic);
81651
+ if (checkUnused) {
81652
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
81653
+ }
81654
+ if (checkUninitialized) {
81655
+ checkUninitializedLocals(node);
81656
+ }
81635
81657
  break;
81636
81658
  case 176 /* Constructor */:
81637
81659
  case 218 /* FunctionExpression */:
@@ -81640,10 +81662,15 @@ function createTypeChecker(host) {
81640
81662
  case 174 /* MethodDeclaration */:
81641
81663
  case 177 /* GetAccessor */:
81642
81664
  case 178 /* SetAccessor */:
81643
- if (node.body) {
81644
- checkUnusedLocalsAndParameters(node, addDiagnostic);
81665
+ if (checkUnused) {
81666
+ if (node.body) {
81667
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
81668
+ }
81669
+ checkUnusedTypeParameters(node, addDiagnostic);
81670
+ }
81671
+ if (checkUninitialized) {
81672
+ checkUninitializedLocals(node);
81645
81673
  }
81646
- checkUnusedTypeParameters(node, addDiagnostic);
81647
81674
  break;
81648
81675
  case 173 /* MethodSignature */:
81649
81676
  case 179 /* CallSignature */:
@@ -81652,10 +81679,14 @@ function createTypeChecker(host) {
81652
81679
  case 185 /* ConstructorType */:
81653
81680
  case 265 /* TypeAliasDeclaration */:
81654
81681
  case 264 /* InterfaceDeclaration */:
81655
- checkUnusedTypeParameters(node, addDiagnostic);
81682
+ if (checkUnused) {
81683
+ checkUnusedTypeParameters(node, addDiagnostic);
81684
+ }
81656
81685
  break;
81657
81686
  case 195 /* InferType */:
81658
- checkUnusedInferTypeParameter(node, addDiagnostic);
81687
+ if (checkUnused) {
81688
+ checkUnusedInferTypeParameter(node, addDiagnostic);
81689
+ }
81659
81690
  break;
81660
81691
  default:
81661
81692
  Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
@@ -81845,6 +81876,26 @@ function createTypeChecker(host) {
81845
81876
  }
81846
81877
  });
81847
81878
  }
81879
+ function checkUninitializedLocals(nodeWithLocals) {
81880
+ nodeWithLocals.locals.forEach((local) => {
81881
+ if (!(local.flags & 3 /* Variable */) || local.isInitialized || !local.isReferenced) {
81882
+ return;
81883
+ }
81884
+ const declaration = local.valueDeclaration;
81885
+ if (!declaration) {
81886
+ return;
81887
+ }
81888
+ if (isVariableDeclaration(declaration)) {
81889
+ if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
81890
+ return;
81891
+ }
81892
+ const type = getTypeFromTypeNode(declaration.type);
81893
+ if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
81894
+ error2(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
81895
+ }
81896
+ }
81897
+ });
81898
+ }
81848
81899
  function checkPotentialUncheckedRenamedBindingElementsInTypes() {
81849
81900
  var _a;
81850
81901
  for (const node of potentialUnusedRenamedBindingElementsInTypes) {
@@ -81891,7 +81942,7 @@ function createTypeChecker(host) {
81891
81942
  forEach(node.statements, checkSourceElement);
81892
81943
  }
81893
81944
  if (node.locals) {
81894
- registerForUnusedIdentifiersCheck(node);
81945
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
81895
81946
  }
81896
81947
  }
81897
81948
  function checkCollisionWithArgumentsInGeneratedCode(node) {
@@ -82441,7 +82492,7 @@ function createTypeChecker(host) {
82441
82492
  checkExpression(node.incrementor);
82442
82493
  checkSourceElement(node.statement);
82443
82494
  if (node.locals) {
82444
- registerForUnusedIdentifiersCheck(node);
82495
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
82445
82496
  }
82446
82497
  }
82447
82498
  function checkForOfStatement(node) {
@@ -82480,7 +82531,7 @@ function createTypeChecker(host) {
82480
82531
  }
82481
82532
  checkSourceElement(node.statement);
82482
82533
  if (node.locals) {
82483
- registerForUnusedIdentifiersCheck(node);
82534
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
82484
82535
  }
82485
82536
  }
82486
82537
  function checkForInStatement(node) {
@@ -82512,7 +82563,7 @@ function createTypeChecker(host) {
82512
82563
  }
82513
82564
  checkSourceElement(node.statement);
82514
82565
  if (node.locals) {
82515
- registerForUnusedIdentifiersCheck(node);
82566
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
82516
82567
  }
82517
82568
  }
82518
82569
  function checkRightHandSideOfForOf(statement) {
@@ -83244,7 +83295,7 @@ function createTypeChecker(host) {
83244
83295
  }
83245
83296
  });
83246
83297
  if (node.caseBlock.locals) {
83247
- registerForUnusedIdentifiersCheck(node.caseBlock);
83298
+ registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
83248
83299
  }
83249
83300
  }
83250
83301
  function checkLabeledStatement(node) {
@@ -83584,7 +83635,7 @@ function createTypeChecker(host) {
83584
83635
  }
83585
83636
  function checkClassExpressionDeferred(node) {
83586
83637
  forEach(node.members, checkSourceElement);
83587
- registerForUnusedIdentifiersCheck(node);
83638
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
83588
83639
  }
83589
83640
  function checkClassDeclaration(node) {
83590
83641
  const firstDecorator = find(node.modifiers, isDecorator);
@@ -83596,7 +83647,7 @@ function createTypeChecker(host) {
83596
83647
  }
83597
83648
  checkClassLikeDeclaration(node);
83598
83649
  forEach(node.members, checkSourceElement);
83599
- registerForUnusedIdentifiersCheck(node);
83650
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
83600
83651
  }
83601
83652
  function checkClassLikeDeclaration(node) {
83602
83653
  checkGrammarClassLikeDeclaration(node);
@@ -84157,7 +84208,7 @@ function createTypeChecker(host) {
84157
84208
  forEach(node.members, checkSourceElement);
84158
84209
  addLazyDiagnostic(() => {
84159
84210
  checkTypeForDuplicateIndexSignatures(node);
84160
- registerForUnusedIdentifiersCheck(node);
84211
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
84161
84212
  });
84162
84213
  }
84163
84214
  function checkTypeAliasDeclaration(node) {
@@ -84171,7 +84222,7 @@ function createTypeChecker(host) {
84171
84222
  }
84172
84223
  } else {
84173
84224
  checkSourceElement(node.type);
84174
- registerForUnusedIdentifiersCheck(node);
84225
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
84175
84226
  }
84176
84227
  }
84177
84228
  function computeEnumMemberValues(node) {
@@ -84442,7 +84493,7 @@ function createTypeChecker(host) {
84442
84493
  if (node.body) {
84443
84494
  checkSourceElement(node.body);
84444
84495
  if (!isGlobalScopeAugmentation(node)) {
84445
- registerForUnusedIdentifiersCheck(node);
84496
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
84446
84497
  }
84447
84498
  }
84448
84499
  addLazyDiagnostic(checkModuleDeclarationDiagnostics);
@@ -85440,8 +85491,8 @@ function createTypeChecker(host) {
85440
85491
  return Debug.assertNever(kind);
85441
85492
  }
85442
85493
  }
85443
- function getPotentiallyUnusedIdentifiers(sourceFile) {
85444
- return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
85494
+ function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
85495
+ return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
85445
85496
  }
85446
85497
  function checkSourceFileWorker(node) {
85447
85498
  const links = getNodeLinks(node);
@@ -85459,15 +85510,21 @@ function createTypeChecker(host) {
85459
85510
  checkSourceElement(node.endOfFileToken);
85460
85511
  checkDeferredNodes(node);
85461
85512
  if (isExternalOrCommonJsModule(node)) {
85462
- registerForUnusedIdentifiersCheck(node);
85513
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
85463
85514
  }
85464
85515
  addLazyDiagnostic(() => {
85465
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85466
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag2) => {
85467
- if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
85468
- diagnostics.add(diag2);
85469
- }
85470
- });
85516
+ const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
85517
+ if (checkUnused || strictNullChecks) {
85518
+ checkUnusedOrUninitializedIdentifiers(
85519
+ getPotentiallyUnusedOrUninitializedIdentifiers(node),
85520
+ (containingNode, kind, diag2) => {
85521
+ if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
85522
+ diagnostics.add(diag2);
85523
+ }
85524
+ },
85525
+ checkUnused,
85526
+ strictNullChecks
85527
+ );
85471
85528
  }
85472
85529
  if (!node.isDeclarationFile) {
85473
85530
  checkPotentialUncheckedRenamedBindingElementsInTypes();
package/lib/typescript.js CHANGED
@@ -6126,11 +6126,12 @@ ${lanes.join("\n")}
6126
6126
  let activeSession;
6127
6127
  let profilePath = "./profile.cpuprofile";
6128
6128
  const Buffer2 = require("buffer").Buffer;
6129
- const isWindows = process.platform === "win32";
6129
+ const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
6130
+ const platform = _os.platform();
6130
6131
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
6131
- const fsRealpath = !!_fs.realpathSync.native ? isWindows ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
6132
+ const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
6132
6133
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
6133
- const fsSupportsRecursiveFsWatch = isWindows || process.platform === "darwin";
6134
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
6134
6135
  const getCurrentDirectory = memoize(() => process.cwd());
6135
6136
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
6136
6137
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -6149,7 +6150,7 @@ ${lanes.join("\n")}
6149
6150
  tscWatchFile: process.env.TSC_WATCHFILE,
6150
6151
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
6151
6152
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6152
- inodeWatching: !isWindows,
6153
+ inodeWatching: isLinuxOrMacOs,
6153
6154
  sysLog
6154
6155
  });
6155
6156
  const nodeSystem = {
@@ -6334,7 +6335,7 @@ ${lanes.join("\n")}
6334
6335
  return Buffer2.from && Buffer2.from !== Int8Array.from ? Buffer2.from(input, encoding) : new Buffer2(input, encoding);
6335
6336
  }
6336
6337
  function isFileSystemCaseSensitive() {
6337
- if (isWindows) {
6338
+ if (platform === "win32" || platform === "win64") {
6338
6339
  return false;
6339
6340
  }
6340
6341
  return !fileExists(swapCase(__filename));
@@ -17429,6 +17430,7 @@ ${lanes.join("\n")}
17429
17430
  this.exportSymbol = void 0;
17430
17431
  this.constEnumOnlyModule = void 0;
17431
17432
  this.isReferenced = void 0;
17433
+ this.isInitialized = void 0;
17432
17434
  this.isAssigned = void 0;
17433
17435
  this.links = void 0;
17434
17436
  }
@@ -46001,11 +46003,16 @@ ${lanes.join("\n")}
46001
46003
  checkSourceFileWithEagerDiagnostics(file);
46002
46004
  Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
46003
46005
  diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
46004
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag2) => {
46005
- if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
46006
- (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
46007
- }
46008
- });
46006
+ checkUnusedOrUninitializedIdentifiers(
46007
+ getPotentiallyUnusedOrUninitializedIdentifiers(file),
46008
+ (containingNode, kind, diag2) => {
46009
+ if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
46010
+ (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
46011
+ }
46012
+ },
46013
+ /*checkUnused*/
46014
+ true
46015
+ );
46009
46016
  return diagnostics2 || emptyArray;
46010
46017
  } finally {
46011
46018
  cancellationToken = void 0;
@@ -46502,7 +46509,7 @@ ${lanes.join("\n")}
46502
46509
  var deferredGlobalClassAccessorDecoratorTargetType;
46503
46510
  var deferredGlobalClassAccessorDecoratorResultType;
46504
46511
  var deferredGlobalClassFieldDecoratorContextType;
46505
- var allPotentiallyUnusedIdentifiers = /* @__PURE__ */ new Map();
46512
+ var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
46506
46513
  var flowLoopStart = 0;
46507
46514
  var flowLoopCount = 0;
46508
46515
  var sharedFlowCount = 0;
@@ -47213,10 +47220,10 @@ ${lanes.join("\n")}
47213
47220
  function isConstAssertion(location) {
47214
47221
  return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
47215
47222
  }
47216
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
47217
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol2);
47223
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
47224
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol2);
47218
47225
  }
47219
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
47226
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
47220
47227
  var _a, _b, _c;
47221
47228
  const originalLocation = location;
47222
47229
  let result;
@@ -47442,6 +47449,9 @@ ${lanes.join("\n")}
47442
47449
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
47443
47450
  result.isReferenced |= meaning;
47444
47451
  }
47452
+ if (isWritten && result) {
47453
+ result.isInitialized = true;
47454
+ }
47445
47455
  if (!result) {
47446
47456
  if (lastLocation) {
47447
47457
  Debug.assertNode(lastLocation, isSourceFile);
@@ -66949,7 +66959,10 @@ ${lanes.join("\n")}
66949
66959
  node,
66950
66960
  !isWriteOnlyAccess(node),
66951
66961
  /*excludeGlobals*/
66952
- false
66962
+ false,
66963
+ /*getSpellingSuggestions*/
66964
+ void 0,
66965
+ isWriteAccess(node)
66953
66966
  ) || unknownSymbol;
66954
66967
  }
66955
66968
  return links.resolvedSymbol;
@@ -72383,6 +72396,8 @@ ${lanes.join("\n")}
72383
72396
  false,
72384
72397
  /*getSpellingSuggestions*/
72385
72398
  true,
72399
+ /*isWritten*/
72400
+ false,
72386
72401
  (symbols, name, meaning2) => {
72387
72402
  Debug.assertEqual(outerName, name, "name should equal outerName");
72388
72403
  const symbol = getSymbol2(symbols, name, meaning2);
@@ -77837,7 +77852,7 @@ ${lanes.join("\n")}
77837
77852
  }
77838
77853
  }
77839
77854
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
77840
- registerForUnusedIdentifiersCheck(node);
77855
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
77841
77856
  }
77842
77857
  }
77843
77858
  }
@@ -78382,7 +78397,7 @@ ${lanes.join("\n")}
78382
78397
  }
78383
78398
  }
78384
78399
  }
78385
- registerForUnusedIdentifiersCheck(node);
78400
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
78386
78401
  }
78387
78402
  function checkTemplateLiteralType(node) {
78388
78403
  for (const span of node.templateSpans) {
@@ -79368,25 +79383,27 @@ ${lanes.join("\n")}
79368
79383
  }
79369
79384
  }
79370
79385
  }
79371
- function registerForUnusedIdentifiersCheck(node) {
79372
- addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
79373
- function registerForUnusedIdentifiersCheckDiagnostics() {
79386
+ function registerForUnusedOrUninitializedIdentifiersCheck(node) {
79387
+ addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
79388
+ function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
79374
79389
  const sourceFile = getSourceFileOfNode(node);
79375
- let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
79376
- if (!potentiallyUnusedIdentifiers) {
79377
- potentiallyUnusedIdentifiers = [];
79378
- allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
79390
+ let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
79391
+ if (!potentiallyUnusedOrUninitializedIdentifiers) {
79392
+ potentiallyUnusedOrUninitializedIdentifiers = [];
79393
+ allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
79379
79394
  }
79380
- potentiallyUnusedIdentifiers.push(node);
79395
+ potentiallyUnusedOrUninitializedIdentifiers.push(node);
79381
79396
  }
79382
79397
  }
79383
- function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
79398
+ function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
79384
79399
  for (const node of potentiallyUnusedIdentifiers) {
79385
79400
  switch (node.kind) {
79386
79401
  case 263 /* ClassDeclaration */:
79387
79402
  case 231 /* ClassExpression */:
79388
- checkUnusedClassMembers(node, addDiagnostic);
79389
- checkUnusedTypeParameters(node, addDiagnostic);
79403
+ if (checkUnused) {
79404
+ checkUnusedClassMembers(node, addDiagnostic);
79405
+ checkUnusedTypeParameters(node, addDiagnostic);
79406
+ }
79390
79407
  break;
79391
79408
  case 312 /* SourceFile */:
79392
79409
  case 267 /* ModuleDeclaration */:
@@ -79395,7 +79412,12 @@ ${lanes.join("\n")}
79395
79412
  case 248 /* ForStatement */:
79396
79413
  case 249 /* ForInStatement */:
79397
79414
  case 250 /* ForOfStatement */:
79398
- checkUnusedLocalsAndParameters(node, addDiagnostic);
79415
+ if (checkUnused) {
79416
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
79417
+ }
79418
+ if (checkUninitialized) {
79419
+ checkUninitializedLocals(node);
79420
+ }
79399
79421
  break;
79400
79422
  case 176 /* Constructor */:
79401
79423
  case 218 /* FunctionExpression */:
@@ -79404,10 +79426,15 @@ ${lanes.join("\n")}
79404
79426
  case 174 /* MethodDeclaration */:
79405
79427
  case 177 /* GetAccessor */:
79406
79428
  case 178 /* SetAccessor */:
79407
- if (node.body) {
79408
- checkUnusedLocalsAndParameters(node, addDiagnostic);
79429
+ if (checkUnused) {
79430
+ if (node.body) {
79431
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
79432
+ }
79433
+ checkUnusedTypeParameters(node, addDiagnostic);
79434
+ }
79435
+ if (checkUninitialized) {
79436
+ checkUninitializedLocals(node);
79409
79437
  }
79410
- checkUnusedTypeParameters(node, addDiagnostic);
79411
79438
  break;
79412
79439
  case 173 /* MethodSignature */:
79413
79440
  case 179 /* CallSignature */:
@@ -79416,10 +79443,14 @@ ${lanes.join("\n")}
79416
79443
  case 185 /* ConstructorType */:
79417
79444
  case 265 /* TypeAliasDeclaration */:
79418
79445
  case 264 /* InterfaceDeclaration */:
79419
- checkUnusedTypeParameters(node, addDiagnostic);
79446
+ if (checkUnused) {
79447
+ checkUnusedTypeParameters(node, addDiagnostic);
79448
+ }
79420
79449
  break;
79421
79450
  case 195 /* InferType */:
79422
- checkUnusedInferTypeParameter(node, addDiagnostic);
79451
+ if (checkUnused) {
79452
+ checkUnusedInferTypeParameter(node, addDiagnostic);
79453
+ }
79423
79454
  break;
79424
79455
  default:
79425
79456
  Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
@@ -79609,6 +79640,26 @@ ${lanes.join("\n")}
79609
79640
  }
79610
79641
  });
79611
79642
  }
79643
+ function checkUninitializedLocals(nodeWithLocals) {
79644
+ nodeWithLocals.locals.forEach((local) => {
79645
+ if (!(local.flags & 3 /* Variable */) || local.isInitialized || !local.isReferenced) {
79646
+ return;
79647
+ }
79648
+ const declaration = local.valueDeclaration;
79649
+ if (!declaration) {
79650
+ return;
79651
+ }
79652
+ if (isVariableDeclaration(declaration)) {
79653
+ if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
79654
+ return;
79655
+ }
79656
+ const type = getTypeFromTypeNode(declaration.type);
79657
+ if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
79658
+ error2(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
79659
+ }
79660
+ }
79661
+ });
79662
+ }
79612
79663
  function checkPotentialUncheckedRenamedBindingElementsInTypes() {
79613
79664
  var _a;
79614
79665
  for (const node of potentialUnusedRenamedBindingElementsInTypes) {
@@ -79655,7 +79706,7 @@ ${lanes.join("\n")}
79655
79706
  forEach(node.statements, checkSourceElement);
79656
79707
  }
79657
79708
  if (node.locals) {
79658
- registerForUnusedIdentifiersCheck(node);
79709
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
79659
79710
  }
79660
79711
  }
79661
79712
  function checkCollisionWithArgumentsInGeneratedCode(node) {
@@ -80205,7 +80256,7 @@ ${lanes.join("\n")}
80205
80256
  checkExpression(node.incrementor);
80206
80257
  checkSourceElement(node.statement);
80207
80258
  if (node.locals) {
80208
- registerForUnusedIdentifiersCheck(node);
80259
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80209
80260
  }
80210
80261
  }
80211
80262
  function checkForOfStatement(node) {
@@ -80244,7 +80295,7 @@ ${lanes.join("\n")}
80244
80295
  }
80245
80296
  checkSourceElement(node.statement);
80246
80297
  if (node.locals) {
80247
- registerForUnusedIdentifiersCheck(node);
80298
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80248
80299
  }
80249
80300
  }
80250
80301
  function checkForInStatement(node) {
@@ -80276,7 +80327,7 @@ ${lanes.join("\n")}
80276
80327
  }
80277
80328
  checkSourceElement(node.statement);
80278
80329
  if (node.locals) {
80279
- registerForUnusedIdentifiersCheck(node);
80330
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
80280
80331
  }
80281
80332
  }
80282
80333
  function checkRightHandSideOfForOf(statement) {
@@ -81008,7 +81059,7 @@ ${lanes.join("\n")}
81008
81059
  }
81009
81060
  });
81010
81061
  if (node.caseBlock.locals) {
81011
- registerForUnusedIdentifiersCheck(node.caseBlock);
81062
+ registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
81012
81063
  }
81013
81064
  }
81014
81065
  function checkLabeledStatement(node) {
@@ -81348,7 +81399,7 @@ ${lanes.join("\n")}
81348
81399
  }
81349
81400
  function checkClassExpressionDeferred(node) {
81350
81401
  forEach(node.members, checkSourceElement);
81351
- registerForUnusedIdentifiersCheck(node);
81402
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
81352
81403
  }
81353
81404
  function checkClassDeclaration(node) {
81354
81405
  const firstDecorator = find(node.modifiers, isDecorator);
@@ -81360,7 +81411,7 @@ ${lanes.join("\n")}
81360
81411
  }
81361
81412
  checkClassLikeDeclaration(node);
81362
81413
  forEach(node.members, checkSourceElement);
81363
- registerForUnusedIdentifiersCheck(node);
81414
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
81364
81415
  }
81365
81416
  function checkClassLikeDeclaration(node) {
81366
81417
  checkGrammarClassLikeDeclaration(node);
@@ -81921,7 +81972,7 @@ ${lanes.join("\n")}
81921
81972
  forEach(node.members, checkSourceElement);
81922
81973
  addLazyDiagnostic(() => {
81923
81974
  checkTypeForDuplicateIndexSignatures(node);
81924
- registerForUnusedIdentifiersCheck(node);
81975
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
81925
81976
  });
81926
81977
  }
81927
81978
  function checkTypeAliasDeclaration(node) {
@@ -81935,7 +81986,7 @@ ${lanes.join("\n")}
81935
81986
  }
81936
81987
  } else {
81937
81988
  checkSourceElement(node.type);
81938
- registerForUnusedIdentifiersCheck(node);
81989
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
81939
81990
  }
81940
81991
  }
81941
81992
  function computeEnumMemberValues(node) {
@@ -82206,7 +82257,7 @@ ${lanes.join("\n")}
82206
82257
  if (node.body) {
82207
82258
  checkSourceElement(node.body);
82208
82259
  if (!isGlobalScopeAugmentation(node)) {
82209
- registerForUnusedIdentifiersCheck(node);
82260
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
82210
82261
  }
82211
82262
  }
82212
82263
  addLazyDiagnostic(checkModuleDeclarationDiagnostics);
@@ -83204,8 +83255,8 @@ ${lanes.join("\n")}
83204
83255
  return Debug.assertNever(kind);
83205
83256
  }
83206
83257
  }
83207
- function getPotentiallyUnusedIdentifiers(sourceFile) {
83208
- return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
83258
+ function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
83259
+ return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
83209
83260
  }
83210
83261
  function checkSourceFileWorker(node) {
83211
83262
  const links = getNodeLinks(node);
@@ -83223,15 +83274,21 @@ ${lanes.join("\n")}
83223
83274
  checkSourceElement(node.endOfFileToken);
83224
83275
  checkDeferredNodes(node);
83225
83276
  if (isExternalOrCommonJsModule(node)) {
83226
- registerForUnusedIdentifiersCheck(node);
83277
+ registerForUnusedOrUninitializedIdentifiersCheck(node);
83227
83278
  }
83228
83279
  addLazyDiagnostic(() => {
83229
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
83230
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag2) => {
83231
- if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
83232
- diagnostics.add(diag2);
83233
- }
83234
- });
83280
+ const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
83281
+ if (checkUnused || strictNullChecks) {
83282
+ checkUnusedOrUninitializedIdentifiers(
83283
+ getPotentiallyUnusedOrUninitializedIdentifiers(node),
83284
+ (containingNode, kind, diag2) => {
83285
+ if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
83286
+ diagnostics.add(diag2);
83287
+ }
83288
+ },
83289
+ checkUnused,
83290
+ strictNullChecks
83291
+ );
83235
83292
  }
83236
83293
  if (!node.isDeclarationFile) {
83237
83294
  checkPotentialUncheckedRenamedBindingElementsInTypes();
@@ -4252,11 +4252,12 @@ var sys = (() => {
4252
4252
  let activeSession;
4253
4253
  let profilePath = "./profile.cpuprofile";
4254
4254
  const Buffer2 = require("buffer").Buffer;
4255
- const isWindows = process.platform === "win32";
4255
+ const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4256
+ const platform = _os.platform();
4256
4257
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
4257
- const fsRealpath = !!_fs.realpathSync.native ? isWindows ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4258
+ const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4258
4259
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
4259
- const fsSupportsRecursiveFsWatch = isWindows || process.platform === "darwin";
4260
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
4260
4261
  const getCurrentDirectory = memoize(() => process.cwd());
4261
4262
  const { watchFile, watchDirectory } = createSystemWatchFunctions({
4262
4263
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -4275,7 +4276,7 @@ var sys = (() => {
4275
4276
  tscWatchFile: process.env.TSC_WATCHFILE,
4276
4277
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
4277
4278
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4278
- inodeWatching: !isWindows,
4279
+ inodeWatching: isLinuxOrMacOs,
4279
4280
  sysLog
4280
4281
  });
4281
4282
  const nodeSystem = {
@@ -4460,7 +4461,7 @@ var sys = (() => {
4460
4461
  return Buffer2.from && Buffer2.from !== Int8Array.from ? Buffer2.from(input, encoding) : new Buffer2(input, encoding);
4461
4462
  }
4462
4463
  function isFileSystemCaseSensitive() {
4463
- if (isWindows) {
4464
+ if (platform === "win32" || platform === "win64") {
4464
4465
  return false;
4465
4466
  }
4466
4467
  return !fileExists(swapCase(__filename));
@@ -11085,6 +11086,7 @@ function Symbol4(flags, name) {
11085
11086
  this.exportSymbol = void 0;
11086
11087
  this.constEnumOnlyModule = void 0;
11087
11088
  this.isReferenced = void 0;
11089
+ this.isInitialized = void 0;
11088
11090
  this.isAssigned = void 0;
11089
11091
  this.links = void 0;
11090
11092
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.3.0-pr-55567-5",
5
+ "version": "5.3.0-pr-55887-9",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "65334d3e757bf0f013f0bd9cca47faebbe411fac"
117
+ "gitHead": "a63ed79d6f43c9a22d93a76489fc39352535410c"
118
118
  }