已开启
feat: extensionAbility文件受限api报错,增加import节点回调 #870
schnappi创建于 8月24日
feat: extensionAbility文件受限api报错,增加import节点回调 #870
已开启
共 12 个文件变更+253-0
| @@ -68996,7 +68996,43 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 68996 | } | 68996 | } |
| 68997 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); | 68997 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); |
| 68998 | } | 68998 | } |
| 68999 | + function getImportExpressionDiagnosticLocation(checkResult, node) { | ||
| 69000 | + if (checkResult.node) { | ||
| 69001 | + return checkResult.node; | ||
| 69002 | + } | ||
| 69003 | + if (isImportDeclaration(node)) { | ||
| 69004 | + if (node.flags & 536870912 /* KitImportFlags */) { | ||
| 69005 | + const importClause = node.importClause; | ||
| 69006 | + const namedBindings = importClause && importClause.namedBindings; | ||
| 69007 | + if (namedBindings && namedBindings.kind === 278 /* NamedImports */ && namedBindings.elements.length > 0) { | ||
| 69008 | + return namedBindings.elements[0]; | ||
| 69009 | + } | ||
| 69010 | + if (importClause && importClause.name) { | ||
| 69011 | + return importClause; | ||
| 69012 | + } | ||
| 69013 | + } | ||
| 69014 | + return node.moduleSpecifier; | ||
| 69015 | + } | ||
| 69016 | + const argument = node.arguments.length > 0 ? node.arguments[0] : void 0; | ||
| 69017 | + return argument && isStringLiteral(argument) ? argument : node; | ||
| 69018 | + } | ||
| 69019 | + function reportHostImportExpressionCheck(node) { | ||
| 69020 | + if (host.checkImportExpression) { | ||
| 69021 | + const checkResults = host.checkImportExpression(node); | ||
| 69022 | + if (checkResults) { | ||
| 69023 | + const results = isArray(checkResults) ? checkResults : [checkResults]; | ||
| 69024 | + for (const checkResult of results) { | ||
| 69025 | + if (checkResult && !checkResult.valid) { | ||
| 69026 | + const sourceFile = getSourceFileOfNode(node); | ||
| 69027 | + const diagnostic = createDiagnosticForNodeInSourceFile(sourceFile, getImportExpressionDiagnosticLocation(checkResult, node), Diagnostics.This_API_has_been_Special_Markings_exercise_caution_when_using_this_API); | ||
| 69028 | + collectDiagnostics(checkResult, node, diagnostic); | ||
| 69029 | + } | ||
| 69030 | + } | ||
| 69031 | + } | ||
| 69032 | + } | ||
| 69033 | + } | ||
| 68999 | function checkImportCallExpression(node) { | 69034 | function checkImportCallExpression(node) { |
| 69035 | + reportHostImportExpressionCheck(node); | ||
| 69000 | checkGrammarImportCallExpression(node); | 69036 | checkGrammarImportCallExpression(node); |
| 69001 | if (node.arguments.length === 0) { | 69037 | if (node.arguments.length === 0) { |
| 69002 | return createPromiseReturnType(node, anyType); | 69038 | return createPromiseReturnType(node, anyType); |
| @@ -76611,6 +76647,7 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 76611 | } | 76647 | } |
| 76612 | } | 76648 | } |
| 76613 | function checkImportDeclaration(node) { | 76649 | function checkImportDeclaration(node) { |
| 76650 | + reportHostImportExpressionCheck(node); | ||
| 76614 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { | 76651 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 76615 | return; | 76652 | return; |
| 76616 | } | 76653 | } |
| @@ -106597,6 +106634,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config | |||
| 106597 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, | 106634 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, |
| 106598 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, | 106635 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, |
| 106599 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, | 106636 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, |
| 106637 | + checkImportExpression: host.checkImportExpression, | ||
| 106600 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, | 106638 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, |
| 106601 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, | 106639 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, |
| 106602 | releaseTypeChecker: () => { | 106640 | releaseTypeChecker: () => { |
| @@ -71557,7 +71557,43 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 71557 | } | 71557 | } |
| 71558 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); | 71558 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); |
| 71559 | } | 71559 | } |
| 71560 | + function getImportExpressionDiagnosticLocation(checkResult, node) { | ||
| 71561 | + if (checkResult.node) { | ||
| 71562 | + return checkResult.node; | ||
| 71563 | + } | ||
| 71564 | + if (isImportDeclaration(node)) { | ||
| 71565 | + if (node.flags & 536870912 /* KitImportFlags */) { | ||
| 71566 | + const importClause = node.importClause; | ||
| 71567 | + const namedBindings = importClause && importClause.namedBindings; | ||
| 71568 | + if (namedBindings && namedBindings.kind === 278 /* NamedImports */ && namedBindings.elements.length > 0) { | ||
| 71569 | + return namedBindings.elements[0]; | ||
| 71570 | + } | ||
| 71571 | + if (importClause && importClause.name) { | ||
| 71572 | + return importClause; | ||
| 71573 | + } | ||
| 71574 | + } | ||
| 71575 | + return node.moduleSpecifier; | ||
| 71576 | + } | ||
| 71577 | + const argument = node.arguments.length > 0 ? node.arguments[0] : void 0; | ||
| 71578 | + return argument && isStringLiteral(argument) ? argument : node; | ||
| 71579 | + } | ||
| 71580 | + function reportHostImportExpressionCheck(node) { | ||
| 71581 | + if (host.checkImportExpression) { | ||
| 71582 | + const checkResults = host.checkImportExpression(node); | ||
| 71583 | + if (checkResults) { | ||
| 71584 | + const results = isArray(checkResults) ? checkResults : [checkResults]; | ||
| 71585 | + for (const checkResult of results) { | ||
| 71586 | + if (checkResult && !checkResult.valid) { | ||
| 71587 | + const sourceFile = getSourceFileOfNode(node); | ||
| 71588 | + const diagnostic = createDiagnosticForNodeInSourceFile(sourceFile, getImportExpressionDiagnosticLocation(checkResult, node), Diagnostics.This_API_has_been_Special_Markings_exercise_caution_when_using_this_API); | ||
| 71589 | + collectDiagnostics(checkResult, node, diagnostic); | ||
| 71590 | + } | ||
| 71591 | + } | ||
| 71592 | + } | ||
| 71593 | + } | ||
| 71594 | + } | ||
| 71560 | function checkImportCallExpression(node) { | 71595 | function checkImportCallExpression(node) { |
| 71596 | + reportHostImportExpressionCheck(node); | ||
| 71561 | checkGrammarImportCallExpression(node); | 71597 | checkGrammarImportCallExpression(node); |
| 71562 | if (node.arguments.length === 0) { | 71598 | if (node.arguments.length === 0) { |
| 71563 | return createPromiseReturnType(node, anyType); | 71599 | return createPromiseReturnType(node, anyType); |
| @@ -79172,6 +79208,7 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 79172 | } | 79208 | } |
| 79173 | } | 79209 | } |
| 79174 | function checkImportDeclaration(node) { | 79210 | function checkImportDeclaration(node) { |
| 79211 | + reportHostImportExpressionCheck(node); | ||
| 79175 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { | 79212 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 79176 | return; | 79213 | return; |
| 79177 | } | 79214 | } |
| @@ -108954,6 +108991,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config | |||
| 108954 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, | 108991 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, |
| 108955 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, | 108992 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, |
| 108956 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, | 108993 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, |
| 108994 | + checkImportExpression: host.checkImportExpression, | ||
| 108957 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, | 108995 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, |
| 108958 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, | 108996 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, |
| 108959 | releaseTypeChecker: () => { | 108997 | releaseTypeChecker: () => { |
| @@ -127921,6 +127959,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h | |||
| 127921 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), | 127959 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), |
| 127922 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), | 127960 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), |
| 127923 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), | 127961 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), |
| 127962 | + checkImportExpression: maybeBind(host, host.checkImportExpression), | ||
| 127924 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), | 127963 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), |
| 127925 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), | 127964 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), |
| 127926 | isStaticSourceFile: host.isStaticSourceFile, | 127965 | isStaticSourceFile: host.isStaticSourceFile, |
| @@ -7599,6 +7599,7 @@ declare namespace ts { | |||
| 7599 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; | 7599 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; |
| 7600 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7600 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7601 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7601 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7602 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7602 | } | 7603 | } |
| 7603 | /** | 7604 | /** |
| 7604 | * Used by services to specify the minimum host area required to set up source files under any compilation settings | 7605 | * Used by services to specify the minimum host area required to set up source files under any compilation settings |
| @@ -7720,6 +7721,13 @@ declare namespace ts { | |||
| 7720 | valid: boolean; | 7721 | valid: boolean; |
| 7721 | type?: DiagnosticCategory; | 7722 | type?: DiagnosticCategory; |
| 7722 | message?: string; | 7723 | message?: string; |
| 7724 | + /** | ||
| 7725 | + * Optional node the host pins as the diagnostic location. When absent, the checker | ||
| 7726 | + * applies its generic default location rule for the checked import expression | ||
| 7727 | + * (kit-rewritten declaration: first named import specifier; other import | ||
| 7728 | + * declarations: module specifier; dynamic import: string literal argument). | ||
| 7729 | + */ | ||
| 7730 | + node?: Node; | ||
| 7723 | } | 7731 | } |
| 7724 | interface CompilerHost extends ModuleResolutionHost { | 7732 | interface CompilerHost extends ModuleResolutionHost { |
| 7725 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; | 7733 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; |
| @@ -7766,6 +7774,7 @@ declare namespace ts { | |||
| 7766 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7774 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7767 | isSourceOrExternalCode?(filePath: string): boolean; | 7775 | isSourceOrExternalCode?(filePath: string): boolean; |
| 7768 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7776 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7777 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7769 | } | 7778 | } |
| 7770 | interface SourceMapRange extends TextRange { | 7779 | interface SourceMapRange extends TextRange { |
| 7771 | source?: SourceMapSource; | 7780 | source?: SourceMapSource; |
| @@ -71459,7 +71459,43 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 71459 | } | 71459 | } |
| 71460 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); | 71460 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); |
| 71461 | } | 71461 | } |
| 71462 | + function getImportExpressionDiagnosticLocation(checkResult, node) { | ||
| 71463 | + if (checkResult.node) { | ||
| 71464 | + return checkResult.node; | ||
| 71465 | + } | ||
| 71466 | + if (isImportDeclaration(node)) { | ||
| 71467 | + if (node.flags & 536870912 /* KitImportFlags */) { | ||
| 71468 | + const importClause = node.importClause; | ||
| 71469 | + const namedBindings = importClause && importClause.namedBindings; | ||
| 71470 | + if (namedBindings && namedBindings.kind === 278 /* NamedImports */ && namedBindings.elements.length > 0) { | ||
| 71471 | + return namedBindings.elements[0]; | ||
| 71472 | + } | ||
| 71473 | + if (importClause && importClause.name) { | ||
| 71474 | + return importClause; | ||
| 71475 | + } | ||
| 71476 | + } | ||
| 71477 | + return node.moduleSpecifier; | ||
| 71478 | + } | ||
| 71479 | + const argument = node.arguments.length > 0 ? node.arguments[0] : void 0; | ||
| 71480 | + return argument && isStringLiteral(argument) ? argument : node; | ||
| 71481 | + } | ||
| 71482 | + function reportHostImportExpressionCheck(node) { | ||
| 71483 | + if (host.checkImportExpression) { | ||
| 71484 | + const checkResults = host.checkImportExpression(node); | ||
| 71485 | + if (checkResults) { | ||
| 71486 | + const results = isArray(checkResults) ? checkResults : [checkResults]; | ||
| 71487 | + for (const checkResult of results) { | ||
| 71488 | + if (checkResult && !checkResult.valid) { | ||
| 71489 | + const sourceFile = getSourceFileOfNode(node); | ||
| 71490 | + const diagnostic = createDiagnosticForNodeInSourceFile(sourceFile, getImportExpressionDiagnosticLocation(checkResult, node), Diagnostics.This_API_has_been_Special_Markings_exercise_caution_when_using_this_API); | ||
| 71491 | + collectDiagnostics(checkResult, node, diagnostic); | ||
| 71492 | + } | ||
| 71493 | + } | ||
| 71494 | + } | ||
| 71495 | + } | ||
| 71496 | + } | ||
| 71462 | function checkImportCallExpression(node) { | 71497 | function checkImportCallExpression(node) { |
| 71498 | + reportHostImportExpressionCheck(node); | ||
| 71463 | checkGrammarImportCallExpression(node); | 71499 | checkGrammarImportCallExpression(node); |
| 71464 | if (node.arguments.length === 0) { | 71500 | if (node.arguments.length === 0) { |
| 71465 | return createPromiseReturnType(node, anyType); | 71501 | return createPromiseReturnType(node, anyType); |
| @@ -79074,6 +79110,7 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 79074 | } | 79110 | } |
| 79075 | } | 79111 | } |
| 79076 | function checkImportDeclaration(node) { | 79112 | function checkImportDeclaration(node) { |
| 79113 | + reportHostImportExpressionCheck(node); | ||
| 79077 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { | 79114 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 79078 | return; | 79115 | return; |
| 79079 | } | 79116 | } |
| @@ -108856,6 +108893,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config | |||
| 108856 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, | 108893 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, |
| 108857 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, | 108894 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, |
| 108858 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, | 108895 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, |
| 108896 | + checkImportExpression: host.checkImportExpression, | ||
| 108859 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, | 108897 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, |
| 108860 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, | 108898 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, |
| 108861 | releaseTypeChecker: () => { | 108899 | releaseTypeChecker: () => { |
| @@ -125129,6 +125167,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h | |||
| 125129 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), | 125167 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), |
| 125130 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), | 125168 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), |
| 125131 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), | 125169 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), |
| 125170 | + checkImportExpression: maybeBind(host, host.checkImportExpression), | ||
| 125132 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), | 125171 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), |
| 125133 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), | 125172 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), |
| 125134 | isStaticSourceFile: host.isStaticSourceFile, | 125173 | isStaticSourceFile: host.isStaticSourceFile, |
| @@ -3590,6 +3590,7 @@ declare namespace ts { | |||
| 3590 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; | 3590 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; |
| 3591 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 3591 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 3592 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 3592 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 3593 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 3593 | } | 3594 | } |
| 3594 | /** | 3595 | /** |
| 3595 | * Used by services to specify the minimum host area required to set up source files under any compilation settings | 3596 | * Used by services to specify the minimum host area required to set up source files under any compilation settings |
| @@ -3711,6 +3712,13 @@ declare namespace ts { | |||
| 3711 | valid: boolean; | 3712 | valid: boolean; |
| 3712 | type?: DiagnosticCategory; | 3713 | type?: DiagnosticCategory; |
| 3713 | message?: string; | 3714 | message?: string; |
| 3715 | + /** | ||
| 3716 | + * Optional node the host pins as the diagnostic location. When absent, the checker | ||
| 3717 | + * applies its generic default location rule for the checked import expression | ||
| 3718 | + * (kit-rewritten declaration: first named import specifier; other import | ||
| 3719 | + * declarations: module specifier; dynamic import: string literal argument). | ||
| 3720 | + */ | ||
| 3721 | + node?: Node; | ||
| 3714 | } | 3722 | } |
| 3715 | interface CompilerHost extends ModuleResolutionHost { | 3723 | interface CompilerHost extends ModuleResolutionHost { |
| 3716 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; | 3724 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; |
| @@ -3757,6 +3765,7 @@ declare namespace ts { | |||
| 3757 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 3765 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 3758 | isSourceOrExternalCode?(filePath: string): boolean; | 3766 | isSourceOrExternalCode?(filePath: string): boolean; |
| 3759 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 3767 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 3768 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 3760 | } | 3769 | } |
| 3761 | interface SourceMapRange extends TextRange { | 3770 | interface SourceMapRange extends TextRange { |
| 3762 | source?: SourceMapSource; | 3771 | source?: SourceMapSource; |
| @@ -71617,7 +71617,43 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 71617 | } | 71617 | } |
| 71618 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); | 71618 | return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, void 0, void 0, false); |
| 71619 | } | 71619 | } |
| 71620 | + function getImportExpressionDiagnosticLocation(checkResult, node) { | ||
| 71621 | + if (checkResult.node) { | ||
| 71622 | + return checkResult.node; | ||
| 71623 | + } | ||
| 71624 | + if (isImportDeclaration(node)) { | ||
| 71625 | + if (node.flags & 536870912 /* KitImportFlags */) { | ||
| 71626 | + const importClause = node.importClause; | ||
| 71627 | + const namedBindings = importClause && importClause.namedBindings; | ||
| 71628 | + if (namedBindings && namedBindings.kind === 278 /* NamedImports */ && namedBindings.elements.length > 0) { | ||
| 71629 | + return namedBindings.elements[0]; | ||
| 71630 | + } | ||
| 71631 | + if (importClause && importClause.name) { | ||
| 71632 | + return importClause; | ||
| 71633 | + } | ||
| 71634 | + } | ||
| 71635 | + return node.moduleSpecifier; | ||
| 71636 | + } | ||
| 71637 | + const argument = node.arguments.length > 0 ? node.arguments[0] : void 0; | ||
| 71638 | + return argument && isStringLiteral(argument) ? argument : node; | ||
| 71639 | + } | ||
| 71640 | + function reportHostImportExpressionCheck(node) { | ||
| 71641 | + if (host.checkImportExpression) { | ||
| 71642 | + const checkResults = host.checkImportExpression(node); | ||
| 71643 | + if (checkResults) { | ||
| 71644 | + const results = isArray(checkResults) ? checkResults : [checkResults]; | ||
| 71645 | + for (const checkResult of results) { | ||
| 71646 | + if (checkResult && !checkResult.valid) { | ||
| 71647 | + const sourceFile = getSourceFileOfNode(node); | ||
| 71648 | + const diagnostic = createDiagnosticForNodeInSourceFile(sourceFile, getImportExpressionDiagnosticLocation(checkResult, node), Diagnostics.This_API_has_been_Special_Markings_exercise_caution_when_using_this_API); | ||
| 71649 | + collectDiagnostics(checkResult, node, diagnostic); | ||
| 71650 | + } | ||
| 71651 | + } | ||
| 71652 | + } | ||
| 71653 | + } | ||
| 71654 | + } | ||
| 71620 | function checkImportCallExpression(node) { | 71655 | function checkImportCallExpression(node) { |
| 71656 | + reportHostImportExpressionCheck(node); | ||
| 71621 | checkGrammarImportCallExpression(node); | 71657 | checkGrammarImportCallExpression(node); |
| 71622 | if (node.arguments.length === 0) { | 71658 | if (node.arguments.length === 0) { |
| 71623 | return createPromiseReturnType(node, anyType); | 71659 | return createPromiseReturnType(node, anyType); |
| @@ -79232,6 +79268,7 @@ function createTypeChecker(host, isTypeCheckerForLinter = false) { | |||
| 79232 | } | 79268 | } |
| 79233 | } | 79269 | } |
| 79234 | function checkImportDeclaration(node) { | 79270 | function checkImportDeclaration(node) { |
| 79271 | + reportHostImportExpressionCheck(node); | ||
| 79235 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { | 79272 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 79236 | return; | 79273 | return; |
| 79237 | } | 79274 | } |
| @@ -109218,6 +109255,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config | |||
| 109218 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, | 109255 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, |
| 109219 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, | 109256 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, |
| 109220 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, | 109257 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, |
| 109258 | + checkImportExpression: host.checkImportExpression, | ||
| 109221 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, | 109259 | getJsDocNodeConditionCheckedResult: host.getJsDocNodeConditionCheckedResult, |
| 109222 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, | 109260 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, |
| 109223 | releaseTypeChecker: () => { | 109261 | releaseTypeChecker: () => { |
| @@ -125531,6 +125569,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h | |||
| 125531 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), | 125569 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), |
| 125532 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), | 125570 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), |
| 125533 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), | 125571 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), |
| 125572 | + checkImportExpression: maybeBind(host, host.checkImportExpression), | ||
| 125534 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), | 125573 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), |
| 125535 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), | 125574 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), |
| 125536 | isStaticSourceFile: host.isStaticSourceFile, | 125575 | isStaticSourceFile: host.isStaticSourceFile, |
| @@ -34624,7 +34624,56 @@ export function createTypeChecker(host: TypeCheckerHost, isTypeCheckerForLinter: | |||
| 34624 | return globalESSymbol === resolveName(left, "Symbol" as __String, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); | 34624 | return globalESSymbol === resolveName(left, "Symbol" as __String, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); |
| 34625 | } | 34625 | } |
| 34626 | 34626 | ||
| 34627 | + function getImportExpressionDiagnosticLocation(checkResult: ConditionCheckResult, node: ImportDeclaration | ImportCall): Node { | ||
| 34628 | + // ① Host supplied an explicit location node → use it directly | ||
| 34629 | + if (checkResult.node) { | ||
| 34630 | + return checkResult.node; | ||
| 34631 | + } | ||
| 34632 | + // ② Type guard: here always a static import; reaching the end means a dynamic import | ||
| 34633 | + if (isImportDeclaration(node)) { | ||
| 34634 | + // ③ KitImportFlags = virtual statement rewritten from `import { x } from '@kit.X'` | ||
| 34635 | + // (one symbol per node, pos/end copied from the original statement) | ||
| 34636 | + if (node.flags & NodeFlags.KitImportFlags) { | ||
| 34637 | + const importClause = node.importClause; | ||
| 34638 | + // ④⑤ Default binding (`import x from ...`) has no namedBindings | ||
| 34639 | + const namedBindings = importClause && importClause.namedBindings; | ||
| 34640 | + // ⑥ Named import → the first (and only) symbol name, pos/end is exact | ||
| 34641 | + if (namedBindings && namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length > 0) { | ||
| 34642 | + return namedBindings.elements[0]; | ||
| 34643 | + } | ||
| 34644 | + // ⑦ Default-binding kit symbol → the clause itself: its pos/end is stamped with the | ||
| 34645 | + // original specifier span, so `x as y` starts at x (importClause.name would only | ||
| 34646 | + // cover the alias y, and the virtual moduleSpecifier points at the '@kit.X' string) | ||
| 34647 | + if (importClause && importClause.name) { | ||
| 34648 | + return importClause; | ||
| 34649 | + } | ||
| 34650 | + } | ||
| 34651 | + // ⑧ Plain direct import → module specifier, matching native TS2307 location | ||
| 34652 | + return node.moduleSpecifier; | ||
| 34653 | + } | ||
| 34654 | + // ⑨⑩ Dynamic import() → first string literal argument, else the whole call | ||
| 34655 | + const argument = node.arguments.length > 0 ? node.arguments[0] : undefined; | ||
| 34656 | + return argument && isStringLiteral(argument) ? argument : node; | ||
| 34657 | + } | ||
| 34658 | + | ||
| 34659 | + function reportHostImportExpressionCheck(node: ImportDeclaration | ImportCall): void { | ||
| 34660 | + if (host.checkImportExpression) { | ||
| 34661 | + const checkResults = host.checkImportExpression(node); | ||
| 34662 | + if (checkResults) { | ||
| 34663 | + const results = isArray(checkResults) ? checkResults : [checkResults]; | ||
| 34664 | + for (const checkResult of results) { | ||
| 34665 | + if (checkResult && !checkResult.valid) { | ||
| 34666 | + const sourceFile = getSourceFileOfNode(node); | ||
| 34667 | + const diagnostic = createDiagnosticForNodeInSourceFile(sourceFile, getImportExpressionDiagnosticLocation(checkResult, node), Diagnostics.This_API_has_been_Special_Markings_exercise_caution_when_using_this_API); | ||
| 34668 | + collectDiagnostics(checkResult, node, diagnostic); | ||
| 34669 | + } | ||
| 34670 | + } | ||
| 34671 | + } | ||
| 34672 | + } | ||
| 34673 | + } | ||
| 34674 | + | ||
| 34627 | function checkImportCallExpression(node: ImportCall): Type { | 34675 | function checkImportCallExpression(node: ImportCall): Type { |
| 34676 | + reportHostImportExpressionCheck(node); | ||
| 34628 | // Check grammar of dynamic import | 34677 | // Check grammar of dynamic import |
| 34629 | checkGrammarImportCallExpression(node); | 34678 | checkGrammarImportCallExpression(node); |
| 34630 | 34679 | ||
| @@ -44675,6 +44724,7 @@ export function createTypeChecker(host: TypeCheckerHost, isTypeCheckerForLinter: | |||
| 44675 | } | 44724 | } |
| 44676 | 44725 | ||
| 44677 | function checkImportDeclaration(node: ImportDeclaration) { | 44726 | function checkImportDeclaration(node: ImportDeclaration) { |
| 44727 | + reportHostImportExpressionCheck(node); | ||
| 44678 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { | 44728 | if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 44679 | // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. | 44729 | // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. |
| 44680 | return; | 44730 | return; |
| @@ -1700,6 +1700,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg | |||
| 1700 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, | 1700 | isSourceRetentionAnnotationContentValid: host.isSourceRetentionAnnotationContentValid, |
| 1701 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, | 1701 | isSourceRetentionDeclarationValid: host.isSourceRetentionDeclarationValid, |
| 1702 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, | 1702 | isApiAvailableVersionSpecifications: host.isApiAvailableVersionSpecifications, |
| 1703 | + checkImportExpression: host.checkImportExpression, | ||
| 1703 | getJsDocNodeConditionCheckedResult: host. getJsDocNodeConditionCheckedResult, | 1704 | getJsDocNodeConditionCheckedResult: host. getJsDocNodeConditionCheckedResult, |
| 1704 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, | 1705 | getFileCheckedModuleInfo: host.getFileCheckedModuleInfo, |
| 1705 | releaseTypeChecker: () => { typeChecker = undefined; linterTypeChecker = undefined; }, | 1706 | releaseTypeChecker: () => { typeChecker = undefined; linterTypeChecker = undefined; }, |
| @@ -4776,6 +4776,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost { | |||
| 4776 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 4776 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 4777 | isSourceOrExternalCode?(filePath: string): boolean; | 4777 | isSourceOrExternalCode?(filePath: string): boolean; |
| 4778 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 4778 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 4779 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 4779 | } | 4780 | } |
| 4780 | 4781 | ||
| 4781 | export interface TypeChecker { | 4782 | export interface TypeChecker { |
| @@ -7414,6 +7415,7 @@ export interface ModuleResolutionHost { | |||
| 7414 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; | 7415 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; |
| 7415 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7416 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7416 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7417 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7418 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7417 | } | 7419 | } |
| 7418 | 7420 | ||
| 7419 | /** | 7421 | /** |
| @@ -7573,6 +7575,13 @@ export interface ConditionCheckResult { | |||
| 7573 | valid: boolean; | 7575 | valid: boolean; |
| 7574 | type?: DiagnosticCategory; | 7576 | type?: DiagnosticCategory; |
| 7575 | message?: string; | 7577 | message?: string; |
| 7578 | + /** | ||
| 7579 | + * Optional node the host pins as the diagnostic location. When absent, the checker | ||
| 7580 | + * applies its generic default location rule for the checked import expression | ||
| 7581 | + * (kit-rewritten declaration: first named import specifier; other import | ||
| 7582 | + * declarations: module specifier; dynamic import: string literal argument). | ||
| 7583 | + */ | ||
| 7584 | + node?: Node; | ||
| 7576 | } | 7585 | } |
| 7577 | export interface CompilerHost extends ModuleResolutionHost { | 7586 | export interface CompilerHost extends ModuleResolutionHost { |
| 7578 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; | 7587 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; |
| @@ -7645,6 +7654,7 @@ export interface CompilerHost extends ModuleResolutionHost { | |||
| 7645 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7654 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7646 | isSourceOrExternalCode?(filePath: string): boolean; | 7655 | isSourceOrExternalCode?(filePath: string): boolean; |
| 7647 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7656 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7657 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7648 | } | 7658 | } |
| 7649 | 7659 | ||
| 7650 | /** | 7660 | /** |
| @@ -1700,6 +1700,7 @@ export function createLanguageService( | |||
| 1700 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), | 1700 | isSourceRetentionAnnotationContentValid: maybeBind(host, host.isSourceRetentionAnnotationContentValid), |
| 1701 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), | 1701 | isSourceRetentionDeclarationValid: maybeBind(host, host.isSourceRetentionDeclarationValid), |
| 1702 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), | 1702 | isApiAvailableVersionSpecifications: maybeBind(host, host.isApiAvailableVersionSpecifications), |
| 1703 | + checkImportExpression: maybeBind(host, host.checkImportExpression), | ||
| 1703 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), | 1704 | getJsDocNodeConditionCheckedResult: maybeBind(host, host.getJsDocNodeConditionCheckedResult), |
| 1704 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), | 1705 | getFileCheckedModuleInfo: maybeBind(host, host.getFileCheckedModuleInfo), |
| 1705 | isStaticSourceFile: host.isStaticSourceFile, | 1706 | isStaticSourceFile: host.isStaticSourceFile, |
| @@ -7599,6 +7599,7 @@ declare namespace ts { | |||
| 7599 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; | 7599 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; |
| 7600 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7600 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7601 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7601 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7602 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7602 | } | 7603 | } |
| 7603 | /** | 7604 | /** |
| 7604 | * Used by services to specify the minimum host area required to set up source files under any compilation settings | 7605 | * Used by services to specify the minimum host area required to set up source files under any compilation settings |
| @@ -7720,6 +7721,13 @@ declare namespace ts { | |||
| 7720 | valid: boolean; | 7721 | valid: boolean; |
| 7721 | type?: DiagnosticCategory; | 7722 | type?: DiagnosticCategory; |
| 7722 | message?: string; | 7723 | message?: string; |
| 7724 | + /** | ||
| 7725 | + * Optional node the host pins as the diagnostic location. When absent, the checker | ||
| 7726 | + * applies its generic default location rule for the checked import expression | ||
| 7727 | + * (kit-rewritten declaration: first named import specifier; other import | ||
| 7728 | + * declarations: module specifier; dynamic import: string literal argument). | ||
| 7729 | + */ | ||
| 7730 | + node?: Node; | ||
| 7723 | } | 7731 | } |
| 7724 | interface CompilerHost extends ModuleResolutionHost { | 7732 | interface CompilerHost extends ModuleResolutionHost { |
| 7725 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; | 7733 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; |
| @@ -7766,6 +7774,7 @@ declare namespace ts { | |||
| 7766 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 7774 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 7767 | isSourceOrExternalCode?(filePath: string): boolean; | 7775 | isSourceOrExternalCode?(filePath: string): boolean; |
| 7768 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 7776 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 7777 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 7769 | } | 7778 | } |
| 7770 | interface SourceMapRange extends TextRange { | 7779 | interface SourceMapRange extends TextRange { |
| 7771 | source?: SourceMapSource; | 7780 | source?: SourceMapSource; |
| @@ -3590,6 +3590,7 @@ declare namespace ts { | |||
| 3590 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; | 3590 | isSourceRetentionAnnotationContentValid?(annotationNode: Annotation): ConditionCheckResult; |
| 3591 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 3591 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 3592 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 3592 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 3593 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 3593 | } | 3594 | } |
| 3594 | /** | 3595 | /** |
| 3595 | * Used by services to specify the minimum host area required to set up source files under any compilation settings | 3596 | * Used by services to specify the minimum host area required to set up source files under any compilation settings |
| @@ -3711,6 +3712,13 @@ declare namespace ts { | |||
| 3711 | valid: boolean; | 3712 | valid: boolean; |
| 3712 | type?: DiagnosticCategory; | 3713 | type?: DiagnosticCategory; |
| 3713 | message?: string; | 3714 | message?: string; |
| 3715 | + /** | ||
| 3716 | + * Optional node the host pins as the diagnostic location. When absent, the checker | ||
| 3717 | + * applies its generic default location rule for the checked import expression | ||
| 3718 | + * (kit-rewritten declaration: first named import specifier; other import | ||
| 3719 | + * declarations: module specifier; dynamic import: string literal argument). | ||
| 3720 | + */ | ||
| 3721 | + node?: Node; | ||
| 3714 | } | 3722 | } |
| 3715 | interface CompilerHost extends ModuleResolutionHost { | 3723 | interface CompilerHost extends ModuleResolutionHost { |
| 3716 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; | 3724 | getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean, options?: CompilerOptions): SourceFile | undefined; |
| @@ -3757,6 +3765,7 @@ declare namespace ts { | |||
| 3757 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; | 3765 | isSourceRetentionDeclarationValid?(annotationNode: AnnotationDeclaration): boolean; |
| 3758 | isSourceOrExternalCode?(filePath: string): boolean; | 3766 | isSourceOrExternalCode?(filePath: string): boolean; |
| 3759 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; | 3767 | isApiAvailableVersionSpecifications?(apiAvailableNode: Node, typeOfNodeFunc: Function): ConditionCheckResult; |
| 3768 | + checkImportExpression?(node: ImportDeclaration | ImportCall): ConditionCheckResult | ConditionCheckResult[] | undefined; | ||
| 3760 | } | 3769 | } |
| 3761 | interface SourceMapRange extends TextRange { | 3770 | interface SourceMapRange extends TextRange { |
| 3762 | source?: SourceMapSource; | 3771 | source?: SourceMapSource; |