Skip to content

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
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
687d25a
initial changes
mhegazy Jun 30, 2015
c5c4835
visit nodes
mhegazy Jul 1, 2015
5865c02
Add error reporting
mhegazy Jul 4, 2015
96a2b7f
Do error reporting slightlly difrrentelly
mhegazy Jul 4, 2015
46ddcbf
Walk types
mhegazy Jul 7, 2015
e3444c1
use track symbol insted of walking types
mhegazy Jul 7, 2015
b010a19
remove old diagnostics reporting
mhegazy Jul 7, 2015
4e6948f
Remove isDeclarationVisible uses
mhegazy Jul 7, 2015
4f1c088
rename functions with write prefix to emit
mhegazy Jul 7, 2015
ccba296
clean up
mhegazy Jul 7, 2015
e05b983
Handel visibility correctelly
mhegazy Jul 7, 2015
f33e422
handel internals when collecting declarations
mhegazy Jul 7, 2015
820d77d
Wire trackSymbol to show errors correctelly
mhegazy Jul 7, 2015
655104e
Disable internal check for now untill all code is fixed
mhegazy Jul 7, 2015
7718b22
use custom indexOf instead of array.prototype.indexOf to allow runnin…
mhegazy Jul 7, 2015
86c9578
Accept symbol baselines
mhegazy Jul 7, 2015
ceee493
A few additional fixes
mhegazy Jul 8, 2015
34f0d54
rename functions
mhegazy Jul 8, 2015
672fb44
use namespaces instead of module
mhegazy Jul 9, 2015
6eb1df7
Ensure trackSymbol is only called for type symbols
mhegazy Jul 9, 2015
fc7325b
handel import clauses and export default expression
mhegazy Jul 9, 2015
c8a8ff5
Handel variableDeclarations and variableStatements
mhegazy Jul 9, 2015
0f46057
handel binding patterns
mhegazy Jul 9, 2015
cb964c1
Accept baseline for export default case
mhegazy Jul 10, 2015
50cf293
accept baselines
mhegazy Jul 10, 2015
0e28bee
Fix error reporting issues
mhegazy Jul 10, 2015
a27e6f2
handel expressions in heritage clauses
mhegazy Jul 10, 2015
6384dcf
Handel type paramter declarations correctelly
mhegazy Jul 10, 2015
ffde83c
reorder declarations
mhegazy Jul 10, 2015
99d4e46
clean up collection logic
mhegazy Jul 10, 2015
767e27f
Handel missing PropertyAccessExpression
mhegazy Jul 14, 2015
edaed88
Filter declarations from other files
mhegazy Jul 14, 2015
2f3c689
use forEachChild in visitNode
mhegazy Jul 14, 2015
d1ce92e
Do not collect import declarations
mhegazy Jul 14, 2015
6193c5a
Revert "Accept symbol baselines"
mhegazy Jul 14, 2015
1d92d8e
Update error messages and fix error reporting for computed property n…
mhegazy Jul 14, 2015
8209348
Accept baseline change
mhegazy Jul 14, 2015
d18b829
Accept baseline
mhegazy Jul 15, 2015
d47caa2
Handel inaccisible symbol errors
mhegazy Jul 16, 2015
57aae40
accept baselines
mhegazy Jul 16, 2015
b44fba3
remove unused code from checker
mhegazy Jul 16, 2015
1bf2d0a
Make trackSymbol optional and use an empty writer in visitNode
mhegazy Jul 16, 2015
0758e15
Remove unused interfaces, and simplify the writer logic
mhegazy Jul 16, 2015
4b2aa47
Reorganize how triple slash references are being emitted
mhegazy Jul 16, 2015
0f58d94
remove unsused variable
mhegazy Jul 17, 2015
ca07040
Consolidate emit logic in one place, and split the process into two p…
mhegazy Jul 20, 2015
98cd107
Switch to iterative model and clean up error reporting
mhegazy Jul 21, 2015
bd1347d
handel missing nodes in visitNode
mhegazy Jul 22, 2015
1f0520e
Only check if hasExportDeclarations on external modules
mhegazy Jul 22, 2015
859bd12
Do not create a new typewriter everytime
mhegazy Jul 22, 2015
33ace7a
Merge branch 'master' into declarations
Jul 27, 2015
ce8090a
remove unused property
Jul 27, 2015
fd01a64
Support @internal
Jul 28, 2015
a876104
make forEachTopLevelDeclaration generic
mhegazy Jul 28, 2015
ab42595
Fix #3912: emit declaration for binding elements correctelly
mhegazy Jul 28, 2015
ed2e5d9
move getLocalTargetOfAliasDeclaration back to the emitter
mhegazy Jul 29, 2015
f4da2fe
Merge branch 'master' into declarations
mhegazy Jul 29, 2015
4ec081c
rever sourceRoot change to tsconfig.json
mhegazy Jul 29, 2015
cbb4e2c
Merge branch 'master' into declarations
mhegazy Aug 9, 2015
3eb940b
Merge branch 'master' into declarations
mhegazy Sep 17, 2015
9ebf182
handel outFile flag
mhegazy Sep 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
396 changes: 37 additions & 359 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

1,876 changes: 1,017 additions & 859 deletions src/compiler/declarationEmitter.ts

Large diffs are not rendered by default.

91 changes: 21 additions & 70 deletions src/compiler/diagnosticInformationMap.generated.ts

Large diffs are not rendered by default.

256 changes: 32 additions & 224 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1700,307 +1700,115 @@
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
},
},
"Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": {
"category": "Error",
"code": 2653
},
},
"Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2654
},
"Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2655
},
},
"Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2656
},
"Import declaration '{0}' is using private name '{1}'.": {
},

"Import declaration '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4000
},
"Type parameter '{0}' of exported class has or is using private name '{1}'.": {
"Constraint of type parameter '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4002
},
"Type parameter '{0}' of exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4004
},
"Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4006
},
"Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4008
},
"Type parameter '{0}' of public static method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4010
},
"Type parameter '{0}' of public method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4012
},
"Type parameter '{0}' of method from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4014
},
"Type parameter '{0}' of exported function has or is using private name '{1}'.": {
"category": "Error",
"code": 4016
},
"Implements clause of exported class '{0}' has or is using private name '{1}'.": {
"Implements clause references inaccessible name '{0}'.": {
"category": "Error",
"code": 4019
},
"Extends clause of exported class '{0}' has or is using private name '{1}'.": {
"Extends clause references inaccessible name '{0}'.": {
"category": "Error",
"code": 4020
},
"Extends clause of exported interface '{0}' has or is using private name '{1}'.": {
"category": "Error",
"code": 4022
},
"Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 4023
},
"Exported variable '{0}' has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4024
},
"Exported variable '{0}' has or is using private name '{1}'.": {
"Type of variable '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4025
},
"Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"Name of inferred type of variable '{0}' could not be written. Consider adding an explicit type annotation.": {
"category": "Error",
"code": 4026
},
"Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4027
},
"Public static property '{0}' of exported class has or is using private name '{1}'.": {
"Type of property '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4028
},
"Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"Name of inferred type of property '{0}' could not be written. Consider adding an explicit type annotation.": {
"category": "Error",
"code": 4029
},
"Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'.": {
"Type of parameter '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4030
},
"Public property '{0}' of exported class has or is using private name '{1}'.": {
"Name of inferred type of parameter '{0}' could not be written. Consider adding an explicit type annotation.": {
"category": "Error",
"code": 4031
},
"Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4032
},
"Property '{0}' of exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4033
},
"Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4034
},
"Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4035
},
"Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4036
},
"Parameter '{0}' of public property setter from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4037
},
"Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"Return type of method '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4038
},
"Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'.": {
"Name of inferred return type of method '{0}' could not be written. Consider adding an explicit type annotation.": {
"category": "Error",
"code": 4039
},
"Return type of public static property getter from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 4040
},
"Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 4041
},
"Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4042
},
"Return type of public property getter from exported class has or is using private name '{0}'.": {
"Return type of property getter '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4043
},
"Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"Return type of construct signature references inaccessible name '{0}'.": {
"category": "Error",
"code": 4044
},
"Return type of constructor signature from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 4045
},
"Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4046
},
"Return type of call signature from exported interface has or is using private name '{0}'.": {
"Return type of call signature references inaccessible name '{0}'.": {
"category": "Error",
"code": 4047
},
"Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4048
},
"Return type of index signature from exported interface has or is using private name '{0}'.": {
"Return type of index signature references inaccessible name '{0}'.": {
"category": "Error",
"code": 4049
},
"Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 4050
},
"Return type of public static method from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4051
},
"Return type of public static method from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 4052
},
"Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 4053
},
"Return type of public method from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4054
},
"Return type of public method from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 4055
},
"Return type of method from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4056
},
"Return type of method from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 4057
},
"Return type of exported function has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 4058
},
"Return type of exported function has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 4059
},
"Return type of exported function has or is using private name '{0}'.": {
"Return type of function '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4060
},
"Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"Name of inferred return type of function '{0}' could not be written. Consider adding an explicit type annotation.": {
"category": "Error",
"code": 4061
},
"Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4062
},
"Parameter '{0}' of constructor from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4063
},
"Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4064
},
"Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4065
},
"Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4066
},
"Parameter '{0}' of call signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4067
},
"Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 4068
},
"Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4069
},
"Parameter '{0}' of public static method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4070
},
"Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 4071
},
"Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4072
},
"Parameter '{0}' of public method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 4073
},
"Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4074
},
"Parameter '{0}' of method from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 4075
},
"Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 4076
},
"Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 4077
},
"Parameter '{0}' of exported function has or is using private name '{1}'.": {
"category": "Error",
"code": 4078
},
"Exported type alias '{0}' has or is using private name '{1}'.": {
"Type alias '{0}' references inaccessible name '{1}'.": {
"category": "Error",
"code": 4081
},
"Default export of the module has or is using private name '{0}'.": {
"Default export of the module references inaccessible name '{0}'.": {
"category": "Error",
"code": 4082
},
"Name of inferred type of default export could not be written. Consider exporting a declaration instead.": {
"category": "Error",
"code": 4083
},


"Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher.": {
"category": "Error",
"code": 4091
},

"The current host does not support the '{0}' option.": {
"category": "Error",
"code": 5001
Expand Down
15 changes: 6 additions & 9 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}

// Emit declarations
if (compilerOptions.declaration) {
emitDeclarations(host, resolver, targetSourceFile, diagnostics);
}

// Sort and make the unique list of diagnostics
diagnostics = sortAndDeduplicateDiagnostics(diagnostics);

Expand Down Expand Up @@ -122,7 +127,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return true;
}

function emitJavaScript(jsFilePath: string, root?: SourceFile) {
function emitFile(jsFilePath: string, root?: SourceFile) {
let writer = createTextWriter(newLine);
let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;

Expand Down Expand Up @@ -7215,14 +7220,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}

function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
emitJavaScript(jsFilePath, sourceFile);

if (compilerOptions.declaration) {
writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics);
}
}
}

var entities: Map<number> = {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ namespace ts {
// Implement the parser as a singleton module. We do this for perf reasons because creating
// parser instances can actually be expensive enough to impact us on projects with many source
// files.
module Parser {
namespace Parser {
// Share a single scanner across all calls to parse a source file. This helps speed things
// up by avoiding the cost of creating/compiling scanners over and over again.
const scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
Expand Down Expand Up @@ -5945,7 +5945,7 @@ namespace ts {
}
}

module IncrementalParser {
namespace IncrementalParser {
export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks: boolean): SourceFile {
aggressiveChecks = aggressiveChecks || Debug.shouldAssert(AssertionLevel.Aggressive);

Expand Down
Loading