Addressed PR feedback: refactored away helper function, generated spec from docx

This commit is contained in:
Asad Saeeduddin 2016-01-19 15:23:57 -05:00
parent eb87bad2c8
commit 28840863a6
3 changed files with 5 additions and 9 deletions

View file

@ -265,7 +265,7 @@ function f() {
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
  ![](images/image1.png)
  ![](images/image1.png)
In this example, the programmer benefits from type inference without providing type annotations. Some beneficial tools, however, do require the programmer to provide type annotations. In TypeScript, we can express a parameter requirement as in the following code fragment.
@ -413,7 +413,7 @@ This signature denotes that a function may be passed as the parameter of the '$'
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
  ![](images/image2.png)
  ![](images/image2.png)
Section [3.3](#3.3) provides additional information about object types.
@ -630,7 +630,7 @@ An important goal of TypeScript is to provide accurate and straightforward types
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
  ![](images/image3.png)
  ![](images/image3.png)
The following code fragment uses this feature. Because the 'span' variable is inferred to have the type 'HTMLSpanElement', the code can reference without static error the 'isMultiline' property of 'span'.
@ -641,7 +641,7 @@ span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
  ![](images/image4.png)
  ![](images/image4.png)
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.

View file

@ -2466,10 +2466,6 @@ namespace ts {
return type && (type.flags & TypeFlags.Any) !== 0;
}
function isUnionContaining(type: Type, kinds: TypeFlags) {
return type && (type.flags & TypeFlags.Union) && someConstituentTypeHasKind(type, kinds);
}
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
// assigned by contextual typing.
function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
@ -10217,7 +10213,7 @@ namespace ts {
}
// Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
if (returnType === voidType || isTypeAny(returnType) || isUnionContaining(returnType, TypeFlags.Any) || isUnionContaining(returnType, TypeFlags.Void)) {
if (returnType === voidType || isTypeAny(returnType) || (returnType && (returnType.flags & TypeFlags.Union) && someConstituentTypeHasKind(returnType, TypeFlags.Any | TypeFlags.Void))) {
return;
}