Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.8k
feat(42684): Override JSDoc for re-exported types / enum / classes / interfaces#47293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Nathan Shively-Sanders (sandersn)
merged 1 commit into
microsoft:main
from
a-tarasyuk:feat/42684Jan 25, 2022
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1194,6 +1194,10 @@ namespace ts { | ||
| return diagnostic; | ||
| } | ||
| function isDeprecatedSymbol(symbol: Symbol) { | ||
| return !!(getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Deprecated); | ||
| } | ||
| function addDeprecatedSuggestion(location: Node, declarations: Node[], deprecatedEntity: string) { | ||
| const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity); | ||
| return addDeprecatedSuggestionWorker(declarations, diagnostic); | ||
| @@ -15175,7 +15179,7 @@ namespace ts { | ||
| } | ||
| const prop = getPropertyOfType(objectType, propName); | ||
| if (prop) { | ||
| if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) { | ||
| if (accessFlags & AccessFlags.ReportDeprecated && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { | ||
| const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); | ||
| addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName as string); | ||
| } | ||
| @@ -25066,9 +25070,9 @@ namespace ts { | ||
| } | ||
| const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); | ||
| const sourceSymbol = localOrExportSymbol.flags & SymbolFlags.Alias ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; | ||
| if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & NodeFlags.Deprecated && isUncalledFunctionReference(node, sourceSymbol)) { | ||
| addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText as string); | ||
| const targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node); | ||
| if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) { | ||
| addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText as string); | ||
| } | ||
| let declaration = localOrExportSymbol.valueDeclaration; | ||
| @@ -28460,7 +28464,7 @@ namespace ts { | ||
| } | ||
| } | ||
| else { | ||
| if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) { | ||
| if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) { | ||
| addDeprecatedSuggestion(right, prop.declarations, right.escapedText as string); | ||
| } | ||
| checkPropertyNotUsedBeforeDeclaration(prop, node, right); | ||
| @@ -39802,10 +39806,45 @@ namespace ts { | ||
| } | ||
| } | ||
| if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) { | ||
a-tarasyuk marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string); | ||
| if (isImportSpecifier(node)) { | ||
| const targetSymbol = checkDeprecatedAliasedSymbol(symbol, node); | ||
| if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) { | ||
| addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName as string); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| function isDeprecatedAliasedSymbol(symbol: Symbol) { | ||
| return !!symbol.declarations && every(symbol.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated)); | ||
| } | ||
| function checkDeprecatedAliasedSymbol(symbol: Symbol, location: Node) { | ||
| if (!(symbol.flags & SymbolFlags.Alias)) return symbol; | ||
| const targetSymbol = resolveAlias(symbol); | ||
| if (targetSymbol === unknownSymbol) return targetSymbol; | ||
| while (symbol.flags & SymbolFlags.Alias) { | ||
| const target = getImmediateAliasedSymbol(symbol); | ||
| if (target) { | ||
| if (target === targetSymbol) break; | ||
| if (target.declarations && length(target.declarations)) { | ||
| if (isDeprecatedAliasedSymbol(target)) { | ||
| addDeprecatedSuggestion(location, target.declarations, target.escapedName as string); | ||
| break; | ||
| } | ||
| else { | ||
| if (symbol === targetSymbol) break; | ||
| symbol = target; | ||
| } | ||
| } | ||
| } | ||
| else { | ||
| break; | ||
| } | ||
| } | ||
| return targetSymbol; | ||
| } | ||
| function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) { | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /// <reference path="fourslash.ts" /> | ||
| // @module: esnext | ||
| // @filename: /a.ts | ||
| ////export const a = 1; | ||
| ////export const b = 1; | ||
| // @filename: /b.ts | ||
| ////export { | ||
| //// /** @deprecated a is deprecated */ | ||
| //// a | ||
| ////} from "./a"; | ||
| // @filename: /c.ts | ||
| ////import { [|a|] } from "./b"; | ||
| ////[|a|] | ||
| goTo.file("/c.ts") | ||
| verify.getSuggestionDiagnostics([ | ||
| { | ||
| "code": 6385, | ||
| "message": "'a' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[0] | ||
| }, | ||
| { | ||
| "code": 6385, | ||
| "message": "'a' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[1] | ||
| }, | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /// <reference path="fourslash.ts" /> | ||
| // @module: esnext | ||
| // @filename: /a.ts | ||
| ////export const a = 1; | ||
| ////export const b = 1; | ||
sandersn marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // @filename: /b.ts | ||
| ////export { | ||
| //// /** @deprecated a is deprecated */ | ||
| //// a | ||
| ////} from "./a"; | ||
| // @filename: /c.ts | ||
| ////export { | ||
| //// a | ||
| ////} from "./b"; | ||
| // @filename: /d.ts | ||
| ////import { [|a|] } from "./c"; | ||
| ////[|a|] | ||
| goTo.file("/d.ts") | ||
| verify.getSuggestionDiagnostics([ | ||
| { | ||
| "code": 6385, | ||
| "message": "'a' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[0] | ||
| }, | ||
| { | ||
| "code": 6385, | ||
| "message": "'a' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[1] | ||
| }, | ||
| ]); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /// <reference path="fourslash.ts" /> | ||
| // @module: esnext | ||
| // @filename: /a.ts | ||
| ////const a = 1; | ||
| ////const b = 1; | ||
| ////export { a, /** @deprecated b is deprecated */ b } | ||
| // @filename: /b.ts | ||
| ////import { [|b|] } from "./a"; | ||
| ////[|b|] | ||
| goTo.file("/b.ts") | ||
| verify.getSuggestionDiagnostics([ | ||
| { | ||
| "code": 6385, | ||
| "message": "'b' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[0] | ||
| }, | ||
| { | ||
| "code": 6385, | ||
| "message": "'b' is deprecated.", | ||
| "reportsDeprecated": true, | ||
| "range": test.ranges()[1] | ||
| }, | ||
| ]); |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.