Skip to content

Commit 7239f8d

Browse files
committed
Mark jsxFactorySymbol as referenced for noUnusedLocals even in verbatimModuleSyntax
1 parent 3163fe7 commit 7239f8d

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

src/compiler/checker.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,8 @@ export const enum CheckMode {
13091309
SkipGenericFunctions = 1 << 3, // Skip single signature generic functions
13101310
IsForSignatureHelp = 1 << 4, // Call resolution for purposes of signature help
13111311
RestBindingElement = 1 << 5, // Checking a type that is going to be used to determine the type of a rest binding element
1312-
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
1313-
// we need to preserve generic types instead of substituting them for constraints
1312+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
1313+
// we need to preserve generic types instead of substituting them for constraints
13141314
TypeOnly = 1 << 6, // Called from getTypeOfExpression, diagnostics may be omitted
13151315
}
13161316

@@ -3350,7 +3350,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33503350
if (isEntityNameExpression((node as ExpressionWithTypeArguments).expression)) {
33513351
return (node as ExpressionWithTypeArguments).expression as EntityNameExpression;
33523352
}
3353-
// falls through
3353+
// falls through
33543354
default:
33553355
return undefined;
33563356
}
@@ -5451,7 +5451,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
54515451
if (!isExternalOrCommonJsModule(location as SourceFile)) {
54525452
break;
54535453
}
5454-
// falls through
5454+
// falls through
54555455
case SyntaxKind.ModuleDeclaration:
54565456
const sym = getSymbolOfDeclaration(location as ModuleDeclaration);
54575457
// `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten
@@ -10006,7 +10006,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1000610006
);
1000710007
break;
1000810008
}
10009-
// else fall through and treat commonjs require just like import=
10009+
// else fall through and treat commonjs require just like import=
1001010010
case SyntaxKind.ImportEqualsDeclaration:
1001110011
// This _specifically_ only exists to handle json declarations - where we make aliases, but since
1001210012
// we emit no declarations for the json document, must not refer to it in the declarations
@@ -10803,7 +10803,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1080310803
// If the binding pattern is empty, this variable declaration is not visible
1080410804
return false;
1080510805
}
10806-
// falls through
10806+
// falls through
1080710807
case SyntaxKind.ModuleDeclaration:
1080810808
case SyntaxKind.ClassDeclaration:
1080910809
case SyntaxKind.InterfaceDeclaration:
@@ -10836,8 +10836,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1083610836
// Private/protected properties/methods are not visible
1083710837
return false;
1083810838
}
10839-
// Public properties/methods are visible if its parents are visible, so:
10840-
// falls through
10839+
// Public properties/methods are visible if its parents are visible, so:
10840+
// falls through
1084110841

1084210842
case SyntaxKind.Constructor:
1084310843
case SyntaxKind.ConstructSignature:
@@ -20664,7 +20664,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2066420664
if (!isConstAssertion(node)) {
2066520665
break;
2066620666
}
20667-
// fallthrough
20667+
// fallthrough
2066820668
case SyntaxKind.JsxExpression:
2066920669
case SyntaxKind.ParenthesizedExpression:
2067020670
return elaborateError((node as AsExpression | ParenthesizedExpression | JsxExpression).expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
@@ -26944,7 +26944,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2694426944
if (isCallExpression(node.parent)) {
2694526945
return Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
2694626946
}
26947-
// falls through
26947+
// falls through
2694826948
default:
2694926949
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
2695026950
return Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
@@ -26986,7 +26986,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2698626986
const symbol = getResolvedSymbol(node as Identifier);
2698726987
return symbol !== unknownSymbol ? `${flowContainer ? getNodeId(flowContainer) : "-1"}|${getTypeId(declaredType)}|${getTypeId(initialType)}|${getSymbolId(symbol)}` : undefined;
2698826988
}
26989-
// falls through
26989+
// falls through
2699026990
case SyntaxKind.ThisKeyword:
2699126991
return `0|${flowContainer ? getNodeId(flowContainer) : "-1"}|${getTypeId(declaredType)}|${getTypeId(initialType)}`;
2699226992
case SyntaxKind.NonNullExpression:
@@ -29370,7 +29370,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2937029370
}
2937129371
}
2937229372
}
29373-
// falls through
29373+
// falls through
2937429374
case SyntaxKind.ThisKeyword:
2937529375
case SyntaxKind.SuperKeyword:
2937629376
case SyntaxKind.PropertyAccessExpression:
@@ -33371,7 +33371,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3337133371

3337233372
checkJsxPreconditions(node);
3337333373

33374-
markLinkedReferences(node, ReferenceHint.Jsx);
33374+
markJsxAliasReferenced(node);
3337533375

3337633376
if (isNodeOpeningLikeElement) {
3337733377
const jsxOpeningLikeNode = node;
@@ -38806,15 +38806,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3880638806
hasError = true;
3880738807
break;
3880838808
}
38809-
// fallthrough
38809+
// fallthrough
3881038810
case ModuleKind.ES2022:
3881138811
case ModuleKind.ESNext:
3881238812
case ModuleKind.Preserve:
3881338813
case ModuleKind.System:
3881438814
if (languageVersion >= ScriptTarget.ES2017) {
3881538815
break;
3881638816
}
38817-
// fallthrough
38817+
// fallthrough
3881838818
default:
3881938819
span ??= getSpanOfTokenAtPosition(sourceFile, node.pos);
3882038820
const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher :
@@ -40609,7 +40609,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4060940609
if ((node as CallExpression).expression.kind === SyntaxKind.ImportKeyword) {
4061040610
return checkImportCallExpression(node as ImportCall);
4061140611
}
40612-
// falls through
40612+
// falls through
4061340613
case SyntaxKind.NewExpression:
4061440614
return checkCallExpression(node as CallExpression, checkMode);
4061540615
case SyntaxKind.TaggedTemplateExpression:
@@ -41070,7 +41070,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4107041070
if (useDefineForClassFields) {
4107141071
break;
4107241072
}
41073-
// fall through
41073+
// fall through
4107441074
case "prototype":
4107541075
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
4107641076
const className = getNameOfSymbolAsWritten(getSymbolOfDeclaration(node));
@@ -42657,7 +42657,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4265742657
headMessage = Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
4265842658
break;
4265942659
}
42660-
// falls through
42660+
// falls through
4266142661

4266242662
case SyntaxKind.Parameter:
4266342663
headMessage = Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
@@ -46791,7 +46791,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4679146791
}
4679246792
break;
4679346793
}
46794-
// falls through
46794+
// falls through
4679546795
case SyntaxKind.ClassDeclaration:
4679646796
case SyntaxKind.EnumDeclaration:
4679746797
case SyntaxKind.FunctionDeclaration:
@@ -47610,7 +47610,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4761047610
return checkJSDocPropertyTag(node as JSDocPropertyTag);
4761147611
case SyntaxKind.JSDocFunctionType:
4761247612
checkJSDocFunctionType(node as JSDocFunctionType);
47613-
// falls through
47613+
// falls through
4761447614
case SyntaxKind.JSDocNonNullableType:
4761547615
case SyntaxKind.JSDocNullableType:
4761647616
case SyntaxKind.JSDocAllType:
@@ -48136,7 +48136,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4813648136
switch (location.kind) {
4813748137
case SyntaxKind.SourceFile:
4813848138
if (!isExternalModule(location as SourceFile)) break;
48139-
// falls through
48139+
// falls through
4814048140
case SyntaxKind.ModuleDeclaration:
4814148141
copyLocallyVisibleExportSymbols(getSymbolOfDeclaration(location as ModuleDeclaration | SourceFile).exports!, meaning & SymbolFlags.ModuleMember);
4814248142
break;
@@ -48301,7 +48301,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4830148301
if (isPropertyAccessExpression(entityName.parent) && getLeftmostAccessExpression(entityName.parent) === entityName) {
4830248302
return undefined;
4830348303
}
48304-
// falls through
48304+
// falls through
4830548305
case AssignmentDeclarationKind.ThisProperty:
4830648306
case AssignmentDeclarationKind.ModuleExports:
4830748307
return getSymbolOfDeclaration(entityName.parent.parent as BinaryExpression);
@@ -48601,7 +48601,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4860148601
if (!isThisInTypeQuery(node)) {
4860248602
return getSymbolOfNameOrPropertyAccessExpression(node as EntityName | PrivateIdentifier | PropertyAccessExpression);
4860348603
}
48604-
// falls through
48604+
// falls through
4860548605

4860648606
case SyntaxKind.ThisKeyword:
4860748607
const container = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
@@ -48614,7 +48614,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4861448614
if (isInExpressionContext(node)) {
4861548615
return checkExpression(node as Expression).symbol;
4861648616
}
48617-
// falls through
48617+
// falls through
4861848618

4861948619
case SyntaxKind.ThisType:
4862048620
return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode).symbol;
@@ -48648,7 +48648,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4864848648
if (isCallExpression(parent) && isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
4864948649
return getSymbolOfDeclaration(parent);
4865048650
}
48651-
// falls through
48651+
// falls through
4865248652

4865348653
case SyntaxKind.NumericLiteral:
4865448654
// index access
@@ -48687,7 +48687,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4868748687
const symbol = getIntrinsicTagSymbol(node.parent as JsxOpeningLikeElement);
4868848688
return symbol === unknownSymbol ? undefined : symbol;
4868948689
}
48690-
// falls through
48690+
// falls through
4869148691

4869248692
default:
4869348693
return undefined;
@@ -51108,15 +51108,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5110851108
);
5110951109
break;
5111051110
}
51111-
// fallthrough
51111+
// fallthrough
5111251112
case ModuleKind.ES2022:
5111351113
case ModuleKind.ESNext:
5111451114
case ModuleKind.Preserve:
5111551115
case ModuleKind.System:
5111651116
if (languageVersion >= ScriptTarget.ES2017) {
5111751117
break;
5111851118
}
51119-
// fallthrough
51119+
// fallthrough
5112051120
default:
5112151121
diagnostics.add(
5112251122
createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @module: preserve
2+
// @verbatimModuleSyntax: true
3+
// @jsx: react
4+
// @noEmit: true
5+
// @noUnusedLocals: true
6+
// @noTypesAndSymbols: true
7+
8+
// @Filename: react.d.ts
9+
declare module 'react';
10+
11+
// @Filename: index.tsx
12+
import React from 'react';
13+
14+
export const build = <div>hello </div>;

0 commit comments

Comments
 (0)