mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into import_completions_pr
This commit is contained in:
@@ -49,3 +49,4 @@ internal/
|
||||
**/.vscode
|
||||
!**/.vscode/tasks.json
|
||||
!tests/cases/projects/projectOption/**/node_modules
|
||||
!tests/cases/projects/NodeModulesSearch/**/*
|
||||
|
||||
+5
-2
@@ -69,12 +69,15 @@ function exec(cmd: string, args: string[], complete: () => void = (() => {}), er
|
||||
console.log(`${cmd} ${args.join(" ")}`);
|
||||
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
|
||||
const subshellFlag = isWin ? "/c" : "-c";
|
||||
const command = isWin ? [cmd, ...args] : [`${cmd} ${args.join(" ")}`];
|
||||
const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
|
||||
const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true } as any);
|
||||
ex.on("exit", (code) => code === 0 ? complete() : error(/*e*/ undefined, code));
|
||||
ex.on("error", error);
|
||||
}
|
||||
|
||||
function possiblyQuote(cmd: string) {
|
||||
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
|
||||
}
|
||||
|
||||
let useDebugMode = true;
|
||||
let host = cmdLineOptions["host"];
|
||||
@@ -647,7 +650,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
testTimeout = 100000;
|
||||
testTimeout = 400000;
|
||||
}
|
||||
|
||||
const colors = cmdLineOptions["colors"];
|
||||
|
||||
+1
-1
@@ -750,7 +750,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
testTimeout = 100000;
|
||||
testTimeout = 400000;
|
||||
}
|
||||
|
||||
colors = process.env.colors || process.env.color;
|
||||
|
||||
@@ -21,7 +21,7 @@ Third Party Code Components
|
||||
--------------------------------------------
|
||||
|
||||
------------------- DefinitelyTyped --------------------
|
||||
This file is based on or incorporates material from the projects listed below (collectively ?Third Party Code?). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
|
||||
This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
|
||||
DefinitelyTyped
|
||||
This project is licensed under the MIT license.
|
||||
Copyrights are respective of each contributor listed at the beginning of each definition file.
|
||||
|
||||
+5
-16
@@ -1,24 +1,13 @@
|
||||
<!--
|
||||
Thank you for contributing to TypeScript! Please review this checklist
|
||||
before submitting your issue.
|
||||
[ ] Many common issues and suggestions are addressed in the FAQ
|
||||
https://github.com/Microsoft/TypeScript/wiki/FAQ
|
||||
[ ] Search for duplicates before logging new issues
|
||||
https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue
|
||||
[ ] Questions are best asked and answered at Stack Overflow
|
||||
http://stackoverflow.com/questions/tagged/typescript
|
||||
<!-- BUGS: Please use this template. -->
|
||||
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
|
||||
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
|
||||
|
||||
For bug reports, please include the information below.
|
||||
__________________________________________________________ -->
|
||||
|
||||
**TypeScript Version:**
|
||||
|
||||
1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217)
|
||||
**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx)
|
||||
|
||||
**Code**
|
||||
|
||||
```ts
|
||||
// A self-contained demonstration of the problem follows...
|
||||
// A *self-contained* demonstration of the problem follows...
|
||||
|
||||
```
|
||||
|
||||
|
||||
+301
-100
@@ -2281,6 +2281,9 @@ var ts;
|
||||
Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" },
|
||||
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
|
||||
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
|
||||
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
|
||||
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
|
||||
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -8736,8 +8739,11 @@ var ts;
|
||||
if (lhs.kind === 69) {
|
||||
return lhs.text === rhs.text;
|
||||
}
|
||||
return lhs.right.text === rhs.right.text &&
|
||||
tagNamesAreEquivalent(lhs.left, rhs.left);
|
||||
if (lhs.kind === 97) {
|
||||
return true;
|
||||
}
|
||||
return lhs.name.text === rhs.name.text &&
|
||||
tagNamesAreEquivalent(lhs.expression, rhs.expression);
|
||||
}
|
||||
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
|
||||
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
|
||||
@@ -8834,15 +8840,15 @@ var ts;
|
||||
}
|
||||
function parseJsxElementName() {
|
||||
scanJsxIdentifier();
|
||||
var elementName = parseIdentifierName();
|
||||
var expression = token === 97 ?
|
||||
parseTokenNode() : parseIdentifierName();
|
||||
while (parseOptional(21)) {
|
||||
scanJsxIdentifier();
|
||||
var node = createNode(139, elementName.pos);
|
||||
node.left = elementName;
|
||||
node.right = parseIdentifierName();
|
||||
elementName = finishNode(node);
|
||||
var propertyAccess = createNode(172, expression.pos);
|
||||
propertyAccess.expression = expression;
|
||||
propertyAccess.name = parseRightSideOfDot(true);
|
||||
expression = finishNode(propertyAccess);
|
||||
}
|
||||
return elementName;
|
||||
return expression;
|
||||
}
|
||||
function parseJsxExpression(inExpressionContext) {
|
||||
var node = createNode(248);
|
||||
@@ -9620,7 +9626,7 @@ var ts;
|
||||
case 56:
|
||||
return parseExportAssignment(fullStart, decorators, modifiers);
|
||||
case 116:
|
||||
return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers);
|
||||
return parseNamespaceExportDeclaration(fullStart, decorators, modifiers);
|
||||
default:
|
||||
return parseExportDeclaration(fullStart, decorators, modifiers);
|
||||
}
|
||||
@@ -10134,7 +10140,7 @@ var ts;
|
||||
function nextTokenIsSlash() {
|
||||
return nextToken() === 39;
|
||||
}
|
||||
function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) {
|
||||
function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) {
|
||||
var exportDeclaration = createNode(228, fullStart);
|
||||
exportDeclaration.decorators = decorators;
|
||||
exportDeclaration.modifiers = modifiers;
|
||||
@@ -13805,7 +13811,7 @@ var ts;
|
||||
function getTargetOfImportSpecifier(node) {
|
||||
return getExternalModuleMember(node.parent.parent.parent, node);
|
||||
}
|
||||
function getTargetOfGlobalModuleExportDeclaration(node) {
|
||||
function getTargetOfNamespaceExportDeclaration(node) {
|
||||
return resolveExternalModuleSymbol(node.parent.symbol);
|
||||
}
|
||||
function getTargetOfExportSpecifier(node) {
|
||||
@@ -13831,7 +13837,7 @@ var ts;
|
||||
case 235:
|
||||
return getTargetOfExportAssignment(node);
|
||||
case 228:
|
||||
return getTargetOfGlobalModuleExportDeclaration(node);
|
||||
return getTargetOfNamespaceExportDeclaration(node);
|
||||
}
|
||||
}
|
||||
function resolveSymbol(symbol) {
|
||||
@@ -13914,9 +13920,12 @@ var ts;
|
||||
var left = name.kind === 139 ? name.left : name.expression;
|
||||
var right = name.kind === 139 ? name.right : name.name;
|
||||
var namespace = resolveEntityName(left, 1536, ignoreErrors);
|
||||
if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) {
|
||||
if (!namespace || ts.nodeIsMissing(right)) {
|
||||
return undefined;
|
||||
}
|
||||
else if (namespace === unknownSymbol) {
|
||||
return namespace;
|
||||
}
|
||||
symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning);
|
||||
if (!symbol) {
|
||||
if (!ignoreErrors) {
|
||||
@@ -14877,16 +14886,13 @@ var ts;
|
||||
writePunctuation(writer, 27);
|
||||
}
|
||||
}
|
||||
function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) {
|
||||
function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) {
|
||||
writePunctuation(writer, 17);
|
||||
if (thisType) {
|
||||
writeKeyword(writer, 97);
|
||||
writePunctuation(writer, 54);
|
||||
writeSpace(writer);
|
||||
buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack);
|
||||
if (thisParameter) {
|
||||
buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
for (var i = 0; i < parameters.length; i++) {
|
||||
if (i > 0 || thisType) {
|
||||
if (i > 0 || thisParameter) {
|
||||
writePunctuation(writer, 24);
|
||||
writeSpace(writer);
|
||||
}
|
||||
@@ -14934,7 +14940,7 @@ var ts;
|
||||
else {
|
||||
buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack);
|
||||
buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack);
|
||||
buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
return _displayBuilder || (_displayBuilder = {
|
||||
@@ -15265,12 +15271,13 @@ var ts;
|
||||
if (func.kind === 150 && !ts.hasDynamicName(func)) {
|
||||
var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149);
|
||||
if (getter) {
|
||||
var signature = getSignatureFromDeclaration(getter);
|
||||
var getterSignature = getSignatureFromDeclaration(getter);
|
||||
var thisParameter = getAccessorThisParameter(func);
|
||||
if (thisParameter && declaration === thisParameter) {
|
||||
return signature.thisType;
|
||||
ts.Debug.assert(!thisParameter.type);
|
||||
return getTypeOfSymbol(getterSignature.thisParameter);
|
||||
}
|
||||
return getReturnTypeOfSignature(signature);
|
||||
return getReturnTypeOfSignature(getterSignature);
|
||||
}
|
||||
}
|
||||
var type = declaration.symbol.name === "this"
|
||||
@@ -15428,14 +15435,12 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getAnnotatedAccessorThisType(accessor) {
|
||||
if (accessor) {
|
||||
var parameter = getAccessorThisParameter(accessor);
|
||||
if (parameter && parameter.type) {
|
||||
return getTypeFromTypeNode(accessor.parameters[0].type);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
function getAnnotatedAccessorThisParameter(accessor) {
|
||||
var parameter = getAccessorThisParameter(accessor);
|
||||
return parameter && parameter.symbol;
|
||||
}
|
||||
function getThisTypeOfDeclaration(declaration) {
|
||||
return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
|
||||
}
|
||||
function getTypeOfAccessors(symbol) {
|
||||
var links = getSymbolLinks(symbol);
|
||||
@@ -16015,12 +16020,12 @@ var ts;
|
||||
type.typeArguments : ts.concatenate(type.typeArguments, [type]);
|
||||
resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
|
||||
}
|
||||
function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) {
|
||||
function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) {
|
||||
var sig = new Signature(checker);
|
||||
sig.declaration = declaration;
|
||||
sig.typeParameters = typeParameters;
|
||||
sig.parameters = parameters;
|
||||
sig.thisType = thisType;
|
||||
sig.thisParameter = thisParameter;
|
||||
sig.resolvedReturnType = resolvedReturnType;
|
||||
sig.typePredicate = typePredicate;
|
||||
sig.minArgumentCount = minArgumentCount;
|
||||
@@ -16029,7 +16034,7 @@ var ts;
|
||||
return sig;
|
||||
}
|
||||
function cloneSignature(sig) {
|
||||
return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
|
||||
return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
|
||||
}
|
||||
function getDefaultConstructSignatures(classType) {
|
||||
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
@@ -16113,8 +16118,9 @@ var ts;
|
||||
var s = signature;
|
||||
if (unionSignatures.length > 1) {
|
||||
s = cloneSignature(signature);
|
||||
if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) {
|
||||
s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; }));
|
||||
if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
|
||||
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }));
|
||||
s.thisParameter = createTransientSymbol(signature.thisParameter, thisType);
|
||||
}
|
||||
s.resolvedReturnType = undefined;
|
||||
s.unionSignatures = unionSignatures;
|
||||
@@ -16299,6 +16305,7 @@ var ts;
|
||||
var types = containingType.types;
|
||||
var props;
|
||||
var commonFlags = (containingType.flags & 32768) ? 536870912 : 0;
|
||||
var isReadonly = false;
|
||||
for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
|
||||
var current = types_2[_i];
|
||||
var type = getApparentType(current);
|
||||
@@ -16312,6 +16319,9 @@ var ts;
|
||||
else if (!ts.contains(props, prop)) {
|
||||
props.push(prop);
|
||||
}
|
||||
if (isReadonlySymbol(prop)) {
|
||||
isReadonly = true;
|
||||
}
|
||||
}
|
||||
else if (containingType.flags & 16384) {
|
||||
return undefined;
|
||||
@@ -16339,6 +16349,7 @@ var ts;
|
||||
commonFlags, name);
|
||||
result.containingType = containingType;
|
||||
result.declarations = declarations;
|
||||
result.isReadonly = isReadonly;
|
||||
result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
||||
return result;
|
||||
}
|
||||
@@ -16497,7 +16508,7 @@ var ts;
|
||||
var parameters = [];
|
||||
var hasStringLiterals = false;
|
||||
var minArgumentCount = -1;
|
||||
var thisType = undefined;
|
||||
var thisParameter = undefined;
|
||||
var hasThisParameter = void 0;
|
||||
var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
|
||||
for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) {
|
||||
@@ -16509,7 +16520,7 @@ var ts;
|
||||
}
|
||||
if (i === 0 && paramSymbol.name === "this") {
|
||||
hasThisParameter = true;
|
||||
thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType;
|
||||
thisParameter = param.symbol;
|
||||
}
|
||||
else {
|
||||
parameters.push(paramSymbol);
|
||||
@@ -16528,10 +16539,12 @@ var ts;
|
||||
}
|
||||
if ((declaration.kind === 149 || declaration.kind === 150) &&
|
||||
!ts.hasDynamicName(declaration) &&
|
||||
(!hasThisParameter || thisType === unknownType)) {
|
||||
(!hasThisParameter || !thisParameter)) {
|
||||
var otherKind = declaration.kind === 149 ? 150 : 149;
|
||||
var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind);
|
||||
thisType = getAnnotatedAccessorThisType(setter);
|
||||
var other = ts.getDeclarationOfKind(declaration.symbol, otherKind);
|
||||
if (other) {
|
||||
thisParameter = getAnnotatedAccessorThisParameter(other);
|
||||
}
|
||||
}
|
||||
if (minArgumentCount < 0) {
|
||||
minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0);
|
||||
@@ -16549,7 +16562,7 @@ var ts;
|
||||
var typePredicate = declaration.type && declaration.type.kind === 154 ?
|
||||
createTypePredicateFromTypePredicateNode(declaration.type) :
|
||||
undefined;
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals);
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals);
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
@@ -16619,6 +16632,11 @@ var ts;
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
function getThisTypeOfSignature(signature) {
|
||||
if (signature.thisParameter) {
|
||||
return getTypeOfSymbol(signature.thisParameter);
|
||||
}
|
||||
}
|
||||
function getReturnTypeOfSignature(signature) {
|
||||
if (!signature.resolvedReturnType) {
|
||||
if (!pushTypeResolution(signature, 3)) {
|
||||
@@ -17336,7 +17354,7 @@ var ts;
|
||||
if (signature.typePredicate) {
|
||||
freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper);
|
||||
}
|
||||
var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
|
||||
var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
|
||||
result.target = signature;
|
||||
result.mapper = mapper;
|
||||
return result;
|
||||
@@ -17539,16 +17557,20 @@ var ts;
|
||||
source = getErasedSignature(source);
|
||||
target = getErasedSignature(target);
|
||||
var result = -1;
|
||||
if (source.thisType && target.thisType && source.thisType !== voidType) {
|
||||
var related = compareTypes(source.thisType, target.thisType, false)
|
||||
|| compareTypes(target.thisType, source.thisType, reportErrors);
|
||||
if (!related) {
|
||||
if (reportErrors) {
|
||||
errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
||||
var sourceThisType = getThisTypeOfSignature(source);
|
||||
if (sourceThisType && sourceThisType !== voidType) {
|
||||
var targetThisType = getThisTypeOfSignature(target);
|
||||
if (targetThisType) {
|
||||
var related = compareTypes(sourceThisType, targetThisType, false)
|
||||
|| compareTypes(targetThisType, sourceThisType, reportErrors);
|
||||
if (!related) {
|
||||
if (reportErrors) {
|
||||
errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
result &= related;
|
||||
}
|
||||
result &= related;
|
||||
}
|
||||
var sourceMax = getNumNonRestParameters(source);
|
||||
var targetMax = getNumNonRestParameters(target);
|
||||
@@ -18366,12 +18388,18 @@ var ts;
|
||||
source = getErasedSignature(source);
|
||||
target = getErasedSignature(target);
|
||||
var result = -1;
|
||||
if (!ignoreThisTypes && source.thisType && target.thisType) {
|
||||
var related = compareTypes(source.thisType, target.thisType);
|
||||
if (!related) {
|
||||
return 0;
|
||||
if (!ignoreThisTypes) {
|
||||
var sourceThisType = getThisTypeOfSignature(source);
|
||||
if (sourceThisType) {
|
||||
var targetThisType = getThisTypeOfSignature(target);
|
||||
if (targetThisType) {
|
||||
var related = compareTypes(sourceThisType, targetThisType);
|
||||
if (!related) {
|
||||
return 0;
|
||||
}
|
||||
result &= related;
|
||||
}
|
||||
}
|
||||
result &= related;
|
||||
}
|
||||
var targetLen = target.parameters.length;
|
||||
for (var i = 0; i < targetLen; i++) {
|
||||
@@ -19634,8 +19662,20 @@ var ts;
|
||||
}
|
||||
return container === declarationContainer;
|
||||
}
|
||||
function updateReferencesForInterfaceHeritiageClauseTargets(node) {
|
||||
var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node);
|
||||
if (extendedTypeNode) {
|
||||
var t = getTypeFromTypeNode(extendedTypeNode);
|
||||
if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
t.symbol.hasReference = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkIdentifier(node) {
|
||||
var symbol = getResolvedSymbol(node);
|
||||
if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
symbol.hasReference = true;
|
||||
}
|
||||
if (symbol === argumentsSymbol) {
|
||||
var container = ts.getContainingFunction(node);
|
||||
if (container.kind === 180) {
|
||||
@@ -19845,9 +19885,9 @@ var ts;
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
var signature = getSignatureFromDeclaration(container);
|
||||
if (signature.thisType) {
|
||||
return signature.thisType;
|
||||
var thisType = getThisTypeOfDeclaration(container);
|
||||
if (thisType) {
|
||||
return thisType;
|
||||
}
|
||||
}
|
||||
if (ts.isClassLike(container.parent)) {
|
||||
@@ -19990,7 +20030,7 @@ var ts;
|
||||
if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) {
|
||||
var contextualSignature = getContextualSignature(func);
|
||||
if (contextualSignature) {
|
||||
return contextualSignature.thisType;
|
||||
return getThisTypeOfSignature(contextualSignature);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@@ -20572,7 +20612,7 @@ var ts;
|
||||
return name.indexOf("-") < 0;
|
||||
}
|
||||
function isJsxIntrinsicIdentifier(tagName) {
|
||||
if (tagName.kind === 139) {
|
||||
if (tagName.kind === 172 || tagName.kind === 97) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -20708,6 +20748,25 @@ var ts;
|
||||
return getResolvedJsxType(node, type, elemClassType);
|
||||
}));
|
||||
}
|
||||
if (elemType.flags & 2) {
|
||||
return anyType;
|
||||
}
|
||||
else if (elemType.flags & 256) {
|
||||
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
|
||||
if (intrinsicElementsType !== unknownType) {
|
||||
var stringLiteralTypeName = elemType.text;
|
||||
var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
|
||||
if (intrinsicProp) {
|
||||
return getTypeOfSymbol(intrinsicProp);
|
||||
}
|
||||
var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
|
||||
if (indexSignatureType) {
|
||||
return indexSignatureType;
|
||||
}
|
||||
error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
var elemInstanceType = getJsxElementInstanceType(node, elemType);
|
||||
if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) {
|
||||
if (jsxElementType) {
|
||||
@@ -20952,6 +21011,9 @@ var ts;
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
prop.hasReference = true;
|
||||
}
|
||||
getNodeLinks(node).resolvedSymbol = prop;
|
||||
if (prop.parent && prop.parent.flags & 32) {
|
||||
checkClassPropertyAccess(node, left, apparentType, prop);
|
||||
@@ -21264,10 +21326,11 @@ var ts;
|
||||
if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) {
|
||||
context.failedTypeParameterIndex = undefined;
|
||||
}
|
||||
if (signature.thisType) {
|
||||
var thisType = getThisTypeOfSignature(signature);
|
||||
if (thisType) {
|
||||
var thisArgumentNode = getThisArgumentOfCall(node);
|
||||
var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
|
||||
inferTypes(context, thisArgumentType, signature.thisType);
|
||||
inferTypes(context, thisArgumentType, thisType);
|
||||
}
|
||||
var argCount = getEffectiveArgumentCount(node, args, signature);
|
||||
for (var i = 0; i < argCount; i++) {
|
||||
@@ -21318,12 +21381,13 @@ var ts;
|
||||
return typeArgumentsAreAssignable;
|
||||
}
|
||||
function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) {
|
||||
if (signature.thisType && signature.thisType !== voidType && node.kind !== 175) {
|
||||
var thisType = getThisTypeOfSignature(signature);
|
||||
if (thisType && thisType !== voidType && node.kind !== 175) {
|
||||
var thisArgumentNode = getThisArgumentOfCall(node);
|
||||
var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
|
||||
var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
|
||||
var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
|
||||
if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) {
|
||||
if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -21739,7 +21803,7 @@ var ts;
|
||||
if (getReturnTypeOfSignature(signature) !== voidType) {
|
||||
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
|
||||
}
|
||||
if (signature.thisType === voidType) {
|
||||
if (getThisTypeOfSignature(signature) === voidType) {
|
||||
error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
|
||||
}
|
||||
return signature;
|
||||
@@ -22219,6 +22283,8 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkUnusedIdentifiers(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
}
|
||||
function checkArithmeticOperandType(operand, type, diagnostic) {
|
||||
@@ -22229,7 +22295,8 @@ var ts;
|
||||
return true;
|
||||
}
|
||||
function isReadonlySymbol(symbol) {
|
||||
return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 ||
|
||||
return symbol.isReadonly ||
|
||||
symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 ||
|
||||
symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 ||
|
||||
symbol.flags & 98304 && !(symbol.flags & 65536) ||
|
||||
(symbol.flags & 8) !== 0;
|
||||
@@ -23064,6 +23131,9 @@ var ts;
|
||||
checkAsyncFunctionReturnType(node);
|
||||
}
|
||||
}
|
||||
if (!node.body) {
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkClassForDuplicateDeclarations(node) {
|
||||
@@ -23191,6 +23261,8 @@ var ts;
|
||||
checkSignatureDeclaration(node);
|
||||
checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node);
|
||||
checkSourceElement(node.body);
|
||||
checkUnusedIdentifiers(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
var symbol = getSymbolOfNode(node);
|
||||
var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
|
||||
if (node === firstDeclaration) {
|
||||
@@ -23294,7 +23366,7 @@ var ts;
|
||||
error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
|
||||
}
|
||||
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
|
||||
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
|
||||
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
|
||||
}
|
||||
}
|
||||
getTypeOfAccessors(getSymbolOfNode(node));
|
||||
@@ -23339,12 +23411,17 @@ var ts;
|
||||
function checkTypeReferenceNode(node) {
|
||||
checkGrammarTypeArguments(node, node.typeArguments);
|
||||
var type = getTypeFromTypeReference(node);
|
||||
if (type !== unknownType && node.typeArguments) {
|
||||
ts.forEach(node.typeArguments, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
var symbol = getNodeLinks(node).resolvedSymbol;
|
||||
var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters;
|
||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||
if (type !== unknownType) {
|
||||
if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
type.symbol.hasReference = true;
|
||||
}
|
||||
if (node.typeArguments) {
|
||||
ts.forEach(node.typeArguments, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
var symbol = getNodeLinks(node).resolvedSymbol;
|
||||
var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters;
|
||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23874,6 +23951,8 @@ var ts;
|
||||
}
|
||||
}
|
||||
checkSourceElement(node.body);
|
||||
checkUnusedIdentifiers(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
if (!node.asteriskToken) {
|
||||
var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type));
|
||||
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType);
|
||||
@@ -23887,11 +23966,83 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkUnusedIdentifiers(node) {
|
||||
if (node.parent.kind !== 222 && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
for (var key in node.locals) {
|
||||
if (ts.hasProperty(node.locals, key)) {
|
||||
var local = node.locals[key];
|
||||
if (!local.hasReference && local.valueDeclaration) {
|
||||
if (local.valueDeclaration.kind !== 142 && compilerOptions.noUnusedLocals) {
|
||||
error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name);
|
||||
}
|
||||
else if (local.valueDeclaration.kind === 142 && compilerOptions.noUnusedParameters) {
|
||||
if (local.valueDeclaration.flags === 0) {
|
||||
error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkUnusedClassLocals(node) {
|
||||
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
|
||||
if (node.members) {
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind === 147 || member.kind === 145) {
|
||||
if (isPrivateNode(member) && !member.symbol.hasReference) {
|
||||
error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name);
|
||||
}
|
||||
}
|
||||
else if (member.kind === 148) {
|
||||
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
|
||||
var parameter = _c[_b];
|
||||
if (isPrivateNode(parameter) && !parameter.symbol.hasReference) {
|
||||
error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkUnusedTypeParameters(node) {
|
||||
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
|
||||
if (node.typeParameters) {
|
||||
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
|
||||
var typeParameter = _a[_i];
|
||||
if (!typeParameter.symbol.hasReference) {
|
||||
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function isPrivateNode(node) {
|
||||
return (node.flags & 8) !== 0;
|
||||
}
|
||||
function checkUnusedModuleLocals(node) {
|
||||
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
|
||||
var _loop_1 = function(key) {
|
||||
if (ts.hasProperty(node.locals, key)) {
|
||||
var local_1 = node.locals[key];
|
||||
if (!local_1.hasReference && !local_1.exportSymbol) {
|
||||
ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); });
|
||||
}
|
||||
}
|
||||
};
|
||||
for (var key in node.locals) {
|
||||
_loop_1(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkBlock(node) {
|
||||
if (node.kind === 199) {
|
||||
checkGrammarStatementInAmbientContext(node);
|
||||
}
|
||||
ts.forEach(node.statements, checkSourceElement);
|
||||
checkUnusedIdentifiers(node);
|
||||
}
|
||||
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
||||
if (!ts.hasDeclaredRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) {
|
||||
@@ -24237,6 +24388,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
checkUnusedIdentifiers(node);
|
||||
}
|
||||
function checkForInStatement(node) {
|
||||
checkGrammarForInOrForOfStatement(node);
|
||||
@@ -24265,6 +24417,7 @@ var ts;
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
checkUnusedIdentifiers(node);
|
||||
}
|
||||
function checkForInOrForOfVariableDeclaration(iterationStatement) {
|
||||
var variableDeclarationList = iterationStatement.initializer;
|
||||
@@ -24561,6 +24714,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
checkBlock(catchClause.block);
|
||||
checkUnusedIdentifiers(catchClause);
|
||||
}
|
||||
if (node.finallyBlock) {
|
||||
checkBlock(node.finallyBlock);
|
||||
@@ -24683,6 +24837,8 @@ var ts;
|
||||
}
|
||||
checkClassLikeDeclaration(node);
|
||||
ts.forEach(node.members, checkSourceElement);
|
||||
checkUnusedClassLocals(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
function checkClassLikeDeclaration(node) {
|
||||
checkGrammarClassDeclarationHeritageClauses(node);
|
||||
@@ -24923,6 +25079,8 @@ var ts;
|
||||
ts.forEach(node.members, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
updateReferencesForInterfaceHeritiageClauseTargets(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
}
|
||||
function checkTypeAliasDeclaration(node) {
|
||||
@@ -25242,6 +25400,7 @@ var ts;
|
||||
}
|
||||
if (node.body) {
|
||||
checkSourceElement(node.body);
|
||||
checkUnusedModuleLocals(node);
|
||||
}
|
||||
}
|
||||
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
||||
@@ -25392,6 +25551,9 @@ var ts;
|
||||
if (target.flags & 793056) {
|
||||
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
||||
}
|
||||
if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) {
|
||||
target.hasReference = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -25679,6 +25841,9 @@ var ts;
|
||||
potentialThisCollisions.length = 0;
|
||||
deferredNodes = [];
|
||||
ts.forEach(node.statements, checkSourceElement);
|
||||
if (ts.isExternalModule(node)) {
|
||||
checkUnusedModuleLocals(node);
|
||||
}
|
||||
checkDeferredNodes();
|
||||
deferredNodes = undefined;
|
||||
if (ts.isExternalOrCommonJsModule(node)) {
|
||||
@@ -25967,6 +26132,13 @@ var ts;
|
||||
case 139:
|
||||
return getSymbolOfEntityNameOrPropertyAccessExpression(node);
|
||||
case 97:
|
||||
var container = ts.getThisContainer(node, false);
|
||||
if (ts.isFunctionLike(container)) {
|
||||
var sig = getSignatureFromDeclaration(container);
|
||||
if (sig.thisParameter) {
|
||||
return sig.thisParameter;
|
||||
}
|
||||
}
|
||||
case 95:
|
||||
var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node);
|
||||
return type.symbol;
|
||||
@@ -26155,7 +26327,9 @@ var ts;
|
||||
var parentSymbol = getParentOfSymbol(symbol);
|
||||
if (parentSymbol) {
|
||||
if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) {
|
||||
return parentSymbol.valueDeclaration;
|
||||
if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) {
|
||||
return parentSymbol.valueDeclaration;
|
||||
}
|
||||
}
|
||||
for (var n = node.parent; n; n = n.parent) {
|
||||
if ((n.kind === 225 || n.kind === 224) && getSymbolOfNode(n) === parentSymbol) {
|
||||
@@ -27048,7 +27222,7 @@ var ts;
|
||||
var GetAccessor = 2;
|
||||
var SetAccessor = 4;
|
||||
var GetOrSetAccessor = GetAccessor | SetAccessor;
|
||||
var _loop_1 = function(prop) {
|
||||
var _loop_2 = function(prop) {
|
||||
var name_21 = prop.name;
|
||||
if (prop.kind === 193 ||
|
||||
name_21.kind === 140) {
|
||||
@@ -27109,8 +27283,8 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_2 = _loop_1(prop);
|
||||
if (typeof state_2 === "object") return state_2.value;
|
||||
var state_3 = _loop_2(prop);
|
||||
if (typeof state_3 === "object") return state_3.value;
|
||||
}
|
||||
}
|
||||
function checkGrammarJsxElement(node) {
|
||||
@@ -29740,6 +29914,8 @@ var ts;
|
||||
return generateNameForExportDefault();
|
||||
case 192:
|
||||
return generateNameForClassExpression();
|
||||
default:
|
||||
ts.Debug.fail();
|
||||
}
|
||||
}
|
||||
function getGeneratedNameForNode(node) {
|
||||
@@ -30437,6 +30613,20 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) {
|
||||
if (languageVersion >= 2) {
|
||||
var parent_14 = node.parent;
|
||||
if (parent_14.kind === 172 && parent_14.expression === node) {
|
||||
parent_14 = parent_14.parent;
|
||||
while (parent_14 && parent_14.kind !== 145) {
|
||||
parent_14 = parent_14.parent;
|
||||
}
|
||||
return parent_14 && parent_14.kind === 145 && (parent_14.flags & 32) !== 0 &&
|
||||
parent_14.parent.kind === 192 ? parent_14.parent : undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function emitIdentifier(node) {
|
||||
if (convertedLoopState) {
|
||||
if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) {
|
||||
@@ -30449,6 +30639,14 @@ var ts;
|
||||
write(node.text);
|
||||
}
|
||||
else if (isExpressionIdentifier(node)) {
|
||||
var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node);
|
||||
if (classExpression) {
|
||||
var declaration = resolver.getReferencedValueDeclaration(node);
|
||||
if (declaration === classExpression) {
|
||||
write(getGeneratedNameForNode(declaration.name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
emitExpressionIdentifier(node);
|
||||
}
|
||||
else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) {
|
||||
@@ -32988,7 +33186,7 @@ var ts;
|
||||
emitStart(property);
|
||||
emitStart(property.name);
|
||||
if (receiver) {
|
||||
emit(receiver);
|
||||
write(receiver);
|
||||
}
|
||||
else {
|
||||
if (property.flags & 32) {
|
||||
@@ -33271,12 +33469,15 @@ var ts;
|
||||
}
|
||||
var staticProperties = getInitializedProperties(node, true);
|
||||
var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192;
|
||||
var tempVariable;
|
||||
var generatedName;
|
||||
if (isClassExpressionWithStaticProperties) {
|
||||
tempVariable = createAndRecordTempVariable(0);
|
||||
generatedName = getGeneratedNameForNode(node.name);
|
||||
var synthesizedNode = ts.createSynthesizedNode(69);
|
||||
synthesizedNode.text = generatedName;
|
||||
recordTempDeclaration(synthesizedNode);
|
||||
write("(");
|
||||
increaseIndent();
|
||||
emit(tempVariable);
|
||||
emit(synthesizedNode);
|
||||
write(" = ");
|
||||
}
|
||||
write("class");
|
||||
@@ -33316,11 +33517,11 @@ var ts;
|
||||
var property = staticProperties_1[_a];
|
||||
write(",");
|
||||
writeLine();
|
||||
emitPropertyDeclaration(node, property, tempVariable, true);
|
||||
emitPropertyDeclaration(node, property, generatedName, true);
|
||||
}
|
||||
write(",");
|
||||
writeLine();
|
||||
emit(tempVariable);
|
||||
write(generatedName);
|
||||
decreaseIndent();
|
||||
write(")");
|
||||
}
|
||||
@@ -35498,7 +35699,7 @@ var ts;
|
||||
ts.emitTime = 0;
|
||||
ts.ioReadTime = 0;
|
||||
ts.ioWriteTime = 0;
|
||||
ts.version = "1.9.0";
|
||||
ts.version = "2.0.0";
|
||||
var emptyArray = [];
|
||||
var defaultTypeRoots = ["node_modules/@types"];
|
||||
function findConfigFile(searchPath, fileExists) {
|
||||
@@ -37341,6 +37542,16 @@ var ts;
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type
|
||||
},
|
||||
{
|
||||
name: "noUnusedLocals",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
|
||||
},
|
||||
{
|
||||
name: "noUnusedParameters",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
|
||||
},
|
||||
{
|
||||
name: "noLib",
|
||||
type: "boolean"
|
||||
@@ -37530,16 +37741,6 @@ var ts;
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typesSearchPaths",
|
||||
type: "list",
|
||||
isTSConfigOnly: true,
|
||||
element: {
|
||||
name: "typesSearchPaths",
|
||||
type: "string",
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typeRoots",
|
||||
type: "list",
|
||||
@@ -37614,7 +37815,7 @@ var ts;
|
||||
description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
|
||||
},
|
||||
{
|
||||
name: "disableProjectSizeLimit",
|
||||
name: "disableSizeLimit",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
@@ -38629,7 +38830,7 @@ var ts;
|
||||
var usageColumn = [];
|
||||
var descriptionColumn = [];
|
||||
var optionsDescriptionMap = {};
|
||||
var _loop_2 = function(i) {
|
||||
var _loop_3 = function(i) {
|
||||
var option = optsList[i];
|
||||
if (!option.description) {
|
||||
return "continue";
|
||||
@@ -38660,7 +38861,7 @@ var ts;
|
||||
marginLength = Math.max(usageText_1.length, marginLength);
|
||||
};
|
||||
for (var i = 0; i < optsList.length; i++) {
|
||||
_loop_2(i);
|
||||
_loop_3(i);
|
||||
}
|
||||
var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">";
|
||||
usageColumn.push(usageText);
|
||||
|
||||
+437
-165
File diff suppressed because it is too large
Load Diff
Vendored
+39
-9
@@ -744,9 +744,10 @@ declare namespace ts {
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
|
||||
interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
@@ -761,7 +762,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
}
|
||||
interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
}
|
||||
interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
@@ -1263,7 +1264,7 @@ declare namespace ts {
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
}
|
||||
@@ -1446,11 +1447,13 @@ declare namespace ts {
|
||||
members?: SymbolTable;
|
||||
exports?: SymbolTable;
|
||||
globalExports?: SymbolTable;
|
||||
isReadonly?: boolean;
|
||||
id?: number;
|
||||
mergeId?: number;
|
||||
parent?: Symbol;
|
||||
exportSymbol?: Symbol;
|
||||
constEnumOnlyModule?: boolean;
|
||||
hasReference?: boolean;
|
||||
}
|
||||
interface SymbolLinks {
|
||||
target?: Symbol;
|
||||
@@ -1639,7 +1642,7 @@ declare namespace ts {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
thisType?: Type;
|
||||
thisParameter?: Symbol;
|
||||
resolvedReturnType: Type;
|
||||
minArgumentCount: number;
|
||||
hasRestParameter: boolean;
|
||||
@@ -1757,6 +1760,8 @@ declare namespace ts {
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
@@ -1785,7 +1790,6 @@ declare namespace ts {
|
||||
disableSizeLimit?: boolean;
|
||||
types?: string[];
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
@@ -6438,6 +6442,24 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
_0_is_declared_but_never_used: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Report_Errors_on_Unused_Locals: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Report_Errors_on_Unused_Parameters: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Variable_0_implicitly_has_an_1_type: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
@@ -6981,7 +7003,7 @@ declare namespace ts {
|
||||
function isLiteralComputedPropertyDeclarationName(node: Node): boolean;
|
||||
function isIdentifierName(node: Identifier): boolean;
|
||||
function isAliasSymbolDeclaration(node: Node): boolean;
|
||||
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): ExpressionWithTypeArguments;
|
||||
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments;
|
||||
function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray<ExpressionWithTypeArguments>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<ExpressionWithTypeArguments>;
|
||||
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
||||
@@ -7688,6 +7710,7 @@ declare namespace ts.formatting {
|
||||
declare namespace ts.formatting {
|
||||
namespace SmartIndenter {
|
||||
function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number;
|
||||
function getBaseIndentation(options: EditorOptions): number;
|
||||
function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number;
|
||||
function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean;
|
||||
function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): {
|
||||
@@ -7826,7 +7849,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
getNonBoundSourceFile(fileName: string): SourceFile;
|
||||
@@ -7904,6 +7927,7 @@ declare namespace ts {
|
||||
containerKind: string;
|
||||
}
|
||||
interface EditorOptions {
|
||||
BaseIndentSize?: number;
|
||||
IndentSize: number;
|
||||
TabSize: number;
|
||||
NewLineCharacter: string;
|
||||
@@ -7926,7 +7950,7 @@ declare namespace ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
[s: string]: boolean | number | string | undefined;
|
||||
}
|
||||
interface DefinitionInfo {
|
||||
fileName: string;
|
||||
@@ -8231,6 +8255,8 @@ declare namespace ts.server {
|
||||
const Formatonkey: string;
|
||||
const Geterr: string;
|
||||
const GeterrForProject: string;
|
||||
const SemanticDiagnosticsSync: string;
|
||||
const SyntacticDiagnosticsSync: string;
|
||||
const NavBar: string;
|
||||
const Navto: string;
|
||||
const Occurrences: string;
|
||||
@@ -8277,6 +8303,9 @@ declare namespace ts.server {
|
||||
private getDefinition(line, offset, fileName);
|
||||
private getTypeDefinition(line, offset, fileName);
|
||||
private getOccurrences(line, offset, fileName);
|
||||
private getDiagnosticsWorker(args, selector);
|
||||
private getSyntacticDiagnosticsSync(args);
|
||||
private getSemanticDiagnosticsSync(args);
|
||||
private getDocumentHighlights(line, offset, fileName, filesToSearch);
|
||||
private getProjectInfo(fileName, needFileNameList);
|
||||
private getRenameLocations(line, offset, fileName, findInComments, findInStrings);
|
||||
@@ -8300,6 +8329,7 @@ declare namespace ts.server {
|
||||
getDiagnosticsForProject(delay: number, fileName: string): void;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
exit(): void;
|
||||
private requiredResponse(response);
|
||||
private handlers;
|
||||
addProtocolHandler(command: string, handler: (request: protocol.Request) => {
|
||||
response?: any;
|
||||
@@ -8731,7 +8761,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: string): string;
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string;
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): string;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string;
|
||||
getEmitOutput(fileName: string): string;
|
||||
}
|
||||
interface ClassifierShim extends Shim {
|
||||
|
||||
+437
-165
File diff suppressed because it is too large
Load Diff
Vendored
+9
-7
@@ -753,9 +753,10 @@ declare namespace ts {
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
|
||||
interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
@@ -770,7 +771,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
}
|
||||
interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
}
|
||||
interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
@@ -1271,7 +1272,7 @@ declare namespace ts {
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
}
|
||||
@@ -1483,7 +1484,6 @@ declare namespace ts {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
thisType?: Type;
|
||||
}
|
||||
enum IndexKind {
|
||||
String = 0,
|
||||
@@ -1564,6 +1564,8 @@ declare namespace ts {
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
@@ -1590,7 +1592,6 @@ declare namespace ts {
|
||||
types?: string[];
|
||||
/** Paths used to used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
interface TypingOptions {
|
||||
@@ -2055,7 +2056,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -2133,6 +2134,7 @@ declare namespace ts {
|
||||
containerKind: string;
|
||||
}
|
||||
interface EditorOptions {
|
||||
BaseIndentSize?: number;
|
||||
IndentSize: number;
|
||||
TabSize: number;
|
||||
NewLineCharacter: string;
|
||||
@@ -2155,7 +2157,7 @@ declare namespace ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
[s: string]: boolean | number | string | undefined;
|
||||
}
|
||||
interface DefinitionInfo {
|
||||
fileName: string;
|
||||
|
||||
+434
-176
File diff suppressed because it is too large
Load Diff
Vendored
+9
-7
@@ -753,9 +753,10 @@ declare namespace ts {
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
|
||||
interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
@@ -770,7 +771,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
}
|
||||
interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
}
|
||||
interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
@@ -1271,7 +1272,7 @@ declare namespace ts {
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
}
|
||||
@@ -1483,7 +1484,6 @@ declare namespace ts {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
thisType?: Type;
|
||||
}
|
||||
enum IndexKind {
|
||||
String = 0,
|
||||
@@ -1564,6 +1564,8 @@ declare namespace ts {
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
@@ -1590,7 +1592,6 @@ declare namespace ts {
|
||||
types?: string[];
|
||||
/** Paths used to used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
interface TypingOptions {
|
||||
@@ -2055,7 +2056,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -2133,6 +2134,7 @@ declare namespace ts {
|
||||
containerKind: string;
|
||||
}
|
||||
interface EditorOptions {
|
||||
BaseIndentSize?: number;
|
||||
IndentSize: number;
|
||||
TabSize: number;
|
||||
NewLineCharacter: string;
|
||||
@@ -2155,7 +2157,7 @@ declare namespace ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
[s: string]: boolean | number | string | undefined;
|
||||
}
|
||||
interface DefinitionInfo {
|
||||
fileName: string;
|
||||
|
||||
+434
-176
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "1.9.0",
|
||||
"version": "2.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
|
||||
@@ -67,7 +67,7 @@ function getNightlyVersionString(versionString: string): string {
|
||||
const now = new Date();
|
||||
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
|
||||
|
||||
return `${versionString}-dev.${timeStr}-1.0`;
|
||||
return `${versionString}-dev.${timeStr}`;
|
||||
}
|
||||
|
||||
main();
|
||||
+286
-49
@@ -53,6 +53,7 @@ namespace ts {
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
const languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
const modulekind = getEmitModuleKind(compilerOptions);
|
||||
const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters;
|
||||
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
|
||||
const strictNullChecks = compilerOptions.strictNullChecks;
|
||||
|
||||
@@ -190,6 +191,7 @@ namespace ts {
|
||||
let jsxElementClassType: Type;
|
||||
|
||||
let deferredNodes: Node[];
|
||||
let deferredUnusedIdentifierNodes: Node[];
|
||||
|
||||
let flowLoopStart = 0;
|
||||
let flowLoopCount = 0;
|
||||
@@ -397,7 +399,7 @@ namespace ts {
|
||||
target.flags |= source.flags;
|
||||
if (source.valueDeclaration &&
|
||||
(!target.valueDeclaration ||
|
||||
(target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) {
|
||||
(target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) {
|
||||
// other kinds of value declarations take precedence over modules
|
||||
target.valueDeclaration = source.valueDeclaration;
|
||||
}
|
||||
@@ -667,8 +669,8 @@ namespace ts {
|
||||
useResult = result.flags & SymbolFlags.TypeParameter
|
||||
// type parameters are visible in parameter list, return type and type parameter list
|
||||
? lastLocation === (<FunctionLikeDeclaration>location).type ||
|
||||
lastLocation.kind === SyntaxKind.Parameter ||
|
||||
lastLocation.kind === SyntaxKind.TypeParameter
|
||||
lastLocation.kind === SyntaxKind.Parameter ||
|
||||
lastLocation.kind === SyntaxKind.TypeParameter
|
||||
// local types not visible outside the function body
|
||||
: false;
|
||||
}
|
||||
@@ -850,6 +852,10 @@ namespace ts {
|
||||
location = location.parent;
|
||||
}
|
||||
|
||||
if (result && nameNotFoundMessage && noUnusedIdentifiers) {
|
||||
result.isReferenced = true;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = getSymbol(globals, name, meaning);
|
||||
}
|
||||
@@ -857,7 +863,7 @@ namespace ts {
|
||||
if (!result) {
|
||||
if (nameNotFoundMessage) {
|
||||
if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
|
||||
!checkAndReportErrorForExtendingInterface(errorLocation)) {
|
||||
!checkAndReportErrorForExtendingInterface(errorLocation)) {
|
||||
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
|
||||
}
|
||||
}
|
||||
@@ -964,7 +970,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
|
||||
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0);
|
||||
@@ -1025,8 +1031,8 @@ namespace ts {
|
||||
const exportDefaultSymbol = isShorthandAmbientModule(moduleSymbol.valueDeclaration) ?
|
||||
moduleSymbol :
|
||||
moduleSymbol.exports["export="] ?
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
|
||||
if (!exportDefaultSymbol && !allowSyntheticDefaultImports) {
|
||||
error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
|
||||
@@ -1268,9 +1274,13 @@ namespace ts {
|
||||
const right = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).right : (<PropertyAccessExpression>name).name;
|
||||
|
||||
const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors);
|
||||
if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) {
|
||||
if (!namespace || nodeIsMissing(right)) {
|
||||
return undefined;
|
||||
}
|
||||
else if (namespace === unknownSymbol) {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning);
|
||||
if (!symbol) {
|
||||
if (!ignoreErrors) {
|
||||
@@ -4236,6 +4246,7 @@ namespace ts {
|
||||
let props: Symbol[];
|
||||
// Flags we want to propagate to the result if they exist in all source symbols
|
||||
let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None;
|
||||
let isReadonly = false;
|
||||
for (const current of types) {
|
||||
const type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
@@ -4248,6 +4259,9 @@ namespace ts {
|
||||
else if (!contains(props, prop)) {
|
||||
props.push(prop);
|
||||
}
|
||||
if (isReadonlySymbol(prop)) {
|
||||
isReadonly = true;
|
||||
}
|
||||
}
|
||||
else if (containingType.flags & TypeFlags.Union) {
|
||||
// A union type requires the property to be present in all constituent types
|
||||
@@ -4277,6 +4291,7 @@ namespace ts {
|
||||
name);
|
||||
result.containingType = containingType;
|
||||
result.declarations = declarations;
|
||||
result.isReadonly = isReadonly;
|
||||
result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
||||
return result;
|
||||
}
|
||||
@@ -4530,7 +4545,7 @@ namespace ts {
|
||||
: undefined;
|
||||
const typeParameters = classType ? classType.localTypeParameters :
|
||||
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) :
|
||||
getTypeParametersFromJSDocTemplate(declaration);
|
||||
getTypeParametersFromJSDocTemplate(declaration);
|
||||
const returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType);
|
||||
const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ?
|
||||
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
|
||||
@@ -5159,7 +5174,7 @@ namespace ts {
|
||||
if (typeSet.length === 0) {
|
||||
return typeSet.containsNull ? typeSet.containsNonWideningType ? nullType : nullWideningType :
|
||||
typeSet.containsUndefined ? typeSet.containsNonWideningType ? undefinedType : undefinedWideningType :
|
||||
neverType;
|
||||
neverType;
|
||||
}
|
||||
else if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -5395,8 +5410,8 @@ namespace ts {
|
||||
const count = sources.length;
|
||||
const mapper: TypeMapper =
|
||||
count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) :
|
||||
count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||
createArrayTypeMapper(sources, targets);
|
||||
count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||
createArrayTypeMapper(sources, targets);
|
||||
mapper.mappedTypes = sources;
|
||||
return mapper;
|
||||
}
|
||||
@@ -5719,8 +5734,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isSignatureAssignableTo(source: Signature,
|
||||
target: Signature,
|
||||
ignoreReturnTypes: boolean): boolean {
|
||||
target: Signature,
|
||||
ignoreReturnTypes: boolean): boolean {
|
||||
return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False;
|
||||
}
|
||||
|
||||
@@ -5728,11 +5743,11 @@ namespace ts {
|
||||
* See signatureRelatedTo, compareSignaturesIdentical
|
||||
*/
|
||||
function compareSignaturesRelated(source: Signature,
|
||||
target: Signature,
|
||||
ignoreReturnTypes: boolean,
|
||||
reportErrors: boolean,
|
||||
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
|
||||
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
|
||||
target: Signature,
|
||||
ignoreReturnTypes: boolean,
|
||||
reportErrors: boolean,
|
||||
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
|
||||
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
|
||||
// TODO (drosen): De-duplicate code between related functions.
|
||||
if (source === target) {
|
||||
return Ternary.True;
|
||||
@@ -5814,10 +5829,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function compareTypePredicateRelatedTo(source: TypePredicate,
|
||||
target: TypePredicate,
|
||||
reportErrors: boolean,
|
||||
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
|
||||
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
|
||||
target: TypePredicate,
|
||||
reportErrors: boolean,
|
||||
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
|
||||
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
|
||||
if (source.kind !== target.kind) {
|
||||
if (reportErrors) {
|
||||
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
||||
@@ -6898,7 +6913,7 @@ namespace ts {
|
||||
function isStringLiteralUnionType(type: Type): boolean {
|
||||
return type.flags & TypeFlags.StringLiteral ? true :
|
||||
type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isStringLiteralUnionType) :
|
||||
false;
|
||||
false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6980,11 +6995,11 @@ namespace ts {
|
||||
const resolved = <ResolvedType>type;
|
||||
const members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
|
||||
const regularNew = createAnonymousType(resolved.symbol,
|
||||
members,
|
||||
resolved.callSignatures,
|
||||
resolved.constructSignatures,
|
||||
resolved.stringIndexInfo,
|
||||
resolved.numberIndexInfo);
|
||||
members,
|
||||
resolved.callSignatures,
|
||||
resolved.constructSignatures,
|
||||
resolved.stringIndexInfo,
|
||||
resolved.numberIndexInfo);
|
||||
regularNew.flags = resolved.flags & ~TypeFlags.FreshObjectLiteral;
|
||||
(<FreshObjectLiteralType>type).regularType = regularNew;
|
||||
return regularNew;
|
||||
@@ -7812,7 +7827,7 @@ namespace ts {
|
||||
// We cache results of flow type resolution for shared nodes that were previously visited in
|
||||
// the same getFlowTypeOfReference invocation. A node is considered shared when it is the
|
||||
// antecedent of more than one node.
|
||||
for (let i = visitedFlowStart; i < visitedFlowCount; i++) {
|
||||
for (let i = visitedFlowStart; i < visitedFlowCount; i++) {
|
||||
if (visitedFlowNodes[i] === flow) {
|
||||
return visitedFlowTypes[i];
|
||||
}
|
||||
@@ -8199,7 +8214,7 @@ namespace ts {
|
||||
const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type;
|
||||
return isTypeAssignableTo(candidate, targetType) ? candidate :
|
||||
isTypeAssignableTo(type, candidate) ? type :
|
||||
getIntersectionType([type, candidate]);
|
||||
getIntersectionType([type, candidate]);
|
||||
}
|
||||
|
||||
function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
|
||||
@@ -8605,9 +8620,9 @@ namespace ts {
|
||||
getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) {
|
||||
// Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container')
|
||||
const className = (((container.parent as BinaryExpression) // x.prototype.y = f
|
||||
.left as PropertyAccessExpression) // x.prototype.y
|
||||
.expression as PropertyAccessExpression) // x.prototype
|
||||
.expression; // x
|
||||
.left as PropertyAccessExpression) // x.prototype.y
|
||||
.expression as PropertyAccessExpression) // x.prototype
|
||||
.expression; // x
|
||||
const classSymbol = checkExpression(className).symbol;
|
||||
if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) {
|
||||
return getInferredClassType(classSymbol);
|
||||
@@ -9660,8 +9675,9 @@ namespace ts {
|
||||
/**
|
||||
* Returns true iff React would emit this tag name as a string rather than an identifier or qualified name
|
||||
*/
|
||||
function isJsxIntrinsicIdentifier(tagName: Identifier | QualifiedName) {
|
||||
if (tagName.kind === SyntaxKind.QualifiedName) {
|
||||
function isJsxIntrinsicIdentifier(tagName: JsxTagNameExpression) {
|
||||
// TODO (yuisu): comment
|
||||
if (tagName.kind === SyntaxKind.PropertyAccessExpression || tagName.kind === SyntaxKind.ThisKeyword) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -9851,12 +9867,35 @@ namespace ts {
|
||||
elemType = checkExpression(node.tagName);
|
||||
}
|
||||
if (elemType.flags & TypeFlags.Union) {
|
||||
const types = (<UnionOrIntersectionType> elemType).types;
|
||||
const types = (<UnionOrIntersectionType>elemType).types;
|
||||
return getUnionType(types.map(type => {
|
||||
return getResolvedJsxType(node, type, elemClassType);
|
||||
}));
|
||||
}
|
||||
|
||||
// If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type
|
||||
if (elemType.flags & TypeFlags.String) {
|
||||
return anyType;
|
||||
}
|
||||
else if (elemType.flags & TypeFlags.StringLiteral) {
|
||||
// If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type
|
||||
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
|
||||
if (intrinsicElementsType !== unknownType) {
|
||||
const stringLiteralTypeName = (<StringLiteralType>elemType).text;
|
||||
const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
|
||||
if (intrinsicProp) {
|
||||
return getTypeOfSymbol(intrinsicProp);
|
||||
}
|
||||
const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String);
|
||||
if (indexSignatureType) {
|
||||
return indexSignatureType;
|
||||
}
|
||||
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
|
||||
}
|
||||
// If we need to report an error, we already done so here. So just return any to prevent any more error downstream
|
||||
return anyType;
|
||||
}
|
||||
|
||||
// Get the element instance type (the result of newing or invoking this tag)
|
||||
const elemInstanceType = getJsxElementInstanceType(node, elemType);
|
||||
|
||||
@@ -10205,6 +10244,18 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (noUnusedIdentifiers &&
|
||||
(prop.flags & SymbolFlags.ClassMember) &&
|
||||
prop.valueDeclaration && (prop.valueDeclaration.flags & NodeFlags.Private)) {
|
||||
if (prop.flags & SymbolFlags.Instantiated) {
|
||||
getSymbolLinks(prop).target.isReferenced = true;
|
||||
|
||||
}
|
||||
else {
|
||||
prop.isReferenced = true;
|
||||
}
|
||||
}
|
||||
|
||||
getNodeLinks(node).resolvedSymbol = prop;
|
||||
|
||||
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
|
||||
@@ -11756,7 +11807,7 @@ namespace ts {
|
||||
// if inference didn't come up with anything but {}, fall back to the binding pattern if present.
|
||||
if (links.type === emptyObjectType &&
|
||||
(parameter.valueDeclaration.name.kind === SyntaxKind.ObjectBindingPattern ||
|
||||
parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) {
|
||||
parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) {
|
||||
links.type = getTypeFromBindingPattern(<BindingPattern>parameter.valueDeclaration.name);
|
||||
}
|
||||
assignBindingElementTypes(<ParameterDeclaration>parameter.valueDeclaration);
|
||||
@@ -12147,6 +12198,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12164,7 +12216,9 @@ namespace ts {
|
||||
// Variables declared with 'const'
|
||||
// Get accessors without matching set accessors
|
||||
// Enum members
|
||||
return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
|
||||
// Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation)
|
||||
return symbol.isReadonly ||
|
||||
symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
|
||||
symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 ||
|
||||
symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) ||
|
||||
(symbol.flags & SymbolFlags.EnumMember) !== 0;
|
||||
@@ -12493,6 +12547,12 @@ namespace ts {
|
||||
if (exprOrAssignment.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const prop = <ShorthandPropertyAssignment>exprOrAssignment;
|
||||
if (prop.objectAssignmentInitializer) {
|
||||
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
||||
// undefined from the final type.
|
||||
if (strictNullChecks &&
|
||||
!(getCombinedTypeFlags(checkExpression(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) {
|
||||
sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined);
|
||||
}
|
||||
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper);
|
||||
}
|
||||
target = (<ShorthandPropertyAssignment>exprOrAssignment).name;
|
||||
@@ -13217,6 +13277,9 @@ namespace ts {
|
||||
checkAsyncFunctionReturnType(<FunctionLikeDeclaration>node);
|
||||
}
|
||||
}
|
||||
if (!(<FunctionDeclaration>node).body) {
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13234,8 +13297,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const static = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword);
|
||||
const names = static ? staticNames : instanceNames;
|
||||
const isStatic = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword);
|
||||
const names = isStatic ? staticNames : instanceNames;
|
||||
|
||||
const memberName = member.name && getPropertyNameForPropertyNameNode(member.name);
|
||||
if (memberName) {
|
||||
@@ -13369,6 +13432,7 @@ namespace ts {
|
||||
checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node);
|
||||
|
||||
checkSourceElement(node.body);
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const firstDeclaration = getDeclarationOfKind(symbol, node.kind);
|
||||
@@ -13514,6 +13578,7 @@ namespace ts {
|
||||
}
|
||||
if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) {
|
||||
checkSourceElement(node.body);
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
else {
|
||||
checkNodeDeferred(node);
|
||||
@@ -13530,6 +13595,7 @@ namespace ts {
|
||||
|
||||
function checkAccessorDeferred(node: AccessorDeclaration) {
|
||||
checkSourceElement(node.body);
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
function checkMissingDeclaration(node: Node) {
|
||||
@@ -13561,13 +13627,15 @@ namespace ts {
|
||||
function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) {
|
||||
checkGrammarTypeArguments(node, node.typeArguments);
|
||||
const type = getTypeFromTypeReference(node);
|
||||
if (type !== unknownType && node.typeArguments) {
|
||||
// Do type argument local checks only if referenced type is successfully resolved
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
const symbol = getNodeLinks(node).resolvedSymbol;
|
||||
const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
|
||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||
if (type !== unknownType) {
|
||||
if (node.typeArguments) {
|
||||
// Do type argument local checks only if referenced type is successfully resolved
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
const symbol = getNodeLinks(node).resolvedSymbol;
|
||||
const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
|
||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14410,6 +14478,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
checkSourceElement(node.body);
|
||||
|
||||
if (!node.asteriskToken) {
|
||||
const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type));
|
||||
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType);
|
||||
@@ -14429,6 +14498,139 @@ namespace ts {
|
||||
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
|
||||
}
|
||||
}
|
||||
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
function registerForUnusedIdentifiersCheck(node: Node) {
|
||||
if (deferredUnusedIdentifierNodes) {
|
||||
deferredUnusedIdentifierNodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
function checkUnusedIdentifiers() {
|
||||
if (deferredUnusedIdentifierNodes) {
|
||||
for (const node of deferredUnusedIdentifierNodes) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
checkUnusedModuleMembers(<ModuleDeclaration | SourceFile>node);
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
checkUnusedClassMembers(<ClassDeclaration | ClassExpression>node);
|
||||
checkUnusedTypeParameters(<ClassDeclaration | ClassExpression>node);
|
||||
break;
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
checkUnusedTypeParameters(<InterfaceDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
checkUnusedLocalsAndParameters(node);
|
||||
break;
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
if ((<FunctionLikeDeclaration>node).body) {
|
||||
checkUnusedLocalsAndParameters(<FunctionLikeDeclaration>node);
|
||||
}
|
||||
checkUnusedTypeParameters(<FunctionLikeDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
checkUnusedTypeParameters(<FunctionLikeDeclaration>node);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUnusedLocalsAndParameters(node: Node): void {
|
||||
if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) {
|
||||
for (const key in node.locals) {
|
||||
if (hasProperty(node.locals, key)) {
|
||||
const local = node.locals[key];
|
||||
if (!local.isReferenced) {
|
||||
if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) {
|
||||
const parameter = <ParameterDeclaration>local.valueDeclaration;
|
||||
if (compilerOptions.noUnusedParameters &&
|
||||
!isParameterPropertyDeclaration(parameter) &&
|
||||
!parameterNameStartsWithUnderscore(parameter)) {
|
||||
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
|
||||
}
|
||||
}
|
||||
else if (compilerOptions.noUnusedLocals) {
|
||||
forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) {
|
||||
return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text.charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
|
||||
function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void {
|
||||
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
|
||||
if (node.members) {
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
|
||||
if (!member.symbol.isReferenced && member.flags & NodeFlags.Private) {
|
||||
error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name);
|
||||
}
|
||||
}
|
||||
else if (member.kind === SyntaxKind.Constructor) {
|
||||
for (const parameter of (<ConstructorDeclaration>member).parameters) {
|
||||
if (!parameter.symbol.isReferenced && parameter.flags & NodeFlags.Private) {
|
||||
error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) {
|
||||
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
|
||||
if (node.typeParameters) {
|
||||
for (const typeParameter of node.typeParameters) {
|
||||
if (!typeParameter.symbol.isReferenced) {
|
||||
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void {
|
||||
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
|
||||
for (const key in node.locals) {
|
||||
if (hasProperty(node.locals, key)) {
|
||||
const local = node.locals[key];
|
||||
if (!local.isReferenced && !local.exportSymbol) {
|
||||
for (const declaration of local.declarations) {
|
||||
if (!isAmbientModule(declaration)) {
|
||||
error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkBlock(node: Block) {
|
||||
@@ -14437,6 +14639,9 @@ namespace ts {
|
||||
checkGrammarStatementInAmbientContext(node);
|
||||
}
|
||||
forEach(node.statements, checkSourceElement);
|
||||
if (node.locals) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
|
||||
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
|
||||
@@ -14901,6 +15106,9 @@ namespace ts {
|
||||
if (node.condition) checkExpression(node.condition);
|
||||
if (node.incrementor) checkExpression(node.incrementor);
|
||||
checkSourceElement(node.statement);
|
||||
if (node.locals) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
|
||||
function checkForOfStatement(node: ForOfStatement): void {
|
||||
@@ -14941,6 +15149,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
checkSourceElement(node.statement);
|
||||
if (node.locals) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
|
||||
function checkForInStatement(node: ForInStatement) {
|
||||
@@ -14988,6 +15199,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
checkSourceElement(node.statement);
|
||||
if (node.locals) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
|
||||
function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void {
|
||||
@@ -15252,7 +15466,7 @@ namespace ts {
|
||||
|
||||
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
|
||||
const unwrappedReturnType = isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType;
|
||||
return maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
|
||||
return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
|
||||
}
|
||||
|
||||
function checkReturnStatement(node: ReturnStatement) {
|
||||
@@ -15360,6 +15574,9 @@ namespace ts {
|
||||
}
|
||||
forEach(clause.statements, checkSourceElement);
|
||||
});
|
||||
if (node.caseBlock.locals) {
|
||||
registerForUnusedIdentifiersCheck(node.caseBlock);
|
||||
}
|
||||
}
|
||||
|
||||
function checkLabeledStatement(node: LabeledStatement) {
|
||||
@@ -15580,6 +15797,7 @@ namespace ts {
|
||||
|
||||
function checkClassExpressionDeferred(node: ClassExpression) {
|
||||
forEach(node.members, checkSourceElement);
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
function checkClassDeclaration(node: ClassDeclaration) {
|
||||
@@ -15588,6 +15806,8 @@ namespace ts {
|
||||
}
|
||||
checkClassLikeDeclaration(node);
|
||||
forEach(node.members, checkSourceElement);
|
||||
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
function checkClassLikeDeclaration(node: ClassLikeDeclaration) {
|
||||
@@ -15897,6 +16117,7 @@ namespace ts {
|
||||
|
||||
if (produceDiagnostics) {
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
checkUnusedTypeParameters(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16293,6 +16514,9 @@ namespace ts {
|
||||
|
||||
if (node.body) {
|
||||
checkSourceElement(node.body);
|
||||
if (!isGlobalScopeAugmentation(node)) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16814,9 +17038,22 @@ namespace ts {
|
||||
potentialThisCollisions.length = 0;
|
||||
|
||||
deferredNodes = [];
|
||||
deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined;
|
||||
|
||||
forEach(node.statements, checkSourceElement);
|
||||
|
||||
checkDeferredNodes();
|
||||
|
||||
if (isExternalModule(node)) {
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
if (!node.isDeclarationFile) {
|
||||
checkUnusedIdentifiers();
|
||||
}
|
||||
|
||||
deferredNodes = undefined;
|
||||
deferredUnusedIdentifierNodes = undefined;
|
||||
|
||||
if (isExternalOrCommonJsModule(node)) {
|
||||
checkExternalModuleExports(node);
|
||||
|
||||
@@ -132,6 +132,16 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
|
||||
},
|
||||
{
|
||||
name: "noUnusedLocals",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Report_Errors_on_Unused_Locals,
|
||||
},
|
||||
{
|
||||
name: "noUnusedParameters",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Report_Errors_on_Unused_Parameters
|
||||
},
|
||||
{
|
||||
name: "noLib",
|
||||
type: "boolean",
|
||||
@@ -326,16 +336,6 @@ namespace ts {
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typesSearchPaths",
|
||||
type: "list",
|
||||
isTSConfigOnly: true,
|
||||
element: {
|
||||
name: "typesSearchPaths",
|
||||
type: "string",
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typeRoots",
|
||||
type: "list",
|
||||
@@ -374,6 +374,11 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
|
||||
},
|
||||
{
|
||||
name: "maxNodeModuleJsDepth",
|
||||
type: "number",
|
||||
description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
|
||||
},
|
||||
{
|
||||
name: "listEmittedFiles",
|
||||
type: "boolean"
|
||||
@@ -413,7 +418,7 @@ namespace ts {
|
||||
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
|
||||
},
|
||||
{
|
||||
name: "disableProjectSizeLimit",
|
||||
name: "disableSizeLimit",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
@@ -886,6 +891,21 @@ namespace ts {
|
||||
*/
|
||||
const invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/;
|
||||
|
||||
/**
|
||||
* Tests for a path where .. appears after a recursive directory wildcard.
|
||||
* Matches **\..\*, **\a\..\*, and **\.., but not ..\**\*
|
||||
*
|
||||
* NOTE: used \ in place of / above to avoid issues with multiline comments.
|
||||
*
|
||||
* Breakdown:
|
||||
* (^|\/) # matches either the beginning of the string or a directory separator.
|
||||
* \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
|
||||
* (.*\/)? # optionally matches any number of characters followed by a directory separator.
|
||||
* \.\. # matches a parent directory path component ".."
|
||||
* ($|\/) # matches either the end of the string or a directory separator.
|
||||
*/
|
||||
const invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
|
||||
|
||||
/**
|
||||
* Tests for a path containing a wildcard character in a directory component of the path.
|
||||
* Matches \*\, \?\, and \a*b\, but not \a\ or \a\*.
|
||||
@@ -1018,6 +1038,9 @@ namespace ts {
|
||||
else if (invalidMultipleRecursionPatterns.test(spec)) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec));
|
||||
}
|
||||
else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec));
|
||||
}
|
||||
else {
|
||||
validSpecs.push(spec);
|
||||
}
|
||||
@@ -1047,7 +1070,7 @@ namespace ts {
|
||||
if (include !== undefined) {
|
||||
const recursiveKeys: string[] = [];
|
||||
for (const file of include) {
|
||||
const name = combinePaths(path, file);
|
||||
const name = normalizePath(combinePaths(path, file));
|
||||
if (excludeRegex && excludeRegex.test(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+10
-8
@@ -1072,15 +1072,17 @@ namespace ts {
|
||||
// Storage for literal base paths amongst the include patterns.
|
||||
const includeBasePaths: string[] = [];
|
||||
for (const include of includes) {
|
||||
if (isRootedDiskPath(include)) {
|
||||
const wildcardOffset = indexOfAnyCharCode(include, wildcardCharCodes);
|
||||
const includeBasePath = wildcardOffset < 0
|
||||
? removeTrailingDirectorySeparator(getDirectoryPath(include))
|
||||
: include.substring(0, include.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
// We also need to check the relative paths by converting them to absolute and normalizing
|
||||
// in case they escape the base path (e.g "..\somedirectory")
|
||||
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
|
||||
|
||||
// Append the literal and canonical candidate base paths.
|
||||
includeBasePaths.push(includeBasePath);
|
||||
}
|
||||
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
|
||||
const includeBasePath = wildcardOffset < 0
|
||||
? removeTrailingDirectorySeparator(getDirectoryPath(absolute))
|
||||
: absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
|
||||
// Append the literal and canonical candidate base paths.
|
||||
includeBasePaths.push(includeBasePath);
|
||||
}
|
||||
|
||||
// Sort the offsets array using either the literal or canonical path representations.
|
||||
|
||||
@@ -2332,6 +2332,10 @@
|
||||
"category": "Error",
|
||||
"code": 5064
|
||||
},
|
||||
"File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 5065
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -2792,7 +2796,26 @@
|
||||
"category": "Message",
|
||||
"code": 6132
|
||||
},
|
||||
|
||||
"'{0}' is declared but never used.": {
|
||||
"category": "Error",
|
||||
"code": 6133
|
||||
},
|
||||
"Report Errors on Unused Locals.": {
|
||||
"category": "Message",
|
||||
"code": 6134
|
||||
},
|
||||
"Report Errors on Unused Parameters.": {
|
||||
"category": "Message",
|
||||
"code": 6135
|
||||
},
|
||||
"The maximum dependency depth to search under node_modules and load JavaScript files": {
|
||||
"category": "Message",
|
||||
"code": 6136
|
||||
},
|
||||
"No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6137
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
+37
-9
@@ -1219,7 +1219,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
function jsxEmitReact(node: JsxElement | JsxSelfClosingElement) {
|
||||
/// Emit a tag name, which is either '"div"' for lower-cased names, or
|
||||
/// 'Div' for upper-cased or dotted names
|
||||
function emitTagName(name: Identifier | QualifiedName) {
|
||||
function emitTagName(name: LeftHandSideExpression) {
|
||||
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
|
||||
write('"');
|
||||
emit(name);
|
||||
@@ -1673,6 +1673,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
return false;
|
||||
}
|
||||
|
||||
function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node: Identifier) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
let parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>parent).expression === node) {
|
||||
parent = parent.parent;
|
||||
while (parent && parent.kind !== SyntaxKind.PropertyDeclaration) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent && parent.kind === SyntaxKind.PropertyDeclaration && (parent.flags & NodeFlags.Static) !== 0 &&
|
||||
parent.parent.kind === SyntaxKind.ClassExpression ? parent.parent : undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function emitIdentifier(node: Identifier) {
|
||||
if (convertedLoopState) {
|
||||
if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) {
|
||||
@@ -1687,6 +1702,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
write(node.text);
|
||||
}
|
||||
else if (isExpressionIdentifier(node)) {
|
||||
const classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node);
|
||||
if (classExpression) {
|
||||
const declaration = resolver.getReferencedValueDeclaration(node);
|
||||
if (declaration === classExpression) {
|
||||
write(getGeneratedNameForNode(declaration.name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
emitExpressionIdentifier(node);
|
||||
}
|
||||
else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) {
|
||||
@@ -4522,8 +4545,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
}
|
||||
|
||||
write(";");
|
||||
tempIndex++;
|
||||
}
|
||||
// Regardless of whether we will emit a var declaration for the binding pattern, we generate the temporary
|
||||
// variable for the parameter (see: emitParameter)
|
||||
tempIndex++;
|
||||
}
|
||||
else if (initializer) {
|
||||
writeLine();
|
||||
@@ -5086,13 +5111,13 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: Identifier, isExpression?: boolean) {
|
||||
function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: string, isExpression?: boolean) {
|
||||
writeLine();
|
||||
emitLeadingComments(property);
|
||||
emitStart(property);
|
||||
emitStart(property.name);
|
||||
if (receiver) {
|
||||
emit(receiver);
|
||||
write(receiver);
|
||||
}
|
||||
else {
|
||||
if (property.flags & NodeFlags.Static) {
|
||||
@@ -5511,13 +5536,16 @@ const _super = (function (geti, seti) {
|
||||
// of it have been initialized by the time it is used.
|
||||
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
|
||||
const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression;
|
||||
let tempVariable: Identifier;
|
||||
let generatedName: string;
|
||||
|
||||
if (isClassExpressionWithStaticProperties) {
|
||||
tempVariable = createAndRecordTempVariable(TempFlags.Auto);
|
||||
generatedName = getGeneratedNameForNode(node.name);
|
||||
const synthesizedNode = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
synthesizedNode.text = generatedName;
|
||||
recordTempDeclaration(synthesizedNode);
|
||||
write("(");
|
||||
increaseIndent();
|
||||
emit(tempVariable);
|
||||
emit(synthesizedNode);
|
||||
write(" = ");
|
||||
}
|
||||
|
||||
@@ -5571,11 +5599,11 @@ const _super = (function (geti, seti) {
|
||||
for (const property of staticProperties) {
|
||||
write(",");
|
||||
writeLine();
|
||||
emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true);
|
||||
emitPropertyDeclaration(node, property, /*receiver*/ generatedName, /*isExpression*/ true);
|
||||
}
|
||||
write(",");
|
||||
writeLine();
|
||||
emit(tempVariable);
|
||||
write(generatedName);
|
||||
decreaseIndent();
|
||||
write(")");
|
||||
}
|
||||
|
||||
+29
-17
@@ -1155,12 +1155,12 @@ namespace ts {
|
||||
if (token === SyntaxKind.ExportKeyword) {
|
||||
nextToken();
|
||||
if (token === SyntaxKind.DefaultKeyword) {
|
||||
return lookAhead(nextTokenIsClassOrFunction);
|
||||
return lookAhead(nextTokenIsClassOrFunctionOrAsync);
|
||||
}
|
||||
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.AsKeyword && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
|
||||
}
|
||||
if (token === SyntaxKind.DefaultKeyword) {
|
||||
return nextTokenIsClassOrFunction();
|
||||
return nextTokenIsClassOrFunctionOrAsync();
|
||||
}
|
||||
if (token === SyntaxKind.StaticKeyword) {
|
||||
nextToken();
|
||||
@@ -1182,9 +1182,9 @@ namespace ts {
|
||||
|| isLiteralPropertyName();
|
||||
}
|
||||
|
||||
function nextTokenIsClassOrFunction(): boolean {
|
||||
function nextTokenIsClassOrFunctionOrAsync(): boolean {
|
||||
nextToken();
|
||||
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword;
|
||||
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword || token === SyntaxKind.AsyncKeyword;
|
||||
}
|
||||
|
||||
// True if positioned at the start of a list element
|
||||
@@ -3576,7 +3576,7 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean {
|
||||
function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagNameExpression): boolean {
|
||||
if (lhs.kind !== rhs.kind) {
|
||||
return false;
|
||||
}
|
||||
@@ -3585,8 +3585,15 @@ namespace ts {
|
||||
return (<Identifier>lhs).text === (<Identifier>rhs).text;
|
||||
}
|
||||
|
||||
return (<QualifiedName>lhs).right.text === (<QualifiedName>rhs).right.text &&
|
||||
tagNamesAreEquivalent((<QualifiedName>lhs).left, (<QualifiedName>rhs).left);
|
||||
if (lhs.kind === SyntaxKind.ThisKeyword) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only
|
||||
// take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression
|
||||
// it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element
|
||||
return (<PropertyAccessExpression>lhs).name.text === (<PropertyAccessExpression>rhs).name.text &&
|
||||
tagNamesAreEquivalent((<PropertyAccessExpression>lhs).expression as JsxTagNameExpression, (<PropertyAccessExpression>rhs).expression as JsxTagNameExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -3654,7 +3661,7 @@ namespace ts {
|
||||
Debug.fail("Unknown JSX child kind " + token);
|
||||
}
|
||||
|
||||
function parseJsxChildren(openingTagName: EntityName): NodeArray<JsxChild> {
|
||||
function parseJsxChildren(openingTagName: LeftHandSideExpression): NodeArray<JsxChild> {
|
||||
const result = <NodeArray<JsxChild>>[];
|
||||
result.pos = scanner.getStartPos();
|
||||
const saveParsingContext = parsingContext;
|
||||
@@ -3717,17 +3724,22 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseJsxElementName(): EntityName {
|
||||
function parseJsxElementName(): JsxTagNameExpression {
|
||||
scanJsxIdentifier();
|
||||
let elementName: EntityName = parseIdentifierName();
|
||||
// JsxElement can have name in the form of
|
||||
// propertyAccessExpression
|
||||
// primaryExpression in the form of an identifier and "this" keyword
|
||||
// We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
|
||||
// We only want to consider "this" as a primaryExpression
|
||||
let expression: JsxTagNameExpression = token === SyntaxKind.ThisKeyword ?
|
||||
parseTokenNode<PrimaryExpression>() : parseIdentifierName();
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
scanJsxIdentifier();
|
||||
const node: QualifiedName = <QualifiedName>createNode(SyntaxKind.QualifiedName, elementName.pos); // !!!
|
||||
node.left = elementName;
|
||||
node.right = parseIdentifierName();
|
||||
elementName = finishNode(node);
|
||||
const propertyAccess: PropertyAccessExpression = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
|
||||
propertyAccess.expression = expression;
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
expression = finishNode(propertyAccess);
|
||||
}
|
||||
return elementName;
|
||||
return expression;
|
||||
}
|
||||
|
||||
function parseJsxExpression(inExpressionContext: boolean): JsxExpression {
|
||||
@@ -5058,7 +5070,7 @@ namespace ts {
|
||||
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
|
||||
*/
|
||||
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
|
||||
let flags = 0;
|
||||
let flags: NodeFlags = 0;
|
||||
let modifiers: ModifiersArray;
|
||||
while (true) {
|
||||
const modifierStart = scanner.getStartPos();
|
||||
|
||||
+106
-25
@@ -9,7 +9,7 @@ namespace ts {
|
||||
/* @internal */ export let ioWriteTime = 0;
|
||||
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = "1.9.0";
|
||||
export const version = "2.0.0";
|
||||
|
||||
const emptyArray: any[] = [];
|
||||
|
||||
@@ -130,10 +130,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function tryReadTypesSection(packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string {
|
||||
let jsonContent: { typings?: string, types?: string };
|
||||
let jsonContent: { typings?: string, types?: string, main?: string };
|
||||
try {
|
||||
const jsonText = state.host.readFile(packageJsonPath);
|
||||
jsonContent = jsonText ? <{ typings?: string, types?: string }>JSON.parse(jsonText) : {};
|
||||
jsonContent = jsonText ? <{ typings?: string, types?: string, main?: string }>JSON.parse(jsonText) : {};
|
||||
}
|
||||
catch (e) {
|
||||
// gracefully handle if readFile fails or returns not JSON
|
||||
@@ -173,14 +173,36 @@ namespace ts {
|
||||
}
|
||||
return typesFilePath;
|
||||
}
|
||||
// Use the main module for inferring types if no types package specified and the allowJs is set
|
||||
if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main);
|
||||
}
|
||||
const mainFilePath = normalizePath(combinePaths(baseDirectory, jsonContent.main));
|
||||
return mainFilePath;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const typeReferenceExtensions = [".d.ts"];
|
||||
|
||||
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
|
||||
return options.typeRoots ||
|
||||
map(defaultTypeRoots, d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
|
||||
if (options.typeRoots) {
|
||||
return options.typeRoots;
|
||||
}
|
||||
|
||||
let currentDirectory: string;
|
||||
if (options.configFilePath) {
|
||||
currentDirectory = getDirectoryPath(options.configFilePath);
|
||||
}
|
||||
else if (host.getCurrentDirectory) {
|
||||
currentDirectory = host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
if (!currentDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +242,7 @@ namespace ts {
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
// Check primary library paths
|
||||
if (typeRoots.length) {
|
||||
if (typeRoots && typeRoots.length) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
|
||||
}
|
||||
@@ -610,7 +632,7 @@ namespace ts {
|
||||
failedLookupLocations, supportedExtensions, state);
|
||||
|
||||
let isExternalLibraryImport = false;
|
||||
if (!resolvedFileName) {
|
||||
if (!resolvedFileName) {
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName);
|
||||
@@ -740,12 +762,13 @@ namespace ts {
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
// Load only typescript files irrespective of allowJs option if loading from node modules
|
||||
let result = loadModuleFromFile(candidate, supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
const supportedExtensions = getSupportedExtensions(state.compilerOptions);
|
||||
|
||||
let result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -756,13 +779,18 @@ namespace ts {
|
||||
while (true) {
|
||||
const baseName = getBaseFileName(directory);
|
||||
if (baseName !== "node_modules") {
|
||||
const result =
|
||||
// first: try to load module as-is
|
||||
loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) ||
|
||||
// second: try to load module from the scope '@types'
|
||||
loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
|
||||
if (result) {
|
||||
return result;
|
||||
// Try to load source from the package
|
||||
const packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state);
|
||||
if (packageResult && hasTypeScriptFileExtension(packageResult)) {
|
||||
// Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package
|
||||
return packageResult;
|
||||
}
|
||||
else {
|
||||
// Else prefer a types package over non-TypeScript results (e.g. JavaScript files)
|
||||
const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
|
||||
if (typesResult || packageResult) {
|
||||
return typesResult || packageResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,9 +1065,11 @@ namespace ts {
|
||||
let result: string[] = [];
|
||||
if (host.directoryExists && host.getDirectories) {
|
||||
const typeRoots = getEffectiveTypeRoots(options, host);
|
||||
for (const root of typeRoots) {
|
||||
if (host.directoryExists(root)) {
|
||||
result = result.concat(host.getDirectories(root));
|
||||
if (typeRoots) {
|
||||
for (const root of typeRoots) {
|
||||
if (host.directoryExists(root)) {
|
||||
result = result.concat(host.getDirectories(root));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1057,6 +1087,23 @@ namespace ts {
|
||||
let resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective> = {};
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
|
||||
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
||||
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
||||
// - For each root file, findSourceFile is called.
|
||||
// - This calls processImportedModules for each module imported in the source file.
|
||||
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
|
||||
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
|
||||
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
|
||||
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
|
||||
let currentNodeModulesJsDepth = 0;
|
||||
|
||||
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
|
||||
// this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed.
|
||||
const modulesWithElidedImports: Map<boolean> = {};
|
||||
|
||||
// Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled.
|
||||
const sourceFilesFoundSearchingNodeModules: Map<boolean> = {};
|
||||
|
||||
const start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
@@ -1211,6 +1258,7 @@ namespace ts {
|
||||
(oldOptions.rootDir !== options.rootDir) ||
|
||||
(oldOptions.configFilePath !== options.configFilePath) ||
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) ||
|
||||
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
|
||||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!mapIsEqualTo(oldOptions.paths, options.paths)) {
|
||||
@@ -1335,6 +1383,7 @@ namespace ts {
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFileByPath: program.getSourceFileByPath,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path),
|
||||
writeFile: writeFileCallback || (
|
||||
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
|
||||
isEmitBlocked,
|
||||
@@ -1869,6 +1918,14 @@ namespace ts {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
|
||||
// See if we need to reprocess the imports due to prior skipped imports
|
||||
if (file && lookUp(modulesWithElidedImports, file.path)) {
|
||||
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
|
||||
modulesWithElidedImports[file.path] = false;
|
||||
processImportedModules(file, getDirectoryPath(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -2007,16 +2064,40 @@ namespace ts {
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
const resolution = resolutions[i];
|
||||
setResolvedModule(file, moduleNames[i], resolution);
|
||||
const resolvedPath = resolution ? toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined;
|
||||
|
||||
// add file to program only if:
|
||||
// - resolution was successful
|
||||
// - noResolve is falsy
|
||||
// - module name comes from the list of imports
|
||||
const shouldAddFile = resolution &&
|
||||
!options.noResolve &&
|
||||
i < file.imports.length;
|
||||
// - it's not a top level JavaScript module that exceeded the search max
|
||||
const isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
|
||||
const isJsFileFromNodeModules = isFromNodeModulesSearch && hasJavaScriptFileExtension(resolution.resolvedFileName);
|
||||
|
||||
if (shouldAddFile) {
|
||||
findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
if (isFromNodeModulesSearch) {
|
||||
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
|
||||
}
|
||||
if (isJsFileFromNodeModules) {
|
||||
currentNodeModulesJsDepth++;
|
||||
}
|
||||
|
||||
const elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
|
||||
const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
|
||||
|
||||
if (elideImport) {
|
||||
modulesWithElidedImports[file.path] = true;
|
||||
}
|
||||
else if (shouldAddFile) {
|
||||
findSourceFile(resolution.resolvedFileName,
|
||||
resolvedPath,
|
||||
/*isDefaultLib*/ false, /*isReference*/ false,
|
||||
file,
|
||||
skipTrivia(file.text, file.imports[i].pos),
|
||||
file.imports[i].end);
|
||||
}
|
||||
|
||||
if (isJsFileFromNodeModules) {
|
||||
currentNodeModulesJsDepth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-5
@@ -469,7 +469,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface ModifiersArray extends NodeArray<Modifier> {
|
||||
flags: number;
|
||||
flags: NodeFlags;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.AbstractKeyword)
|
||||
@@ -1042,11 +1042,13 @@ namespace ts {
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
|
||||
export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
|
||||
|
||||
/// The opening element of a <Tag>...</Tag> JsxElement
|
||||
// @kind(SyntaxKind.JsxOpeningElement)
|
||||
export interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
|
||||
@@ -1073,7 +1075,7 @@ namespace ts {
|
||||
|
||||
// @kind(SyntaxKind.JsxClosingElement)
|
||||
export interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
tagName: JsxTagNameExpression;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.JsxExpression)
|
||||
@@ -2106,6 +2108,8 @@ namespace ts {
|
||||
PropertyOrAccessor = Property | Accessor,
|
||||
Export = ExportNamespace | ExportType | ExportValue,
|
||||
|
||||
ClassMember = Method | Accessor | Property,
|
||||
|
||||
/* @internal */
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// classification.
|
||||
@@ -2121,11 +2125,13 @@ namespace ts {
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
globalExports?: SymbolTable; // Conditional global UMD exports
|
||||
/* @internal */ isReadonly?: boolean; // readonly? (set only for intersections and unions)
|
||||
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
|
||||
/* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -2530,6 +2536,7 @@ namespace ts {
|
||||
declaration?: boolean;
|
||||
declarationDir?: string;
|
||||
/* @internal */ diagnostics?: boolean;
|
||||
disableSizeLimit?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
@@ -2545,6 +2552,7 @@ namespace ts {
|
||||
/*@internal*/listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
maxNodeModuleJsDepth?: number;
|
||||
module?: ModuleKind;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
newLine?: NewLineKind;
|
||||
@@ -2556,6 +2564,8 @@ namespace ts {
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
@@ -2581,11 +2591,9 @@ namespace ts {
|
||||
/* @internal */ suppressOutputPathCheck?: boolean;
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
disableSizeLimit?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
/*@internal*/ version?: boolean;
|
||||
/*@internal*/ watch?: boolean;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace ts {
|
||||
export interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
|
||||
/* @internal */
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
@@ -1702,7 +1705,7 @@ namespace ts {
|
||||
node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) {
|
||||
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) {
|
||||
const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
|
||||
}
|
||||
@@ -2275,7 +2278,8 @@ namespace ts {
|
||||
else {
|
||||
const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
|
||||
for (const sourceFile of sourceFiles) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
// Don't emit if source file is a declaration file, or was located under node_modules
|
||||
if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) {
|
||||
onSingleFileEmit(host, sourceFile);
|
||||
}
|
||||
}
|
||||
@@ -2307,11 +2311,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function onBundledEmit(host: EmitHost) {
|
||||
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
|
||||
const bundledSources = filter(host.getSourceFiles(), sourceFile =>
|
||||
!isDeclarationFile(sourceFile) // Not a declaration file
|
||||
&& (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); // and not a module, unless module emit enabled
|
||||
|
||||
// Can emit only sources that are not declaration file and are either non module code or module with
|
||||
// --module or --target es6 specified. Files included by searching under node_modules are also not emitted.
|
||||
const bundledSources = filter(host.getSourceFiles(),
|
||||
sourceFile => !isDeclarationFile(sourceFile) &&
|
||||
!host.isSourceFileFromExternalLibrary(sourceFile) &&
|
||||
(!isExternalModule(sourceFile) ||
|
||||
!!getEmitModuleKind(options)));
|
||||
if (bundledSources.length) {
|
||||
const jsFilePath = options.outFile || options.out;
|
||||
const emitFileNames: EmitFileNames = {
|
||||
|
||||
+14
-11
@@ -310,6 +310,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
this.formatCodeOptions = {
|
||||
BaseIndentSize: 0,
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: Harness.IO.newLine(),
|
||||
@@ -323,6 +324,7 @@ namespace FourSlash {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
|
||||
PlaceOpenBraceOnNewLineForFunctions: false,
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
};
|
||||
@@ -1659,24 +1661,25 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle): number {
|
||||
private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle, baseIndentSize: number): number {
|
||||
|
||||
const formatOptions = ts.clone(this.formatCodeOptions);
|
||||
formatOptions.IndentStyle = indentStyle;
|
||||
formatOptions.BaseIndentSize = baseIndentSize;
|
||||
|
||||
return this.languageService.getIndentationAtPosition(fileName, position, formatOptions);
|
||||
}
|
||||
|
||||
public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
|
||||
const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle);
|
||||
public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
|
||||
const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle, baseIndentSize);
|
||||
const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
|
||||
if (actual !== numberOfSpaces) {
|
||||
this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
|
||||
const actual = this.getIndentation(fileName, position, indentStyle);
|
||||
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
|
||||
const actual = this.getIndentation(fileName, position, indentStyle, baseIndentSize);
|
||||
const lineCol = this.getLineColStringAtPosition(position);
|
||||
if (actual !== numberOfSpaces) {
|
||||
this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
|
||||
@@ -1892,7 +1895,7 @@ namespace FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
public verifyBraceCompletionAtPostion(negative: boolean, openingBrace: string) {
|
||||
public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) {
|
||||
|
||||
const openBraceMap: ts.Map<ts.CharacterCodes> = {
|
||||
"(": ts.CharacterCodes.openParen,
|
||||
@@ -1912,7 +1915,7 @@ namespace FourSlash {
|
||||
|
||||
const position = this.currentCaretPosition;
|
||||
|
||||
const validBraceCompletion = this.languageService.isValidBraceCompletionAtPostion(this.activeFile.fileName, position, charCode);
|
||||
const validBraceCompletion = this.languageService.isValidBraceCompletionAtPosition(this.activeFile.fileName, position, charCode);
|
||||
|
||||
if (!negative && !validBraceCompletion) {
|
||||
this.raiseError(`${position} is not a valid brace completion position for ${openingBrace}`);
|
||||
@@ -2920,8 +2923,8 @@ namespace FourSlashInterface {
|
||||
this.state.verifyDefinitionsName(this.negative, name, containerName);
|
||||
}
|
||||
|
||||
public isValidBraceCompletionAtPostion(openingBrace: string) {
|
||||
this.state.verifyBraceCompletionAtPostion(this.negative, openingBrace);
|
||||
public isValidBraceCompletionAtPosition(openingBrace: string) {
|
||||
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2938,8 +2941,8 @@ namespace FourSlashInterface {
|
||||
this.state.verifyIndentationAtCurrentPosition(numberOfSpaces);
|
||||
}
|
||||
|
||||
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart) {
|
||||
this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle);
|
||||
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
|
||||
this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle, baseIndentSize);
|
||||
}
|
||||
|
||||
public textAtCaretIs(text: string) {
|
||||
|
||||
@@ -494,8 +494,8 @@ namespace Harness.LanguageService {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion {
|
||||
return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position));
|
||||
}
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
|
||||
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace));
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
|
||||
}
|
||||
getEmitOutput(fileName: string): ts.EmitOutput {
|
||||
return unwrapJSONCallResult(this.shim.getEmitOutput(fileName));
|
||||
|
||||
+34
-28
@@ -8,7 +8,12 @@ interface FileInformation {
|
||||
}
|
||||
|
||||
interface FindFileResult {
|
||||
}
|
||||
|
||||
interface IOLogFile {
|
||||
path: string;
|
||||
codepage: number;
|
||||
result?: FileInformation;
|
||||
}
|
||||
|
||||
interface IOLog {
|
||||
@@ -17,11 +22,7 @@ interface IOLog {
|
||||
executingPath: string;
|
||||
currentDirectory: string;
|
||||
useCustomLibraryFile?: boolean;
|
||||
filesRead: {
|
||||
path: string;
|
||||
codepage: number;
|
||||
result?: FileInformation;
|
||||
}[];
|
||||
filesRead: IOLogFile[];
|
||||
filesWritten: {
|
||||
path: string;
|
||||
contents: string;
|
||||
@@ -61,7 +62,7 @@ interface IOLog {
|
||||
}[];
|
||||
directoriesRead: {
|
||||
path: string,
|
||||
extension: string[],
|
||||
extensions: string[],
|
||||
exclude: string[],
|
||||
include: string[],
|
||||
result: string[]
|
||||
@@ -170,8 +171,7 @@ namespace Playback {
|
||||
path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }),
|
||||
memoize(path => {
|
||||
// If we read from the file, it must exist
|
||||
const noResult = {};
|
||||
if (findResultByPath(wrapper, replayLog.filesRead, path, noResult) !== noResult) {
|
||||
if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -215,16 +215,30 @@ namespace Playback {
|
||||
recordLog.filesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
memoize(path => findResultByPath(wrapper, replayLog.filesRead, path).contents));
|
||||
memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
|
||||
|
||||
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
|
||||
(path, extension, exclude, include) => {
|
||||
const result = (<ts.System>underlying).readDirectory(path, extension, exclude, include);
|
||||
const logEntry = { path, extension, exclude, include, result };
|
||||
(path, extensions, exclude, include) => {
|
||||
const result = (<ts.System>underlying).readDirectory(path, extensions, exclude, include);
|
||||
const logEntry = { path, extensions, exclude, include, result };
|
||||
recordLog.directoriesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
(path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead, path));
|
||||
(path, extensions, exclude) => {
|
||||
// Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one
|
||||
// if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered
|
||||
// different entry).
|
||||
// TODO (yuisu): We can certainly remove these once we recapture the RWC using new API
|
||||
const normalizedPath = ts.normalizePath(path).toLowerCase();
|
||||
const result: string[] = [];
|
||||
for (const directory of replayLog.directoriesRead) {
|
||||
if (ts.normalizeSlashes(directory.path).toLowerCase() === normalizedPath) {
|
||||
result.push(...directory.result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
|
||||
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
|
||||
@@ -279,30 +293,22 @@ namespace Playback {
|
||||
return results[0].result;
|
||||
}
|
||||
|
||||
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
|
||||
function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[],
|
||||
expectedPath: string, throwFileNotFoundError: boolean): FileInformation {
|
||||
const normalizedName = ts.normalizePath(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal fileName
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
return logArray[i].result;
|
||||
}
|
||||
}
|
||||
// Fallback, try to resolve the target paths as well
|
||||
if (replayLog.pathsResolved.length > 0) {
|
||||
const normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase();
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (wrapper.resolvePath(logArray[i].path).toLowerCase() === normalizedResolvedName) {
|
||||
return logArray[i].result;
|
||||
}
|
||||
for (const log of logArray) {
|
||||
if (ts.normalizeSlashes(log.path).toLowerCase() === normalizedName) {
|
||||
return log.result;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got here, we didn't find a match
|
||||
if (defaultValue === undefined) {
|
||||
if (throwFileNotFoundError) {
|
||||
throw new Error("No matching result in log array for path: " + expectedPath);
|
||||
}
|
||||
else {
|
||||
return defaultValue;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,18 +31,12 @@ abstract class RunnerBase {
|
||||
|
||||
/** Replaces instances of full paths with fileNames only */
|
||||
static removeFullPaths(path: string) {
|
||||
let fixedPath = path;
|
||||
|
||||
// full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point
|
||||
const fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
const fullPathList = fixedPath.match(fullPath);
|
||||
if (fullPathList) {
|
||||
fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match)));
|
||||
}
|
||||
// If its a full path (starts with "C:" or "/") replace with just the filename
|
||||
let fixedPath = /^(\w:|\/)/.test(path) ? Harness.Path.getFileName(path) : path;
|
||||
|
||||
// when running in the browser the 'full path' is the host name, shows up in error baselines
|
||||
const localHost = /http:\/localhost:\d+/g;
|
||||
fixedPath = fixedPath.replace(localHost, "");
|
||||
return fixedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1968
-1968
File diff suppressed because it is too large
Load Diff
Vendored
+7
-27
@@ -1255,33 +1255,13 @@ declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | P
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise with the same internal state of this Promise.
|
||||
* @returns A Promise.
|
||||
*/
|
||||
then(): PromiseLike<T>;
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
interface ArrayLike<T> {
|
||||
|
||||
Vendored
+13
@@ -276,3 +276,16 @@ interface VBArrayConstructor {
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
|
||||
/**
|
||||
* Automation date (VT_DATE)
|
||||
*/
|
||||
interface VarDate { }
|
||||
|
||||
interface DateConstructor {
|
||||
new (vd: VarDate): Date;
|
||||
}
|
||||
|
||||
interface Date {
|
||||
getVarDate: () => VarDate;
|
||||
}
|
||||
|
||||
Vendored
+83
-83
@@ -342,8 +342,8 @@ declare var IDBCursorWithValue: {
|
||||
interface IDBDatabase extends EventTarget {
|
||||
readonly name: string;
|
||||
readonly objectStoreNames: DOMStringList;
|
||||
onabort: (ev: Event) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
version: number;
|
||||
onversionchange: (ev: IDBVersionChangeEvent) => any;
|
||||
close(): void;
|
||||
@@ -351,8 +351,8 @@ interface IDBDatabase extends EventTarget {
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: string | string[], mode?: string): IDBTransaction;
|
||||
addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -430,12 +430,12 @@ declare var IDBObjectStore: {
|
||||
}
|
||||
|
||||
interface IDBOpenDBRequest extends IDBRequest {
|
||||
onblocked: (ev: Event) => any;
|
||||
onupgradeneeded: (ev: IDBVersionChangeEvent) => any;
|
||||
addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
onblocked: (this: this, ev: Event) => any;
|
||||
onupgradeneeded: (this: this, ev: IDBVersionChangeEvent) => any;
|
||||
addEventListener(type: "blocked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "upgradeneeded", listener: (this: this, ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -446,14 +446,14 @@ declare var IDBOpenDBRequest: {
|
||||
|
||||
interface IDBRequest extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onsuccess: (ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onsuccess: (this: this, ev: Event) => any;
|
||||
readonly readyState: string;
|
||||
readonly result: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
readonly transaction: IDBTransaction;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -466,17 +466,17 @@ interface IDBTransaction extends EventTarget {
|
||||
readonly db: IDBDatabase;
|
||||
readonly error: DOMError;
|
||||
readonly mode: string;
|
||||
onabort: (ev: Event) => any;
|
||||
oncomplete: (ev: Event) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
oncomplete: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
abort(): void;
|
||||
objectStore(name: string): IDBObjectStore;
|
||||
readonly READ_ONLY: string;
|
||||
readonly READ_WRITE: string;
|
||||
readonly VERSION_CHANGE: string;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -535,16 +535,16 @@ declare var MSApp: MSApp;
|
||||
|
||||
interface MSAppAsyncOperation extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
oncomplete: (ev: Event) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
oncomplete: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly result: any;
|
||||
start(): void;
|
||||
readonly COMPLETED: number;
|
||||
readonly ERROR: number;
|
||||
readonly STARTED: number;
|
||||
addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -628,11 +628,11 @@ declare var MessageEvent: {
|
||||
}
|
||||
|
||||
interface MessagePort extends EventTarget {
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
close(): void;
|
||||
postMessage(message?: any, ports?: any): void;
|
||||
start(): void;
|
||||
addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -684,10 +684,10 @@ interface WebSocket extends EventTarget {
|
||||
binaryType: string;
|
||||
readonly bufferedAmount: number;
|
||||
readonly extensions: string;
|
||||
onclose: (ev: CloseEvent) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onopen: (ev: Event) => any;
|
||||
onclose: (this: this, ev: CloseEvent) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
onopen: (this: this, ev: Event) => any;
|
||||
readonly protocol: string;
|
||||
readonly readyState: number;
|
||||
readonly url: string;
|
||||
@@ -697,10 +697,10 @@ interface WebSocket extends EventTarget {
|
||||
readonly CLOSING: number;
|
||||
readonly CONNECTING: number;
|
||||
readonly OPEN: number;
|
||||
addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "close", listener: (this: this, ev: CloseEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "open", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -714,11 +714,11 @@ declare var WebSocket: {
|
||||
}
|
||||
|
||||
interface Worker extends EventTarget, AbstractWorker {
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
postMessage(message: any, ports?: any): void;
|
||||
terminate(): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@ declare var Worker: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (ev: ProgressEvent) => any;
|
||||
onreadystatechange: (this: this, ev: ProgressEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -754,14 +754,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -786,30 +786,30 @@ declare var XMLHttpRequestUpload: {
|
||||
}
|
||||
|
||||
interface AbstractWorker {
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
interface MSBaseReader {
|
||||
onabort: (ev: Event) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onload: (ev: Event) => any;
|
||||
onloadend: (ev: ProgressEvent) => any;
|
||||
onloadstart: (ev: Event) => any;
|
||||
onprogress: (ev: ProgressEvent) => any;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onload: (this: this, ev: Event) => any;
|
||||
onloadend: (this: this, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: this, ev: Event) => any;
|
||||
onprogress: (this: this, ev: ProgressEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly result: any;
|
||||
abort(): void;
|
||||
readonly DONE: number;
|
||||
readonly EMPTY: number;
|
||||
readonly LOADING: number;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -838,20 +838,20 @@ interface WindowConsole {
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTarget {
|
||||
onabort: (ev: Event) => any;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onload: (ev: Event) => any;
|
||||
onloadend: (ev: ProgressEvent) => any;
|
||||
onloadstart: (ev: Event) => any;
|
||||
onprogress: (ev: ProgressEvent) => any;
|
||||
ontimeout: (ev: ProgressEvent) => any;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onload: (this: this, ev: Event) => any;
|
||||
onloadend: (this: this, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: this, ev: Event) => any;
|
||||
onprogress: (this: this, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: this, ev: ProgressEvent) => any;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -869,13 +869,13 @@ declare var FileReaderSync: {
|
||||
|
||||
interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole {
|
||||
readonly location: WorkerLocation;
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
readonly self: WorkerGlobalScope;
|
||||
close(): void;
|
||||
msWriteProfilerMark(profilerMarkName: string): void;
|
||||
toString(): string;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -911,9 +911,9 @@ declare var WorkerNavigator: {
|
||||
}
|
||||
|
||||
interface DedicatedWorkerGlobalScope {
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
postMessage(data: any): void;
|
||||
addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -1169,7 +1169,7 @@ interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
}
|
||||
declare var location: WorkerLocation;
|
||||
declare var onerror: (ev: ErrorEvent) => any;
|
||||
declare var onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any;
|
||||
declare var self: WorkerGlobalScope;
|
||||
declare function close(): void;
|
||||
declare function msWriteProfilerMark(profilerMarkName: string): void;
|
||||
@@ -1192,11 +1192,11 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number):
|
||||
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
|
||||
declare function atob(encodedString: string): string;
|
||||
declare function btoa(rawString: string): string;
|
||||
declare var onmessage: (ev: MessageEvent) => any;
|
||||
declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any;
|
||||
declare function postMessage(data: any): void;
|
||||
declare var console: Console;
|
||||
declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "error", listener: (this: WorkerGlobalScope, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "message", listener: (this: WorkerGlobalScope, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
type AlgorithmIdentifier = string | Algorithm;
|
||||
type IDBKeyPath = string;
|
||||
|
||||
@@ -588,7 +588,7 @@ namespace ts.server {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1574,6 +1574,7 @@ namespace ts.server {
|
||||
|
||||
static getDefaultFormatCodeOptions(host: ServerHost): ts.FormatCodeOptions {
|
||||
return ts.clone({
|
||||
BaseIndentSize: 0,
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: host.newLine || "\n",
|
||||
@@ -1587,6 +1588,7 @@ namespace ts.server {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
|
||||
PlaceOpenBraceOnNewLineForFunctions: false,
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
});
|
||||
|
||||
Vendored
+4
-1
@@ -438,6 +438,9 @@ declare namespace ts.server.protocol {
|
||||
/** Number of spaces to indent during formatting. Default value is 4. */
|
||||
indentSize?: number;
|
||||
|
||||
/** Number of additional spaces to indent during formatting to preserve base indentation (ex. script block indentation). Default value is 0. */
|
||||
baseIndentSize?: number;
|
||||
|
||||
/** The new line character to be used. Default value is the OS line delimiter. */
|
||||
newLineCharacter?: string;
|
||||
|
||||
@@ -478,7 +481,7 @@ declare namespace ts.server.protocol {
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
|
||||
/** Index operator */
|
||||
[key: string]: string | number | boolean;
|
||||
[key: string]: string | number | boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -703,6 +703,7 @@ namespace ts.server {
|
||||
if (lineText.search("\\S") < 0) {
|
||||
// TODO: get these options from host
|
||||
const editorOptions: ts.EditorOptions = {
|
||||
BaseIndentSize: formatOptions.BaseIndentSize,
|
||||
IndentSize: formatOptions.IndentSize,
|
||||
TabSize: formatOptions.TabSize,
|
||||
NewLineCharacter: formatOptions.NewLineCharacter,
|
||||
|
||||
@@ -394,7 +394,10 @@ namespace ts.formatting {
|
||||
const startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
const column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column;
|
||||
// Use the base indent size if it is greater than
|
||||
// the indentation of the inherited predecessor.
|
||||
const baseIndentSize = SmartIndenter.getBaseIndentation(options);
|
||||
return baseIndentSize > column ? baseIndentSize : column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,12 @@ namespace ts.formatting {
|
||||
public NoSpaceBeforeTemplateMiddleAndTail: Rule;
|
||||
public SpaceBeforeTemplateMiddleAndTail: Rule;
|
||||
|
||||
// No space after { and before } in JSX expression
|
||||
public NoSpaceAfterOpenBraceInJsxExpression: Rule;
|
||||
public SpaceAfterOpenBraceInJsxExpression: Rule;
|
||||
public NoSpaceBeforeCloseBraceInJsxExpression: Rule;
|
||||
public SpaceBeforeCloseBraceInJsxExpression: Rule;
|
||||
|
||||
constructor() {
|
||||
///
|
||||
/// Common Rules
|
||||
@@ -264,7 +270,7 @@ namespace ts.formatting {
|
||||
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
|
||||
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword]);
|
||||
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ImportKeyword]);
|
||||
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Place a space before open brace in a control flow construct
|
||||
@@ -316,7 +322,7 @@ namespace ts.formatting {
|
||||
|
||||
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
|
||||
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
|
||||
this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space));
|
||||
this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNotForContext), RuleAction.Space));
|
||||
|
||||
// This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
|
||||
this.SpaceAfterTryFinally = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword]), SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
@@ -338,8 +344,8 @@ namespace ts.formatting {
|
||||
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Add a space around certain TypeScript keywords
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
|
||||
this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space));
|
||||
@@ -444,8 +450,8 @@ namespace ts.formatting {
|
||||
///
|
||||
|
||||
// Insert space after comma delimiter
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space));
|
||||
this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space));
|
||||
this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext), RuleAction.Delete));
|
||||
|
||||
// Insert space before and after binary operators
|
||||
this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
@@ -491,6 +497,12 @@ namespace ts.formatting {
|
||||
this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// No space after { and before } in JSX expression
|
||||
this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete));
|
||||
this.SpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete));
|
||||
this.SpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space));
|
||||
|
||||
// Insert space after function keyword for anonymous functions
|
||||
this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete));
|
||||
@@ -514,6 +526,8 @@ namespace ts.formatting {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
@@ -650,6 +664,10 @@ namespace ts.formatting {
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.NamedExports:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.NamedImports:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -723,6 +741,14 @@ namespace ts.formatting {
|
||||
return context.TokensAreOnSameLine() && context.contextNode.kind !== SyntaxKind.JsxText;
|
||||
}
|
||||
|
||||
static isNonJsxElementContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind !== SyntaxKind.JsxElement;
|
||||
}
|
||||
|
||||
static isJsxExpressionContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.JsxExpression;
|
||||
}
|
||||
|
||||
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
|
||||
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,15 @@ namespace ts.formatting {
|
||||
rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail);
|
||||
}
|
||||
|
||||
if (options.InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) {
|
||||
rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression);
|
||||
rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression);
|
||||
}
|
||||
else {
|
||||
rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression);
|
||||
rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression);
|
||||
}
|
||||
|
||||
if (options.InsertSpaceAfterSemicolonInForStatements) {
|
||||
rules.push(this.globalRules.SpaceAfterSemicolonInFor);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ts.formatting {
|
||||
|
||||
export function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
if (position > sourceFile.text.length) {
|
||||
return 0; // past EOF
|
||||
return getBaseIndentation(options); // past EOF
|
||||
}
|
||||
|
||||
// no indentation when the indent style is set to none,
|
||||
@@ -21,7 +21,7 @@ namespace ts.formatting {
|
||||
|
||||
const precedingToken = findPrecedingToken(position, sourceFile);
|
||||
if (!precedingToken) {
|
||||
return 0;
|
||||
return getBaseIndentation(options);
|
||||
}
|
||||
|
||||
// no indentation in string \regex\template literals
|
||||
@@ -96,13 +96,17 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (!current) {
|
||||
// no parent was found - return 0 to be indented on the level of SourceFile
|
||||
return 0;
|
||||
// no parent was found - return the base indentation of the SourceFile
|
||||
return getBaseIndentation(options);
|
||||
}
|
||||
|
||||
return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options);
|
||||
}
|
||||
|
||||
export function getBaseIndentation(options: EditorOptions) {
|
||||
return options.BaseIndentSize || 0;
|
||||
}
|
||||
|
||||
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
|
||||
const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
@@ -162,7 +166,7 @@ namespace ts.formatting {
|
||||
parent = current.parent;
|
||||
}
|
||||
|
||||
return indentationDelta;
|
||||
return indentationDelta + getBaseIndentation(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -462,7 +466,10 @@ namespace ts.formatting {
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.NamedExports:
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -486,6 +493,11 @@ namespace ts.formatting {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return childKind !== SyntaxKind.Block;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return childKind !== SyntaxKind.NamedExports;
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return childKind !== SyntaxKind.ImportClause ||
|
||||
((<ImportClause>child).namedBindings && (<ImportClause>child).namedBindings.kind !== SyntaxKind.NamedImports);
|
||||
case SyntaxKind.JsxElement:
|
||||
return childKind !== SyntaxKind.JsxClosingElement;
|
||||
}
|
||||
|
||||
@@ -412,8 +412,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
return getJSDocTypedefTagName(<JSDocTypedefTag>node);
|
||||
default:
|
||||
Debug.fail();
|
||||
return "";
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1152,7 +1152,7 @@ namespace ts {
|
||||
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
|
||||
@@ -1249,6 +1249,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface EditorOptions {
|
||||
BaseIndentSize?: number;
|
||||
IndentSize: number;
|
||||
TabSize: number;
|
||||
NewLineCharacter: string;
|
||||
@@ -1271,9 +1272,10 @@ namespace ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
||||
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
[s: string]: boolean | number | string | undefined;
|
||||
}
|
||||
|
||||
export interface DefinitionInfo {
|
||||
@@ -8075,7 +8077,7 @@ namespace ts {
|
||||
return { newText: result, caretOffset: preamble.length };
|
||||
}
|
||||
|
||||
function isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
|
||||
function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
|
||||
// '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too
|
||||
// expensive to do during typing scenarios
|
||||
@@ -8443,7 +8445,7 @@ namespace ts {
|
||||
getFormattingEditsForDocument,
|
||||
getFormattingEditsAfterKeystroke,
|
||||
getDocCommentTemplateAtPosition,
|
||||
isValidBraceCompletionAtPostion,
|
||||
isValidBraceCompletionAtPosition,
|
||||
getEmitOutput,
|
||||
getNonBoundSourceFile,
|
||||
getProgram
|
||||
|
||||
+20
-5
@@ -233,9 +233,10 @@ namespace ts {
|
||||
* at the current position.
|
||||
* E.g. we don't want brace completion inside string-literals, comments, etc.
|
||||
*/
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string;
|
||||
|
||||
getEmitOutput(fileName: string): string;
|
||||
getEmitOutputObject(fileName: string): EmitOutput;
|
||||
}
|
||||
|
||||
export interface ClassifierShim extends Shim {
|
||||
@@ -544,9 +545,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string {
|
||||
return <string>forwardCall(logger, actionDescription, /*returnJson*/ true, action, logPerformance);
|
||||
}
|
||||
|
||||
function forwardCall<T>(logger: Logger, actionDescription: string, returnJson: boolean, action: () => T, logPerformance: boolean): T | string {
|
||||
try {
|
||||
const result = simpleForwardCall(logger, actionDescription, action, logPerformance);
|
||||
return JSON.stringify({ result });
|
||||
return returnJson ? JSON.stringify({ result }) : result;
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof OperationCanceledException) {
|
||||
@@ -558,6 +563,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ShimBase implements Shim {
|
||||
constructor(private factory: ShimFactory) {
|
||||
factory.registerShim(this);
|
||||
@@ -799,10 +805,10 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
public isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string {
|
||||
public isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string {
|
||||
return this.forwardJSONCall(
|
||||
`isValidBraceCompletionAtPostion('${fileName}', ${position}, ${openingBrace})`,
|
||||
() => this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace)
|
||||
`isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`,
|
||||
() => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -944,6 +950,15 @@ namespace ts {
|
||||
() => this.languageService.getEmitOutput(fileName)
|
||||
);
|
||||
}
|
||||
|
||||
public getEmitOutputObject(fileName: string): any {
|
||||
return forwardCall(
|
||||
this.logger,
|
||||
`getEmitOutput('${fileName}')`,
|
||||
/*returnJson*/ false,
|
||||
() => this.languageService.getEmitOutput(fileName),
|
||||
this.logPerformance);
|
||||
}
|
||||
}
|
||||
|
||||
function convertClassifications(classifications: Classifications): { spans: string, endOfLineState: EndOfLineState } {
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace ts {
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamedExports:
|
||||
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
case SyntaxKind.CatchClause:
|
||||
return isCompletedNode((<CatchClause>n).block, sourceFile);
|
||||
@@ -156,6 +158,10 @@ namespace ts {
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return nodeIsPresent((<TemplateSpan>n).literal);
|
||||
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return nodeIsPresent((<ExportDeclaration | ImportDeclaration>n).moduleSpecifier);
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return isCompletedNode((<PrefixUnaryExpression>n).operand, sourceFile);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
error TS2318: Cannot find global type 'Promise'.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Promise'.
|
||||
==== tests/cases/compiler/asyncFunctionNoReturnType.ts (5 errors) ====
|
||||
async () => {
|
||||
~~~~~
|
||||
!!! error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1057: An async function or method must have a valid awaitable return type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS7030: Not all code paths return a value.
|
||||
if (window)
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'window'.
|
||||
return;
|
||||
~~~~~~~
|
||||
!!! error TS7030: Not all code paths return a value.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [asyncFunctionNoReturnType.ts]
|
||||
async () => {
|
||||
if (window)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//// [asyncFunctionNoReturnType.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
};
|
||||
(function () __awaiter(this, void 0, void 0, function* () {
|
||||
if (window)
|
||||
return;
|
||||
}));
|
||||
@@ -1,10 +1,15 @@
|
||||
//// [classExpressionWithStaticPropertiesES61.ts]
|
||||
var v = class C { static a = 1; static b = 2 };
|
||||
var v = class C {
|
||||
static a = 1;
|
||||
static b = 2;
|
||||
static c = C.a + 3;
|
||||
};
|
||||
|
||||
//// [classExpressionWithStaticPropertiesES61.js]
|
||||
var v = (_a = class C {
|
||||
var v = (C_1 = class C {
|
||||
},
|
||||
_a.a = 1,
|
||||
_a.b = 2,
|
||||
_a);
|
||||
var _a;
|
||||
C_1.a = 1,
|
||||
C_1.b = 2,
|
||||
C_1.c = C_1.a + 3,
|
||||
C_1);
|
||||
var C_1;
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts ===
|
||||
var v = class C { static a = 1; static b = 2 };
|
||||
var v = class C {
|
||||
>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 3))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7))
|
||||
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
|
||||
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 31))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
|
||||
|
||||
static b = 2;
|
||||
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 1, 17))
|
||||
|
||||
static c = C.a + 3;
|
||||
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES61.ts, 2, 17))
|
||||
>C.a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7))
|
||||
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
|
||||
|
||||
};
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts ===
|
||||
var v = class C { static a = 1; static b = 2 };
|
||||
var v = class C {
|
||||
>v : typeof C
|
||||
>class C { static a = 1; static b = 2 } : typeof C
|
||||
>class C { static a = 1; static b = 2; static c = C.a + 3;} : typeof C
|
||||
>C : typeof C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
static b = 2;
|
||||
>b : number
|
||||
>2 : number
|
||||
|
||||
static c = C.a + 3;
|
||||
>c : number
|
||||
>C.a + 3 : number
|
||||
>C.a : number
|
||||
>C : typeof C
|
||||
>a : number
|
||||
>3 : number
|
||||
|
||||
};
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
//// [classExpressionWithStaticPropertiesES62.ts]
|
||||
var v = class C { static a = 1; static b };
|
||||
var v = class C {
|
||||
static a = 1;
|
||||
static b
|
||||
static c = {
|
||||
x: "hi"
|
||||
}
|
||||
static d = C.c.x + " world";
|
||||
};
|
||||
|
||||
//// [classExpressionWithStaticPropertiesES62.js]
|
||||
var v = (_a = class C {
|
||||
var v = (C_1 = class C {
|
||||
},
|
||||
_a.a = 1,
|
||||
_a);
|
||||
var _a;
|
||||
C_1.a = 1,
|
||||
C_1.c = {
|
||||
x: "hi"
|
||||
},
|
||||
C_1.d = C_1.c.x + " world",
|
||||
C_1);
|
||||
var C_1;
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts ===
|
||||
var v = class C { static a = 1; static b };
|
||||
var v = class C {
|
||||
>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 3))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7))
|
||||
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17))
|
||||
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 31))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17))
|
||||
|
||||
static b
|
||||
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 1, 17))
|
||||
|
||||
static c = {
|
||||
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
|
||||
|
||||
x: "hi"
|
||||
>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
|
||||
}
|
||||
static d = C.c.x + " world";
|
||||
>d : Symbol(C.d, Decl(classExpressionWithStaticPropertiesES62.ts, 5, 5))
|
||||
>C.c.x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
|
||||
>C.c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7))
|
||||
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
|
||||
>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
|
||||
|
||||
};
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts ===
|
||||
var v = class C { static a = 1; static b };
|
||||
var v = class C {
|
||||
>v : typeof C
|
||||
>class C { static a = 1; static b } : typeof C
|
||||
>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C
|
||||
>C : typeof C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
static b
|
||||
>b : any
|
||||
|
||||
static c = {
|
||||
>c : { x: string; }
|
||||
>{ x: "hi" } : { x: string; }
|
||||
|
||||
x: "hi"
|
||||
>x : string
|
||||
>"hi" : string
|
||||
}
|
||||
static d = C.c.x + " world";
|
||||
>d : string
|
||||
>C.c.x + " world" : string
|
||||
>C.c.x : string
|
||||
>C.c : { x: string; }
|
||||
>C : typeof C
|
||||
>c : { x: string; }
|
||||
>x : string
|
||||
>" world" : string
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [classExpressionWithStaticPropertiesES63.ts]
|
||||
|
||||
declare var console: any;
|
||||
const arr: {y(): number}[] = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
arr.push(class C {
|
||||
static x = i;
|
||||
static y = () => C.x * 2;
|
||||
});
|
||||
}
|
||||
arr.forEach(C => console.log(C.y()));
|
||||
|
||||
//// [classExpressionWithStaticPropertiesES63.js]
|
||||
const arr = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
arr.push((C_1 = class C {
|
||||
},
|
||||
C_1.x = i,
|
||||
C_1.y = () => C_1.x * 2,
|
||||
C_1));
|
||||
}
|
||||
arr.forEach(C => console.log(C.y()));
|
||||
var C_1;
|
||||
@@ -0,0 +1,42 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===
|
||||
|
||||
declare var console: any;
|
||||
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))
|
||||
|
||||
const arr: {y(): number}[] = [];
|
||||
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
|
||||
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
|
||||
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
|
||||
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
|
||||
|
||||
arr.push(class C {
|
||||
>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
|
||||
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
|
||||
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))
|
||||
|
||||
static x = i;
|
||||
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
|
||||
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
|
||||
|
||||
static y = () => C.x * 2;
|
||||
>y : Symbol(C.y, Decl(classExpressionWithStaticPropertiesES63.ts, 5, 21))
|
||||
>C.x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))
|
||||
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
|
||||
|
||||
});
|
||||
}
|
||||
arr.forEach(C => console.log(C.y()));
|
||||
>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
|
||||
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
|
||||
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
|
||||
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))
|
||||
>C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
|
||||
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
|
||||
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===
|
||||
|
||||
declare var console: any;
|
||||
>console : any
|
||||
|
||||
const arr: {y(): number}[] = [];
|
||||
>arr : { y(): number; }[]
|
||||
>y : () => number
|
||||
>[] : undefined[]
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
>i : number
|
||||
>0 : number
|
||||
>i < 3 : boolean
|
||||
>i : number
|
||||
>3 : number
|
||||
>i++ : number
|
||||
>i : number
|
||||
|
||||
arr.push(class C {
|
||||
>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number
|
||||
>arr.push : (...items: { y(): number; }[]) => number
|
||||
>arr : { y(): number; }[]
|
||||
>push : (...items: { y(): number; }[]) => number
|
||||
>class C { static x = i; static y = () => C.x * 2; } : typeof C
|
||||
>C : typeof C
|
||||
|
||||
static x = i;
|
||||
>x : number
|
||||
>i : number
|
||||
|
||||
static y = () => C.x * 2;
|
||||
>y : () => number
|
||||
>() => C.x * 2 : () => number
|
||||
>C.x * 2 : number
|
||||
>C.x : number
|
||||
>C : typeof C
|
||||
>x : number
|
||||
>2 : number
|
||||
|
||||
});
|
||||
}
|
||||
arr.forEach(C => console.log(C.y()));
|
||||
>arr.forEach(C => console.log(C.y())) : void
|
||||
>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
|
||||
>arr : { y(): number; }[]
|
||||
>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
|
||||
>C => console.log(C.y()) : (C: { y(): number; }) => any
|
||||
>C : { y(): number; }
|
||||
>console.log(C.y()) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>C.y() : number
|
||||
>C.y : () => number
|
||||
>C : { y(): number; }
|
||||
>y : () => number
|
||||
|
||||
@@ -4,5 +4,5 @@ tests/cases/compiler/declarationEmit_invalidReference2.ts(1,1): error TS6053: Fi
|
||||
==== tests/cases/compiler/declarationEmit_invalidReference2.ts (1 errors) ====
|
||||
/// <reference path="invalid.ts" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'invalid.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/compiler/invalid.ts' not found.
|
||||
var x = 0;
|
||||
@@ -1,7 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'a.d.ts' because it would overwrite input file.
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/a.d.ts (0 errors) ====
|
||||
|
||||
declare class c {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'out.d.ts' because it would overwrite input file.
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/out.d.ts (0 errors) ====
|
||||
|
||||
declare class c {
|
||||
|
||||
@@ -46,8 +46,9 @@ var MyClass = (function () {
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata('design:paramtypes', [Object])
|
||||
__metadata('design:paramtypes', [(typeof (_a = typeof db_1.default !== 'undefined' && db_1.default.db) === 'function' && _a) || Object])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
var _a;
|
||||
}());
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [destructuringAssignmentWithDefault.ts]
|
||||
const a: { x?: number } = { };
|
||||
let x = 0;
|
||||
({x = 1} = a);
|
||||
|
||||
|
||||
//// [destructuringAssignmentWithDefault.js]
|
||||
var a = {};
|
||||
var x = 0;
|
||||
(_a = a.x, x = _a === void 0 ? 1 : _a, a);
|
||||
var _a;
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/destructuringAssignmentWithDefault.ts ===
|
||||
const a: { x?: number } = { };
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault.ts, 0, 5))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 0, 10))
|
||||
|
||||
let x = 0;
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 1, 3))
|
||||
|
||||
({x = 1} = a);
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 2, 2))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault.ts, 0, 5))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/destructuringAssignmentWithDefault.ts ===
|
||||
const a: { x?: number } = { };
|
||||
>a : { x?: number | undefined; }
|
||||
>x : number | undefined
|
||||
>{ } : {}
|
||||
|
||||
let x = 0;
|
||||
>x : number
|
||||
>0 : number
|
||||
|
||||
({x = 1} = a);
|
||||
>({x = 1} = a) : { x?: number | undefined; }
|
||||
>{x = 1} = a : { x?: number | undefined; }
|
||||
>{x = 1} : { x?: number; }
|
||||
>x : number
|
||||
>a : { x?: number | undefined; }
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [destructuringParameterDeclaration7ES5.ts]
|
||||
|
||||
interface ISomething {
|
||||
foo: string,
|
||||
bar: string
|
||||
}
|
||||
|
||||
function foo({}, {foo, bar}: ISomething) {}
|
||||
|
||||
function baz([], {foo, bar}: ISomething) {}
|
||||
|
||||
function one([], {}) {}
|
||||
|
||||
function two([], [a, b, c]: number[]) {}
|
||||
|
||||
|
||||
//// [destructuringParameterDeclaration7ES5.js]
|
||||
function foo(_a, _b) {
|
||||
var foo = _b.foo, bar = _b.bar;
|
||||
}
|
||||
function baz(_a, _b) {
|
||||
var foo = _b.foo, bar = _b.bar;
|
||||
}
|
||||
function one(_a, _b) { }
|
||||
function two(_a, _b) {
|
||||
var a = _b[0], b = _b[1], c = _b[2];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts ===
|
||||
|
||||
interface ISomething {
|
||||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0))
|
||||
|
||||
foo: string,
|
||||
>foo : Symbol(ISomething.foo, Decl(destructuringParameterDeclaration7ES5.ts, 1, 22))
|
||||
|
||||
bar: string
|
||||
>bar : Symbol(ISomething.bar, Decl(destructuringParameterDeclaration7ES5.ts, 2, 16))
|
||||
}
|
||||
|
||||
function foo({}, {foo, bar}: ISomething) {}
|
||||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 4, 1))
|
||||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 6, 18))
|
||||
>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 6, 22))
|
||||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0))
|
||||
|
||||
function baz([], {foo, bar}: ISomething) {}
|
||||
>baz : Symbol(baz, Decl(destructuringParameterDeclaration7ES5.ts, 6, 43))
|
||||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 8, 18))
|
||||
>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 8, 22))
|
||||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0))
|
||||
|
||||
function one([], {}) {}
|
||||
>one : Symbol(one, Decl(destructuringParameterDeclaration7ES5.ts, 8, 43))
|
||||
|
||||
function two([], [a, b, c]: number[]) {}
|
||||
>two : Symbol(two, Decl(destructuringParameterDeclaration7ES5.ts, 10, 23))
|
||||
>a : Symbol(a, Decl(destructuringParameterDeclaration7ES5.ts, 12, 18))
|
||||
>b : Symbol(b, Decl(destructuringParameterDeclaration7ES5.ts, 12, 20))
|
||||
>c : Symbol(c, Decl(destructuringParameterDeclaration7ES5.ts, 12, 23))
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts ===
|
||||
|
||||
interface ISomething {
|
||||
>ISomething : ISomething
|
||||
|
||||
foo: string,
|
||||
>foo : string
|
||||
|
||||
bar: string
|
||||
>bar : string
|
||||
}
|
||||
|
||||
function foo({}, {foo, bar}: ISomething) {}
|
||||
>foo : ({}: {}, {foo, bar}: ISomething) => void
|
||||
>foo : string
|
||||
>bar : string
|
||||
>ISomething : ISomething
|
||||
|
||||
function baz([], {foo, bar}: ISomething) {}
|
||||
>baz : ([]: any[], {foo, bar}: ISomething) => void
|
||||
>foo : string
|
||||
>bar : string
|
||||
>ISomething : ISomething
|
||||
|
||||
function one([], {}) {}
|
||||
>one : ([]: any[], {}: {}) => void
|
||||
|
||||
function two([], [a, b, c]: number[]) {}
|
||||
>two : ([]: any[], [a, b, c]: number[]) => void
|
||||
>a : number
|
||||
>b : number
|
||||
>c : number
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [exportDefaultAsyncFunction.ts]
|
||||
export default async function foo(): Promise<void> {}
|
||||
foo();
|
||||
|
||||
|
||||
//// [exportDefaultAsyncFunction.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
};
|
||||
export default function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () { });
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/exportDefaultAsyncFunction.ts ===
|
||||
export default async function foo(): Promise<void> {}
|
||||
>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
foo();
|
||||
>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/exportDefaultAsyncFunction.ts ===
|
||||
export default async function foo(): Promise<void> {}
|
||||
>foo : () => Promise<void>
|
||||
>Promise : Promise<T>
|
||||
|
||||
foo();
|
||||
>foo() : Promise<void>
|
||||
>foo : () => Promise<void>
|
||||
|
||||
@@ -14,7 +14,7 @@ tests/cases/compiler/exportStarFromEmptyModule_module4.ts(4,5): error TS2339: Pr
|
||||
==== tests/cases/compiler/exportStarFromEmptyModule_module3.ts (1 errors) ====
|
||||
export * from "./exportStarFromEmptyModule_module2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2306: File 'exportStarFromEmptyModule_module2.ts' is not a module.
|
||||
!!! error TS2306: File 'tests/cases/compiler/exportStarFromEmptyModule_module2.ts' is not a module.
|
||||
export * from "./exportStarFromEmptyModule_module1";
|
||||
|
||||
export class A {
|
||||
|
||||
@@ -4,7 +4,7 @@ tests/cases/conformance/externalModules/foo_1.ts(1,22): error TS2306: File 'test
|
||||
==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ====
|
||||
import foo = require("./foo_0");
|
||||
~~~~~~~~~
|
||||
!!! error TS2306: File 'foo_0.ts' is not a module.
|
||||
!!! error TS2306: File 'tests/cases/conformance/externalModules/foo_0.ts' is not a module.
|
||||
// Import should fail. foo_0 not an external module
|
||||
if(foo.answer === 42){
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts (5 errors) ====
|
||||
interface Base {
|
||||
readonly value: number;
|
||||
}
|
||||
interface Identical {
|
||||
readonly value: number;
|
||||
}
|
||||
interface Mutable {
|
||||
value: number;
|
||||
}
|
||||
interface DifferentType {
|
||||
readonly value: string;
|
||||
}
|
||||
interface DifferentName {
|
||||
readonly other: number;
|
||||
}
|
||||
let base: Base;
|
||||
base.value = 12 // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
let identical: Base & Identical;
|
||||
identical.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
let mutable: Base & Mutable;
|
||||
mutable.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
let differentType: Base & DifferentType;
|
||||
differentType.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
let differentName: Base & DifferentName;
|
||||
differentName.value = 12; // error, property 'value' doesn't exist
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//// [intersectionTypeReadonly.ts]
|
||||
interface Base {
|
||||
readonly value: number;
|
||||
}
|
||||
interface Identical {
|
||||
readonly value: number;
|
||||
}
|
||||
interface Mutable {
|
||||
value: number;
|
||||
}
|
||||
interface DifferentType {
|
||||
readonly value: string;
|
||||
}
|
||||
interface DifferentName {
|
||||
readonly other: number;
|
||||
}
|
||||
let base: Base;
|
||||
base.value = 12 // error, lhs can't be a readonly property
|
||||
let identical: Base & Identical;
|
||||
identical.value = 12; // error, lhs can't be a readonly property
|
||||
let mutable: Base & Mutable;
|
||||
mutable.value = 12; // error, lhs can't be a readonly property
|
||||
let differentType: Base & DifferentType;
|
||||
differentType.value = 12; // error, lhs can't be a readonly property
|
||||
let differentName: Base & DifferentName;
|
||||
differentName.value = 12; // error, property 'value' doesn't exist
|
||||
|
||||
|
||||
//// [intersectionTypeReadonly.js]
|
||||
var base;
|
||||
base.value = 12; // error, lhs can't be a readonly property
|
||||
var identical;
|
||||
identical.value = 12; // error, lhs can't be a readonly property
|
||||
var mutable;
|
||||
mutable.value = 12; // error, lhs can't be a readonly property
|
||||
var differentType;
|
||||
differentType.value = 12; // error, lhs can't be a readonly property
|
||||
var differentName;
|
||||
differentName.value = 12; // error, property 'value' doesn't exist
|
||||
@@ -5,10 +5,10 @@ tests/cases/compiler/invalidTripleSlashReference.ts(2,1): error TS6053: File 'te
|
||||
==== tests/cases/compiler/invalidTripleSlashReference.ts (2 errors) ====
|
||||
/// <reference path='filedoesnotexist.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'filedoesnotexist.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/compiler/filedoesnotexist.ts' not found.
|
||||
/// <reference path='otherdoesnotexist.d.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'otherdoesnotexist.d.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/compiler/otherdoesnotexist.d.ts' not found.
|
||||
|
||||
// this test doesn't actually give the errors you want due to the way the compiler reports errors
|
||||
var x = 1;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'a.d.ts' because it would overwrite input file.
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'b.d.ts' because it would overwrite input file.
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
==== /node_modules/bar/index.d.ts (1 errors) ====
|
||||
/// <reference types="alpha" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! message TS4090: Conflicting library definitions for 'alpha' found at 'index.d.ts' and 'index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict.
|
||||
!!! message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict.
|
||||
declare var bar: any;
|
||||
|
||||
==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ====
|
||||
|
||||
@@ -8,8 +8,6 @@ export {};
|
||||
//// [app.ts]
|
||||
import "A"
|
||||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
//// [app.js]
|
||||
"use strict";
|
||||
require("A");
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource1.ts(4,1): error TS60
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export module CompilerDiagnostics {
|
||||
|
||||
@@ -348,7 +348,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export enum TokenID {
|
||||
|
||||
@@ -523,7 +523,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export class ASTSpan {
|
||||
|
||||
@@ -215,7 +215,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource12.ts(524,30): error
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export interface IAstWalker {
|
||||
|
||||
@@ -122,7 +122,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(135,36): error
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript.AstWalkerWithDetailCallback {
|
||||
export interface AstWalkerDetailCallback {
|
||||
|
||||
@@ -166,7 +166,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export function lastOf(items: any[]): any {
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource2.ts(4,1): error TS60
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource3.ts(4,1): error TS60
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
// Note: Any addition to the NodeType should also be supported with addition to AstWalkerDetailCallback
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(195,37): error T
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource5.ts(61,65): error TS
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
// TODO: refactor indent logic for use in emit
|
||||
|
||||
@@ -67,7 +67,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource6.ts(215,20): error T
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export class TypeCollectionContext {
|
||||
|
||||
@@ -309,7 +309,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export class Continuation {
|
||||
|
||||
@@ -140,7 +140,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(454,35): error T
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(200,48): error T
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found.
|
||||
|
||||
module TypeScript {
|
||||
export class Binder {
|
||||
|
||||
@@ -128,16 +128,16 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32):
|
||||
|
||||
///<reference path='..\compiler\io.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'io.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/compiler/io.ts' not found.
|
||||
///<reference path='..\compiler\typescript.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescript.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/compiler/typescript.ts' not found.
|
||||
///<reference path='..\services\typescriptServices.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'typescriptServices.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/services/typescriptServices.ts' not found.
|
||||
///<reference path='diff.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'diff.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/RealWorld/diff.ts' not found.
|
||||
|
||||
declare var assert: Harness.Assert;
|
||||
~~~~~~
|
||||
|
||||
@@ -146,7 +146,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38):
|
||||
|
||||
///<reference path='formatting.ts' />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'formatting.ts' not found.
|
||||
!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/RealWorld/formatting.ts' not found.
|
||||
|
||||
|
||||
module Formatting {
|
||||
|
||||
@@ -31,9 +31,6 @@ exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
exports.y = 1;
|
||||
//// [file4.js]
|
||||
"use strict";
|
||||
exports.z1 = 1;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file1_1 = require("folder2/file1");
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
|
||||
|
||||
|
||||
==== main.ts (1 errors) ====
|
||||
import * as ng from "angular2/core";
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'angular2/core'.
|
||||
|
||||
declare function foo(...args: any[]);
|
||||
|
||||
@foo
|
||||
export class MyClass1 {
|
||||
constructor(private _elementRef: ng.ElementRef){}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
|
||||
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule",
|
||||
"baselineCheck": true,
|
||||
"runTest": true,
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"main.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"main.js"
|
||||
]
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
define(["require", "exports", "angular2/core"], function (require, exports, ng) {
|
||||
"use strict";
|
||||
var MyClass1 = (function () {
|
||||
function MyClass1(_elementRef) {
|
||||
this._elementRef = _elementRef;
|
||||
}
|
||||
MyClass1 = __decorate([
|
||||
foo,
|
||||
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
|
||||
], MyClass1);
|
||||
return MyClass1;
|
||||
var _a;
|
||||
}());
|
||||
exports.MyClass1 = MyClass1;
|
||||
});
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
|
||||
|
||||
|
||||
==== main.ts (1 errors) ====
|
||||
import * as ng from "angular2/core";
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'angular2/core'.
|
||||
|
||||
declare function foo(...args: any[]);
|
||||
|
||||
@foo
|
||||
export class MyClass1 {
|
||||
constructor(private _elementRef: ng.ElementRef){}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
|
||||
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule",
|
||||
"baselineCheck": true,
|
||||
"runTest": true,
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"main.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"main.js"
|
||||
]
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var ng = require("angular2/core");
|
||||
var MyClass1 = (function () {
|
||||
function MyClass1(_elementRef) {
|
||||
this._elementRef = _elementRef;
|
||||
}
|
||||
MyClass1 = __decorate([
|
||||
foo,
|
||||
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
|
||||
], MyClass1);
|
||||
return MyClass1;
|
||||
var _a;
|
||||
}());
|
||||
exports.MyClass1 = MyClass1;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user