-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Declaration emitter cleanup #4068
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
687d25a
initial changes
mhegazy c5c4835
visit nodes
mhegazy 5865c02
Add error reporting
mhegazy 96a2b7f
Do error reporting slightlly difrrentelly
mhegazy 46ddcbf
Walk types
mhegazy e3444c1
use track symbol insted of walking types
mhegazy b010a19
remove old diagnostics reporting
mhegazy 4e6948f
Remove isDeclarationVisible uses
mhegazy 4f1c088
rename functions with write prefix to emit
mhegazy ccba296
clean up
mhegazy e05b983
Handel visibility correctelly
mhegazy f33e422
handel internals when collecting declarations
mhegazy 820d77d
Wire trackSymbol to show errors correctelly
mhegazy 655104e
Disable internal check for now untill all code is fixed
mhegazy 7718b22
use custom indexOf instead of array.prototype.indexOf to allow runnin…
mhegazy 86c9578
Accept symbol baselines
mhegazy ceee493
A few additional fixes
mhegazy 34f0d54
rename functions
mhegazy 672fb44
use namespaces instead of module
mhegazy 6eb1df7
Ensure trackSymbol is only called for type symbols
mhegazy fc7325b
handel import clauses and export default expression
mhegazy c8a8ff5
Handel variableDeclarations and variableStatements
mhegazy 0f46057
handel binding patterns
mhegazy cb964c1
Accept baseline for export default case
mhegazy 50cf293
accept baselines
mhegazy 0e28bee
Fix error reporting issues
mhegazy a27e6f2
handel expressions in heritage clauses
mhegazy 6384dcf
Handel type paramter declarations correctelly
mhegazy ffde83c
reorder declarations
mhegazy 99d4e46
clean up collection logic
mhegazy 767e27f
Handel missing PropertyAccessExpression
mhegazy edaed88
Filter declarations from other files
mhegazy 2f3c689
use forEachChild in visitNode
mhegazy d1ce92e
Do not collect import declarations
mhegazy 6193c5a
Revert "Accept symbol baselines"
mhegazy 1d92d8e
Update error messages and fix error reporting for computed property n…
mhegazy 8209348
Accept baseline change
mhegazy d18b829
Accept baseline
mhegazy d47caa2
Handel inaccisible symbol errors
mhegazy 57aae40
accept baselines
mhegazy b44fba3
remove unused code from checker
mhegazy 1bf2d0a
Make trackSymbol optional and use an empty writer in visitNode
mhegazy 0758e15
Remove unused interfaces, and simplify the writer logic
mhegazy 4b2aa47
Reorganize how triple slash references are being emitted
mhegazy 0f58d94
remove unsused variable
mhegazy ca07040
Consolidate emit logic in one place, and split the process into two p…
mhegazy 98cd107
Switch to iterative model and clean up error reporting
mhegazy bd1347d
handel missing nodes in visitNode
mhegazy 1f0520e
Only check if hasExportDeclarations on external modules
mhegazy 859bd12
Do not create a new typewriter everytime
mhegazy 33ace7a
Merge branch 'master' into declarations
ce8090a
remove unused property
fd01a64
Support @internal
a876104
make forEachTopLevelDeclaration generic
mhegazy ab42595
Fix #3912: emit declaration for binding elements correctelly
mhegazy ed2e5d9
move getLocalTargetOfAliasDeclaration back to the emitter
mhegazy f4da2fe
Merge branch 'master' into declarations
mhegazy 4ec081c
rever sourceRoot change to tsconfig.json
mhegazy cbb4e2c
Merge branch 'master' into declarations
mhegazy 3eb940b
Merge branch 'master' into declarations
mhegazy 9ebf182
handel outFile flag
mhegazy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ensure trackSymbol is only called for type symbols
- Loading branch information
commit 6eb1df7ba0b5ead4b0f1d7b79ad1e10a734cc473
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 |
|---|---|---|
|
|
@@ -1515,15 +1515,19 @@ namespace ts { | |
| * Writes only the name of the symbol out to the writer. Uses the original source text | ||
| * for the name of the symbol if it is available to match how the user inputted the name. | ||
| */ | ||
| function appendSymbolNameOnly(symbol: Symbol, writer: SymbolWriter): void { | ||
| function appendSymbolNameOnly(symbol: Symbol, writer: SymbolWriter, isTypeSymbol: boolean): void { | ||
| writer.writeSymbol(getNameOfSymbol(symbol), symbol); | ||
|
|
||
| if (isTypeSymbol) { | ||
| writer.trackSymbol(symbol); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope | ||
| * Meaning needs to be specified if the enclosing declaration is given | ||
| */ | ||
| function buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, typeFlags?: TypeFormatFlags): void { | ||
| function buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, typeFlags?: TypeFormatFlags, isTypeSymbol?: boolean): void { | ||
| let parentSymbol: Symbol; | ||
| function appendParentTypeArgumentsAndSymbolName(symbol: Symbol): void { | ||
| if (parentSymbol) { | ||
|
|
@@ -1538,10 +1542,10 @@ namespace ts { | |
| } | ||
| } | ||
| writePunctuation(writer, SyntaxKind.DotToken); | ||
| writer.trackSymbol(symbol); | ||
| } | ||
|
|
||
| parentSymbol = symbol; | ||
| appendSymbolNameOnly(symbol, writer); | ||
| appendSymbolNameOnly(symbol, writer, isTypeSymbol); | ||
| } | ||
|
|
||
| function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { | ||
|
|
@@ -1607,9 +1611,8 @@ namespace ts { | |
| writeTypeReference(<TypeReference>type, flags); | ||
| } | ||
| else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) { | ||
| writer.trackSymbol(type.symbol); | ||
| // The specified symbol flags need to be reinterpreted as type flags | ||
| buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags); | ||
| buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags, /*isTypeSymbol*/true); | ||
| } | ||
| else if (type.flags & TypeFlags.Tuple) { | ||
| writeTupleType(<TupleType>type); | ||
|
|
@@ -1651,8 +1654,7 @@ namespace ts { | |
| // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that | ||
| // we don't want to display | ||
| if (!isReservedMemberName(symbol.name)) { | ||
| writer.trackSymbol(symbol); | ||
| buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type); | ||
| buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type, undefined, undefined, /*isTypeSymbol*/true); | ||
| } | ||
| if (pos < end) { | ||
| writePunctuation(writer, SyntaxKind.LessThanToken); | ||
|
|
@@ -1731,7 +1733,7 @@ namespace ts { | |
| let typeAlias = getTypeAliasForTypeLiteral(type); | ||
| if (typeAlias) { | ||
| // The specified symbol flags need to be reinterpreted as type flags | ||
| buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags); | ||
| buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags, /*isTypeSymbol*/true); | ||
| } | ||
| else { | ||
| // Recursive usage, use any | ||
|
|
@@ -1772,8 +1774,7 @@ namespace ts { | |
| function writeTypeofSymbol(type: ObjectType, typeFormatFlags?: TypeFormatFlags) { | ||
| writeKeyword(writer, SyntaxKind.TypeOfKeyword); | ||
| writeSpace(writer); | ||
| writer.trackSymbol(type.symbol); | ||
| buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); | ||
| buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags, /*isTypeSymbol*/true); | ||
| } | ||
|
|
||
| function getIndexerParameterName(type: ObjectType, indexKind: IndexKind, fallbackName: string): string { | ||
|
|
@@ -1903,7 +1904,7 @@ namespace ts { | |
| } | ||
|
|
||
| function buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { | ||
| appendSymbolNameOnly(tp.symbol, writer); | ||
| appendSymbolNameOnly(tp.symbol, writer, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use named parameter |
||
| let constraint = getConstraintOfTypeParameter(tp); | ||
| if (constraint) { | ||
| writeSpace(writer); | ||
|
|
@@ -1918,7 +1919,7 @@ namespace ts { | |
| if (isRestParameter(parameterNode)) { | ||
| writePunctuation(writer, SyntaxKind.DotDotDotToken); | ||
| } | ||
| appendSymbolNameOnly(p, writer); | ||
| appendSymbolNameOnly(p, writer, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use named parameter |
||
| if (isOptionalParameter(parameterNode)) { | ||
| writePunctuation(writer, SyntaxKind.QuestionToken); | ||
| } | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use named parameters here.