mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #3456 from Microsoft/utf8AllTheThings
Ensure files are valid UTF8
This commit is contained in:
@@ -3603,7 +3603,8 @@ module ts {
|
||||
function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments): Type {
|
||||
let links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
// We only support expressions that are simple qualified names. For other expressions this produces undefined.
let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (<TypeReferenceNode>node).typeName :
|
||||
// We only support expressions that are simple qualified names. For other expressions this produces undefined.
|
||||
let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (<TypeReferenceNode>node).typeName :
|
||||
isSupportedExpressionWithTypeArguments(<ExpressionWithTypeArguments>node) ? (<ExpressionWithTypeArguments>node).expression :
|
||||
undefined;
|
||||
let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol;
|
||||
@@ -5255,14 +5256,14 @@ module ts {
|
||||
if (source.typePredicate && target.typePredicate) {
|
||||
if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) {
|
||||
// Return types from type predicates are treated as booleans. In order to infer types
|
||||
// from type predicates we would need to infer from the type of type predicates. Since
|
||||
// we can't infer any type information from the return types — we can just add a return
|
||||
// statement after the below infer type statement.
|
||||
// from type predicates we would need to infer using the type within the type predicate
|
||||
// (i.e. 'Foo' from 'x is Foo').
|
||||
inferFromTypes(source.typePredicate.type, target.typePredicate.type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
||||
else {
|
||||
inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
||||
}
|
||||
}
|
||||
|
||||
function inferFromIndexTypes(source: Type, target: Type, sourceKind: IndexKind, targetKind: IndexKind) {
|
||||
|
||||
+8
-10
@@ -1903,23 +1903,21 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
function emitNewExpression(node: NewExpression) {
|
||||
write("new ");
|
||||
|
||||
// Spread operator logic can be supported in new expressions in ES5 using a combination
|
||||
// Spread operator logic is supported in new expressions in ES5 using a combination
|
||||
// of Function.prototype.bind() and Function.prototype.apply().
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var arguments = [1, 2, 3, 4, 5];
|
||||
// new Array(...arguments);
|
||||
// var args = [1, 2, 3, 4, 5];
|
||||
// new Array(...args);
|
||||
//
|
||||
// Could be transpiled into ES5:
|
||||
// is compiled into the following ES5:
|
||||
//
|
||||
// var arguments = [1, 2, 3, 4, 5];
|
||||
// new (Array.bind.apply(Array, [void 0].concat(arguments)));
|
||||
// var args = [1, 2, 3, 4, 5];
|
||||
// new (Array.bind.apply(Array, [void 0].concat(args)));
|
||||
//
|
||||
// `[void 0]` is the first argument which represents `thisArg` to the bind method above.
|
||||
// And `thisArg` will be set to the return value of the constructor when instantiated
|
||||
// with the new operator — regardless of any value we set `thisArg` to. Thus, we set it
|
||||
// to an undefined, `void 0`.
|
||||
// The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new',
|
||||
// Thus, we set it to undefined ('void 0').
|
||||
if (languageVersion === ScriptTarget.ES5 &&
|
||||
node.arguments &&
|
||||
hasSpreadElement(node.arguments)) {
|
||||
|
||||
Reference in New Issue
Block a user