Skip to content

Commit 58976ff

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into emitTypeAliasInDeclarationFile
2 parents f137c92 + fcdc07e commit 58976ff

File tree

150 files changed

+3160
-990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+3160
-990
lines changed

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ var servicesSources = [
129129
"documentRegistry.ts",
130130
"findAllReferences.ts",
131131
"goToDefinition.ts",
132+
"goToImplementation.ts",
132133
"jsDoc.ts",
133134
"jsTyping.ts",
134135
"navigateTo.ts",
@@ -789,7 +790,7 @@ function cleanTestDirs() {
789790

790791
// used to pass data from jake command line directly to run.js
791792
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit) {
792-
var testConfigContents = JSON.stringify({
793+
var testConfigContents = JSON.stringify({
793794
test: tests ? [tests] : undefined,
794795
light: light,
795796
workerCount: workerCount,

src/compiler/binder.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ namespace ts {
268268
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType);
269269
let functionType = <JSDocFunctionType>node.parent;
270270
let index = indexOf(functionType.parameters, node);
271-
return "p" + index;
271+
return "arg" + index;
272272
case SyntaxKind.JSDocTypedefTag:
273273
const parentNode = node.parent && node.parent.parent;
274274
let nameFromParentNode: string;
@@ -540,9 +540,7 @@ namespace ts {
540540
// because the scope of JsDocComment should not be affected by whether the current node is a
541541
// container or not.
542542
if (isInJavaScriptFile(node) && node.jsDocComments) {
543-
for (const jsDocComment of node.jsDocComments) {
544-
bind(jsDocComment);
545-
}
543+
forEach(node.jsDocComments, bind);
546544
}
547545
if (checkUnreachable(node)) {
548546
forEachChild(node, bind);

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@ namespace ts {
914914
}
915915
}
916916

917-
// If we're in an external module, we can't reference symbols created from UMD export declarations
918-
if (result && isInExternalModule) {
917+
// If we're in an external module, we can't reference value symbols created from UMD export declarations
918+
if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
919919
const decls = result.declarations;
920920
if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
921921
error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
@@ -5668,12 +5668,13 @@ namespace ts {
56685668
case SyntaxKind.JSDocThisType:
56695669
case SyntaxKind.JSDocOptionalType:
56705670
return getTypeFromTypeNode((<ParenthesizedTypeNode | JSDocTypeReferencingNode>node).type);
5671+
case SyntaxKind.JSDocRecordType:
5672+
return getTypeFromTypeNode((node as JSDocRecordType).literal);
56715673
case SyntaxKind.FunctionType:
56725674
case SyntaxKind.ConstructorType:
56735675
case SyntaxKind.TypeLiteral:
56745676
case SyntaxKind.JSDocTypeLiteral:
56755677
case SyntaxKind.JSDocFunctionType:
5676-
case SyntaxKind.JSDocRecordType:
56775678
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments);
56785679
// This function assumes that an identifier or qualified name is a type expression
56795680
// Callers should first ensure this by calling isTypeNode

src/compiler/parser.ts

Lines changed: 271 additions & 141 deletions
Large diffs are not rendered by default.

src/compiler/scanner.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,40 +1759,46 @@ namespace ts {
17591759
}
17601760

17611761
startPos = pos;
1762-
1763-
// Eat leading whitespace
1764-
let ch = text.charCodeAt(pos);
1765-
while (pos < end) {
1766-
ch = text.charCodeAt(pos);
1767-
if (isWhiteSpaceSingleLine(ch)) {
1768-
pos++;
1769-
}
1770-
else {
1771-
break;
1772-
}
1773-
}
17741762
tokenPos = pos;
17751763

1764+
const ch = text.charCodeAt(pos);
17761765
switch (ch) {
1766+
case CharacterCodes.tab:
1767+
case CharacterCodes.verticalTab:
1768+
case CharacterCodes.formFeed:
1769+
case CharacterCodes.space:
1770+
while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
1771+
pos++;
1772+
}
1773+
return token = SyntaxKind.WhitespaceTrivia;
17771774
case CharacterCodes.at:
1778-
return pos += 1, token = SyntaxKind.AtToken;
1775+
pos++;
1776+
return token = SyntaxKind.AtToken;
17791777
case CharacterCodes.lineFeed:
17801778
case CharacterCodes.carriageReturn:
1781-
return pos += 1, token = SyntaxKind.NewLineTrivia;
1779+
pos++;
1780+
return token = SyntaxKind.NewLineTrivia;
17821781
case CharacterCodes.asterisk:
1783-
return pos += 1, token = SyntaxKind.AsteriskToken;
1782+
pos++;
1783+
return token = SyntaxKind.AsteriskToken;
17841784
case CharacterCodes.openBrace:
1785-
return pos += 1, token = SyntaxKind.OpenBraceToken;
1785+
pos++;
1786+
return token = SyntaxKind.OpenBraceToken;
17861787
case CharacterCodes.closeBrace:
1787-
return pos += 1, token = SyntaxKind.CloseBraceToken;
1788+
pos++;
1789+
return token = SyntaxKind.CloseBraceToken;
17881790
case CharacterCodes.openBracket:
1789-
return pos += 1, token = SyntaxKind.OpenBracketToken;
1791+
pos++;
1792+
return token = SyntaxKind.OpenBracketToken;
17901793
case CharacterCodes.closeBracket:
1791-
return pos += 1, token = SyntaxKind.CloseBracketToken;
1794+
pos++;
1795+
return token = SyntaxKind.CloseBracketToken;
17921796
case CharacterCodes.equals:
1793-
return pos += 1, token = SyntaxKind.EqualsToken;
1797+
pos++;
1798+
return token = SyntaxKind.EqualsToken;
17941799
case CharacterCodes.comma:
1795-
return pos += 1, token = SyntaxKind.CommaToken;
1800+
pos++;
1801+
return token = SyntaxKind.CommaToken;
17961802
}
17971803

17981804
if (isIdentifierStart(ch, ScriptTarget.Latest)) {

src/compiler/transformers/module/module.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -804,17 +804,17 @@ namespace ts {
804804
* Adds a trailing VariableStatement for an enum or module declaration.
805805
*/
806806
function addVarForExportedEnumOrNamespaceDeclaration(statements: Statement[], node: EnumDeclaration | ModuleDeclaration) {
807-
statements.push(
808-
createVariableStatement(
809-
/*modifiers*/ undefined,
810-
[createVariableDeclaration(
811-
getDeclarationName(node),
807+
const transformedStatement = createVariableStatement(
808+
/*modifiers*/ undefined,
809+
[createVariableDeclaration(
810+
getDeclarationName(node),
812811
/*type*/ undefined,
813-
createPropertyAccess(createIdentifier("exports"), getDeclarationName(node))
814-
)],
812+
createPropertyAccess(createIdentifier("exports"), getDeclarationName(node))
813+
)],
815814
/*location*/ node
816-
)
817815
);
816+
setNodeEmitFlags(transformedStatement, NodeEmitFlags.NoComments);
817+
statements.push(transformedStatement);
818818
}
819819

820820
function getDeclarationName(node: DeclarationStatement) {

src/compiler/transformers/ts.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,19 +694,21 @@ namespace ts {
694694

695695
// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
696696
// or decoratedClassAlias if the class contain self-reference.
697+
const transformedClassExpression = createVariableStatement(
698+
/*modifiers*/ undefined,
699+
createLetDeclarationList([
700+
createVariableDeclaration(
701+
classAlias || declaredName,
702+
/*type*/ undefined,
703+
classExpression
704+
)
705+
]),
706+
/*location*/ location
707+
);
708+
setCommentRange(transformedClassExpression, node);
697709
statements.push(
698710
setOriginalNode(
699-
createVariableStatement(
700-
/*modifiers*/ undefined,
701-
createLetDeclarationList([
702-
createVariableDeclaration(
703-
classAlias || declaredName,
704-
/*type*/ undefined,
705-
classExpression
706-
)
707-
]),
708-
/*location*/ location
709-
),
711+
/*node*/ transformedClassExpression,
710712
/*original*/ node
711713
)
712714
);

src/compiler/types.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ namespace ts {
487487
parent?: Node; // Parent node (initialized by binding)
488488
/* @internal */ original?: Node; // The original node if this is an updated node.
489489
/* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms).
490-
/* @internal */ jsDocComments?: JSDocComment[]; // JSDoc for the node, if it has any. Only for .js files.
490+
/* @internal */ jsDocComments?: JSDoc[]; // JSDoc for the node, if it has any.
491491
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
492492
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
493493
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
@@ -1555,7 +1555,7 @@ namespace ts {
15551555

15561556
// @kind(SyntaxKind.JSDocRecordType)
15571557
export interface JSDocRecordType extends JSDocType, TypeLiteralNode {
1558-
members: NodeArray<JSDocRecordMember>;
1558+
literal: TypeLiteralNode;
15591559
}
15601560

15611561
// @kind(SyntaxKind.JSDocTypeReference)
@@ -1603,14 +1603,16 @@ namespace ts {
16031603
}
16041604

16051605
// @kind(SyntaxKind.JSDocComment)
1606-
export interface JSDocComment extends Node {
1606+
export interface JSDoc extends Node {
16071607
tags: NodeArray<JSDocTag>;
1608+
comment: string | undefined;
16081609
}
16091610

16101611
// @kind(SyntaxKind.JSDocTag)
16111612
export interface JSDocTag extends Node {
16121613
atToken: Node;
16131614
tagName: Identifier;
1615+
comment: string | undefined;
16141616
}
16151617

16161618
// @kind(SyntaxKind.JSDocTemplateTag)
@@ -1649,9 +1651,13 @@ namespace ts {
16491651

16501652
// @kind(SyntaxKind.JSDocParameterTag)
16511653
export interface JSDocParameterTag extends JSDocTag {
1654+
/** the parameter name, if provided *before* the type (TypeScript-style) */
16521655
preParameterName?: Identifier;
16531656
typeExpression?: JSDocTypeExpression;
1657+
/** the parameter name, if provided *after* the type (JSDoc-standard) */
16541658
postParameterName?: Identifier;
1659+
/** the parameter name, regardless of the location it was provided */
1660+
parameterName: Identifier;
16551661
isBracketed: boolean;
16561662
}
16571663

0 commit comments

Comments
 (0)