Skip to content

Commit 3e8fb37

Browse files
Merge remote-tracking branch 'origin/master' into useReturnedThisFromSuperCalls
2 parents 6580262 + 19aac12 commit 3e8fb37

File tree

306 files changed

+4769
-1748
lines changed

Some content is hidden

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

306 files changed

+4769
-1748
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: 31 additions & 15 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);
@@ -1758,15 +1758,23 @@ namespace ts {
17581758
return false;
17591759
}
17601760

1761-
function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult {
1761+
/**
1762+
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
1763+
*
1764+
* @param symbol a Symbol to check if accessible
1765+
* @param enclosingDeclaration a Node containing reference to the symbol
1766+
* @param meaning a SymbolFlags to check if such meaning of the symbol is accessible
1767+
* @param shouldComputeAliasToMakeVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible
1768+
*/
1769+
function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult {
17621770
if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) {
17631771
const initialSymbol = symbol;
17641772
let meaningToLook = meaning;
17651773
while (symbol) {
17661774
// Symbol is accessible if it by itself is accessible
17671775
const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false);
17681776
if (accessibleSymbolChain) {
1769-
const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]);
1777+
const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
17701778
if (!hasAccessibleDeclarations) {
17711779
return <SymbolAccessibilityResult>{
17721780
accessibility: SymbolAccessibility.NotAccessible,
@@ -1830,7 +1838,7 @@ namespace ts {
18301838
return isAmbientModule(declaration) || (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>declaration));
18311839
}
18321840

1833-
function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult {
1841+
function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult {
18341842
let aliasesToMakeVisible: AnyImportSyntax[];
18351843
if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) {
18361844
return undefined;
@@ -1846,14 +1854,19 @@ namespace ts {
18461854
if (anyImportSyntax &&
18471855
!(getModifierFlags(anyImportSyntax) & ModifierFlags.Export) && // import clause without export
18481856
isDeclarationVisible(<Declaration>anyImportSyntax.parent)) {
1849-
getNodeLinks(declaration).isVisible = true;
1850-
if (aliasesToMakeVisible) {
1851-
if (!contains(aliasesToMakeVisible, anyImportSyntax)) {
1852-
aliasesToMakeVisible.push(anyImportSyntax);
1857+
// In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types,
1858+
// we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time
1859+
// since we will do the emitting later in trackSymbol.
1860+
if (shouldComputeAliasToMakeVisible) {
1861+
getNodeLinks(declaration).isVisible = true;
1862+
if (aliasesToMakeVisible) {
1863+
if (!contains(aliasesToMakeVisible, anyImportSyntax)) {
1864+
aliasesToMakeVisible.push(anyImportSyntax);
1865+
}
1866+
}
1867+
else {
1868+
aliasesToMakeVisible = [anyImportSyntax];
18531869
}
1854-
}
1855-
else {
1856-
aliasesToMakeVisible = [anyImportSyntax];
18571870
}
18581871
return true;
18591872
}
@@ -1888,7 +1901,7 @@ namespace ts {
18881901
const symbol = resolveName(enclosingDeclaration, (<Identifier>firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
18891902

18901903
// Verify if the symbol is accessible
1891-
return (symbol && hasVisibleDeclarations(symbol)) || <SymbolVisibilityResult>{
1904+
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || <SymbolVisibilityResult>{
18921905
accessibility: SymbolAccessibility.NotAccessible,
18931906
errorSymbolName: getTextOfNode(firstIdentifier),
18941907
errorNode: firstIdentifier
@@ -2163,7 +2176,9 @@ namespace ts {
21632176
// The specified symbol flags need to be reinterpreted as type flags
21642177
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags);
21652178
}
2166-
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) {
2179+
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol &&
2180+
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
2181+
// Only write out inferred type with its corresponding type-alias if type-alias is visible
21672182
const typeArguments = type.aliasTypeArguments;
21682183
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
21692184
}
@@ -5653,12 +5668,13 @@ namespace ts {
56535668
case SyntaxKind.JSDocThisType:
56545669
case SyntaxKind.JSDocOptionalType:
56555670
return getTypeFromTypeNode((<ParenthesizedTypeNode | JSDocTypeReferencingNode>node).type);
5671+
case SyntaxKind.JSDocRecordType:
5672+
return getTypeFromTypeNode((node as JSDocRecordType).literal);
56565673
case SyntaxKind.FunctionType:
56575674
case SyntaxKind.ConstructorType:
56585675
case SyntaxKind.TypeLiteral:
56595676
case SyntaxKind.JSDocTypeLiteral:
56605677
case SyntaxKind.JSDocFunctionType:
5661-
case SyntaxKind.JSDocRecordType:
56625678
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments);
56635679
// This function assumes that an identifier or qualified name is a type expression
56645680
// Callers should first ensure this by calling isTypeNode

src/compiler/declarationEmitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ namespace ts {
306306
}
307307

308308
function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
309-
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
309+
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true));
310310
recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
311311
}
312312

0 commit comments

Comments
 (0)