mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:36:43 -06:00
Parse the jsxFactory again in the checker instead of using cached value in the program
This commit is contained in:
parent
a88c2ae1e4
commit
dd7f00f20b
@ -336,6 +336,8 @@ namespace ts {
|
||||
|
||||
let jsxElementType: Type;
|
||||
let _jsxNamespace: string;
|
||||
let _jsxFactoryEntity: EntityName;
|
||||
|
||||
/** Things we lazy load from the JSX namespace */
|
||||
const jsxTypes = createMap<Type>();
|
||||
const JsxNames = {
|
||||
@ -377,9 +379,9 @@ namespace ts {
|
||||
if (_jsxNamespace === undefined) {
|
||||
_jsxNamespace = "React";
|
||||
if (compilerOptions.jsxFactory) {
|
||||
const jsxEntity = host.getJsxFactoryEntity();
|
||||
if (jsxEntity) {
|
||||
_jsxNamespace = getFirstIdentifier(jsxEntity).text;
|
||||
_jsxFactoryEntity = parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
|
||||
if (_jsxFactoryEntity) {
|
||||
_jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text;
|
||||
}
|
||||
}
|
||||
else if (compilerOptions.reactNamespace) {
|
||||
@ -19613,7 +19615,8 @@ namespace ts {
|
||||
getTypeReferenceDirectivesForEntityName,
|
||||
getTypeReferenceDirectivesForSymbol,
|
||||
isLiteralConstDeclaration,
|
||||
writeLiteralConstValue
|
||||
writeLiteralConstValue,
|
||||
getJsxFactoryEntity: () => _jsxFactoryEntity
|
||||
};
|
||||
|
||||
// defined here to avoid outer scope pollution
|
||||
|
||||
@ -329,9 +329,6 @@ namespace ts {
|
||||
// Map storing if there is emit blocking diagnostics for given input
|
||||
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
|
||||
|
||||
// ReactNamespace and jsxFactory information
|
||||
let jsxFactoryEntity: EntityName;
|
||||
|
||||
let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => ResolvedModuleFull[];
|
||||
if (host.resolveModuleNames) {
|
||||
resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile).map(resolved => {
|
||||
@ -424,8 +421,7 @@ namespace ts {
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
||||
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
|
||||
isSourceFileFromExternalLibrary,
|
||||
dropDiagnosticsProducingTypeChecker,
|
||||
getJsxFactoryEntity: () => jsxFactoryEntity
|
||||
dropDiagnosticsProducingTypeChecker
|
||||
};
|
||||
|
||||
verifyCompilerOptions();
|
||||
@ -731,7 +727,6 @@ namespace ts {
|
||||
writeFile: writeFileCallback || (
|
||||
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
|
||||
isEmitBlocked,
|
||||
getJsxFactoryEntity: program.getJsxFactoryEntity,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1679,8 +1674,7 @@ namespace ts {
|
||||
if (options.reactNamespace) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"));
|
||||
}
|
||||
jsxFactoryEntity = parseIsolatedEntityName(options.jsxFactory, languageVersion);
|
||||
if (!jsxFactoryEntity) {
|
||||
if (!parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory));
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const element = createExpressionForJsxElement(
|
||||
context.getEmitHost().getJsxFactoryEntity(),
|
||||
context.getEmitResolver().getJsxFactoryEntity(),
|
||||
compilerOptions.reactNamespace,
|
||||
tagName,
|
||||
objectProperties,
|
||||
|
||||
@ -2177,7 +2177,6 @@ namespace ts {
|
||||
getTypeChecker(): TypeChecker;
|
||||
|
||||
/* @internal */ getCommonSourceDirectory(): string;
|
||||
/* @internal */ getJsxFactoryEntity(): EntityName;
|
||||
|
||||
// For testing purposes only. Should not be used by any other consumers (including the
|
||||
// language service).
|
||||
@ -2251,7 +2250,6 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface TypeCheckerHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getJsxFactoryEntity(): EntityName;
|
||||
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
@ -2475,6 +2473,7 @@ namespace ts {
|
||||
getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[];
|
||||
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
|
||||
writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void;
|
||||
getJsxFactoryEntity(): EntityName;
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
|
||||
@ -34,8 +34,6 @@ namespace ts {
|
||||
/* @internal */
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
|
||||
/* @internal */
|
||||
getJsxFactoryEntity(): EntityName;
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user