Merge branch 'master' into narrowing-a-type-parameter-intersects-concrete-types

This commit is contained in:
Nathan Shively-Sanders
2016-08-08 08:42:28 -07:00
209 changed files with 3510 additions and 28277 deletions
+17 -8
View File
@@ -7,19 +7,28 @@ node_js:
sudo: false
os:
- linux
- osx
env:
- workerCount=4
matrix:
fast_finish: true
exclude:
include:
- os: osx
node_js: '4'
- os: osx
node_js: '0.10'
node_js: stable
osx_image: xcode7.3
env: workerCount=2
branches:
only:
- master
- transforms
- transforms
install:
- npm uninstall typescript
- npm uninstall tslint
- npm install
- npm update
cache:
directories:
- node_modules
+4 -7
View File
@@ -59,7 +59,6 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
browser: process.env.browser || process.env.b || "IE",
tests: process.env.test || process.env.tests || process.env.t,
light: process.env.light || false,
port: process.env.port || process.env.p || "8888",
reporter: process.env.reporter || process.env.r,
lint: process.env.lint || true,
files: process.env.f || process.env.file || process.env.files || "",
@@ -450,7 +449,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
});
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
@@ -504,7 +503,7 @@ gulp.task("VerifyLKG", false, [], () => {
return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory));
});
gulp.task("LKGInternal", false, ["lib", "local", "lssl"]);
gulp.task("LKGInternal", false, ["lib", "local"]);
gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => {
return runSequence("LKGInternal", "VerifyLKG");
@@ -766,7 +765,7 @@ function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?:
}
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --port=, --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
cleanTestDirs((err) => {
if (err) { console.error(err); done(err); process.exit(1); }
host = "node";
@@ -781,9 +780,6 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
}
const args = [nodeServerOutFile];
if (cmdLineOptions["port"]) {
args.push(cmdLineOptions["port"]);
}
if (cmdLineOptions["browser"]) {
args.push(cmdLineOptions["browser"]);
}
@@ -960,6 +956,7 @@ const lintTargets = [
"src/server/**/*.ts",
"scripts/tslint/**/*.ts",
"src/services/**/*.ts",
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
];
+7 -7
View File
@@ -551,7 +551,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr
compileFile(
tsserverLibraryFile,
languageServiceLibrarySources,
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
{ noOutFile: false, generateDeclarations: true });
@@ -562,7 +562,7 @@ task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]);
// Local target to build the compiler and services
desc("Builds the full compiler and services");
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl"]);
// Local target to build only tsc.js
desc("Builds only the compiler");
@@ -617,7 +617,7 @@ task("generate-spec", [specMd]);
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
desc("Makes a new LKG out of the built js files");
task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() {
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
var missingFiles = expectedFiles.filter(function (f) {
return !fs.existsSync(f);
@@ -847,11 +847,10 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
exec(cmd);
}, {async: true});
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]");
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
cleanTestDirs();
host = "node";
port = process.env.port || process.env.p || '8888';
browser = process.env.browser || process.env.b || "IE";
tests = process.env.test || process.env.tests || process.env.t;
var light = process.env.light || false;
@@ -864,7 +863,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
}
tests = tests ? tests : '';
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON.stringify(tests);
var cmd = host + " tests/webTestServer.js " + browser + " " + JSON.stringify(tests);
console.log(cmd);
exec(cmd);
}, {async: true});
@@ -1042,7 +1041,8 @@ var lintTargets = compilerSources
.concat(serverCoreSources)
.concat(tslintRulesFiles)
.concat(servicesSources)
.concat(["Gulpfile.ts"]);
.concat(["Gulpfile.ts"])
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
+1 -1
View File
@@ -78,7 +78,7 @@
},
"scripts": {
"pretest": "jake tests",
"test": "jake runtests",
"test": "jake runtests-parallel",
"build": "npm run build:compiler && npm run build:tests",
"build:compiler": "jake local",
"build:tests": "jake tests",
+98 -54
View File
@@ -215,7 +215,7 @@ namespace ts {
const flowLoopKeys: string[] = [];
const flowLoopTypes: Type[][] = [];
const visitedFlowNodes: FlowNode[] = [];
const visitedFlowTypes: Type[] = [];
const visitedFlowTypes: FlowType[] = [];
const potentialThisCollisions: Node[] = [];
const awaitedTypeStack: number[] = [];
@@ -1135,6 +1135,10 @@ namespace ts {
else {
symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text);
}
// If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default
if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") {
symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol);
}
// if symbolFromVariable is export - get its final target
symbolFromVariable = resolveSymbol(symbolFromVariable);
const symbolFromModule = getExportOfModule(targetSymbol, name.text);
@@ -7764,16 +7768,17 @@ namespace ts {
}
function isMatchingReference(source: Node, target: Node): boolean {
if (source.kind === target.kind) {
switch (source.kind) {
case SyntaxKind.Identifier:
return getResolvedSymbol(<Identifier>source) === getResolvedSymbol(<Identifier>target);
case SyntaxKind.ThisKeyword:
return true;
case SyntaxKind.PropertyAccessExpression:
return (<PropertyAccessExpression>source).name.text === (<PropertyAccessExpression>target).name.text &&
isMatchingReference((<PropertyAccessExpression>source).expression, (<PropertyAccessExpression>target).expression);
}
switch (source.kind) {
case SyntaxKind.Identifier:
return target.kind === SyntaxKind.Identifier && getResolvedSymbol(<Identifier>source) === getResolvedSymbol(<Identifier>target) ||
(target.kind === SyntaxKind.VariableDeclaration || target.kind === SyntaxKind.BindingElement) &&
getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(<Identifier>source)) === getSymbolOfNode(target);
case SyntaxKind.ThisKeyword:
return target.kind === SyntaxKind.ThisKeyword;
case SyntaxKind.PropertyAccessExpression:
return target.kind === SyntaxKind.PropertyAccessExpression &&
(<PropertyAccessExpression>source).name.text === (<PropertyAccessExpression>target).name.text &&
isMatchingReference((<PropertyAccessExpression>source).expression, (<PropertyAccessExpression>target).expression);
}
return false;
}
@@ -7788,6 +7793,10 @@ namespace ts {
return false;
}
function rootContainsMatchingReference(source: Node, target: Node) {
return target.kind === SyntaxKind.PropertyAccessExpression && containsMatchingReference(source, (<PropertyAccessExpression>target).expression);
}
function isOrContainsMatchingReference(source: Node, target: Node) {
return isMatchingReference(source, target) || containsMatchingReference(source, target);
}
@@ -8032,6 +8041,12 @@ namespace ts {
getInitialTypeOfBindingElement(<BindingElement>node);
}
function getInitialOrAssignedType(node: VariableDeclaration | BindingElement | Expression) {
return node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement ?
getInitialType(<VariableDeclaration | BindingElement>node) :
getAssignedType(<Expression>node);
}
function getReferenceCandidate(node: Expression): Expression {
switch (node.kind) {
case SyntaxKind.ParenthesizedExpression:
@@ -8076,6 +8091,18 @@ namespace ts {
f(type) ? type : neverType;
}
function isIncomplete(flowType: FlowType) {
return flowType.flags === 0;
}
function getTypeFromFlowType(flowType: FlowType) {
return flowType.flags === 0 ? (<IncompleteType>flowType).type : <Type>flowType;
}
function createFlowType(type: Type, incomplete: boolean): FlowType {
return incomplete ? { flags: 0, type } : type;
}
function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) {
let key: string;
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
@@ -8083,14 +8110,14 @@ namespace ts {
}
const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined);
const visitedFlowStart = visitedFlowCount;
const result = getTypeAtFlowNode(reference.flowNode);
const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
visitedFlowCount = visitedFlowStart;
if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === neverType) {
return declaredType;
}
return result;
function getTypeAtFlowNode(flow: FlowNode): Type {
function getTypeAtFlowNode(flow: FlowNode): FlowType {
while (true) {
if (flow.flags & FlowFlags.Shared) {
// We cache results of flow type resolution for shared nodes that were previously visited in
@@ -8102,7 +8129,7 @@ namespace ts {
}
}
}
let type: Type;
let type: FlowType;
if (flow.flags & FlowFlags.Assignment) {
type = getTypeAtFlowAssignment(<FlowAssignment>flow);
if (!type) {
@@ -8154,19 +8181,9 @@ namespace ts {
const node = flow.node;
// Assignments only narrow the computed type if the declared type is a union type. Thus, we
// only need to evaluate the assigned type if the declared type is a union type.
if ((node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement) &&
reference.kind === SyntaxKind.Identifier &&
getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(<Identifier>reference)) === getSymbolOfNode(node)) {
return declaredType.flags & TypeFlags.Union ?
getAssignmentReducedType(<UnionType>declaredType, getInitialType(<VariableDeclaration | BindingElement>node)) :
declaredType;
}
// If the node is not a variable declaration or binding element, it is an identifier
// or a dotted name that is the target of an assignment. If we have a match, reduce
// the declared type by the assigned type.
if (isMatchingReference(reference, node)) {
return declaredType.flags & TypeFlags.Union ?
getAssignmentReducedType(<UnionType>declaredType, getAssignedType(<Expression>node)) :
getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
declaredType;
}
// We didn't have a direct match. However, if the reference is a dotted name, this
@@ -8180,41 +8197,44 @@ namespace ts {
return undefined;
}
function getTypeAtFlowCondition(flow: FlowCondition) {
let type = getTypeAtFlowNode(flow.antecedent);
function getTypeAtFlowCondition(flow: FlowCondition): FlowType {
const flowType = getTypeAtFlowNode(flow.antecedent);
let type = getTypeFromFlowType(flowType);
if (type !== neverType) {
// If we have an antecedent type (meaning we're reachable in some way), we first
// attempt to narrow the antecedent type. If that produces the never type, then
// we take the type guard as an indication that control could reach here in a
// manner not understood by the control flow analyzer (e.g. a function argument
// has an invalid type, or a nested function has possibly made an assignment to a
// captured variable). We proceed by reverting to the declared type and then
// attempt to narrow the antecedent type. If that produces the never type, and if
// the antecedent type is incomplete (i.e. a transient type in a loop), then we
// take the type guard as an indication that control *could* reach here once we
// have the complete type. We proceed by reverting to the declared type and then
// narrow that.
const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0;
type = narrowType(type, flow.expression, assumeTrue);
if (type === neverType) {
if (type === neverType && isIncomplete(flowType)) {
type = narrowType(declaredType, flow.expression, assumeTrue);
}
}
return type;
return createFlowType(type, isIncomplete(flowType));
}
function getTypeAtSwitchClause(flow: FlowSwitchClause) {
const type = getTypeAtFlowNode(flow.antecedent);
function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType {
const flowType = getTypeAtFlowNode(flow.antecedent);
let type = getTypeFromFlowType(flowType);
const expr = flow.switchStatement.expression;
if (isMatchingReference(reference, expr)) {
return narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
}
if (isMatchingPropertyAccess(expr)) {
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd));
else if (isMatchingPropertyAccess(expr)) {
type = narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd));
}
return type;
return createFlowType(type, isIncomplete(flowType));
}
function getTypeAtFlowBranchLabel(flow: FlowLabel) {
function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType {
const antecedentTypes: Type[] = [];
let seenIncomplete = false;
for (const antecedent of flow.antecedents) {
const type = getTypeAtFlowNode(antecedent);
const flowType = getTypeAtFlowNode(antecedent);
const type = getTypeFromFlowType(flowType);
// If the type at a particular antecedent path is the declared type and the
// reference is known to always be assigned (i.e. when declared and initial types
// are the same), there is no reason to process more antecedents since the only
@@ -8225,11 +8245,14 @@ namespace ts {
if (!contains(antecedentTypes, type)) {
antecedentTypes.push(type);
}
if (isIncomplete(flowType)) {
seenIncomplete = true;
}
}
return getUnionType(antecedentTypes);
return createFlowType(getUnionType(antecedentTypes), seenIncomplete);
}
function getTypeAtFlowLoopLabel(flow: FlowLabel) {
function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType {
// If we have previously computed the control flow type for the reference at
// this flow loop junction, return the cached type.
const id = getFlowNodeId(flow);
@@ -8241,12 +8264,12 @@ namespace ts {
return cache[key];
}
// If this flow loop junction and reference are already being processed, return
// the union of the types computed for each branch so far. We should never see
// an empty array here because the first antecedent of a loop junction is always
// the non-looping control flow path that leads to the top.
// the union of the types computed for each branch so far, marked as incomplete.
// We should never see an empty array here because the first antecedent of a loop
// junction is always the non-looping control flow path that leads to the top.
for (let i = flowLoopStart; i < flowLoopCount; i++) {
if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) {
return getUnionType(flowLoopTypes[i]);
return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true);
}
}
// Add the flow loop junction and reference to the in-process stack and analyze
@@ -8257,7 +8280,7 @@ namespace ts {
flowLoopTypes[flowLoopCount] = antecedentTypes;
for (const antecedent of flow.antecedents) {
flowLoopCount++;
const type = getTypeAtFlowNode(antecedent);
const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent));
flowLoopCount--;
// If we see a value appear in the cache it is a sign that control flow analysis
// was restarted and completed by checkExpressionCached. We can simply pick up
@@ -8298,6 +8321,9 @@ namespace ts {
if (isMatchingPropertyAccess(expr)) {
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy));
}
if (rootContainsMatchingReference(reference, expr)) {
return declaredType;
}
return type;
}
@@ -8330,6 +8356,9 @@ namespace ts {
if (isMatchingPropertyAccess(right)) {
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>right, t => narrowTypeByEquality(t, operator, left, assumeTrue));
}
if (rootContainsMatchingReference(reference, left) || rootContainsMatchingReference(reference, right)) {
return declaredType;
}
break;
case SyntaxKind.InstanceOfKeyword:
return narrowTypeByInstanceof(type, expr, assumeTrue);
@@ -10032,7 +10061,7 @@ namespace ts {
for (const prop of props) {
// Is there a corresponding property in the element attributes type? Skip checking of properties
// that have already been assigned to, as these are not actually pushed into the resulting type
if (!nameTable[prop.name]) {
if (!hasProperty(nameTable, prop.name)) {
const targetPropSym = getPropertyOfType(elementAttributesType, prop.name);
if (targetPropSym) {
const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name);
@@ -10378,7 +10407,7 @@ namespace ts {
const targetProperties = getPropertiesOfType(targetAttributesType);
for (let i = 0; i < targetProperties.length; i++) {
if (!(targetProperties[i].flags & SymbolFlags.Optional) &&
nameTable[targetProperties[i].name] === undefined) {
!hasProperty(nameTable, targetProperties[i].name)) {
error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType));
}
@@ -12897,6 +12926,14 @@ namespace ts {
return (target.flags & TypeFlags.Nullable) !== 0 || isTypeComparableTo(source, target);
}
function getBestChoiceType(type1: Type, type2: Type): Type {
const firstAssignableToSecond = isTypeAssignableTo(type1, type2);
const secondAssignableToFirst = isTypeAssignableTo(type2, type1);
return secondAssignableToFirst && !firstAssignableToSecond ? type1 :
firstAssignableToSecond && !secondAssignableToFirst ? type2 :
getUnionType([type1, type2], /*subtypeReduction*/ true);
}
function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) {
return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node);
}
@@ -13040,7 +13077,7 @@ namespace ts {
leftType;
case SyntaxKind.BarBarToken:
return getTypeFacts(leftType) & TypeFacts.Falsy ?
getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], /*subtypeReduction*/ true) :
getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) :
leftType;
case SyntaxKind.EqualsToken:
checkAssignmentOperator(rightType);
@@ -13167,7 +13204,7 @@ namespace ts {
checkExpression(node.condition);
const type1 = checkExpression(node.whenTrue, contextualMapper);
const type2 = checkExpression(node.whenFalse, contextualMapper);
return getUnionType([type1, type2], /*subtypeReduction*/ true);
return getBestChoiceType(type1, type2);
}
function typeContainsLiteralFromEnum(type: Type, enumType: EnumType) {
@@ -16228,6 +16265,12 @@ namespace ts {
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node,
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
if (baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration)) {
if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) {
error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class);
}
}
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) {
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
// that all instantiated base constructor signatures return the same type. We can simply compare the type
@@ -19649,7 +19692,7 @@ namespace ts {
}
function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean {
// A declare modifier is required for any top level .d.ts declaration except export=, export default,
// A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace
// interfaces and imports categories:
//
// DeclarationElement:
@@ -19667,6 +19710,7 @@ namespace ts {
node.kind === SyntaxKind.ImportEqualsDeclaration ||
node.kind === SyntaxKind.ExportDeclaration ||
node.kind === SyntaxKind.ExportAssignment ||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
(node.flags & NodeFlags.Ambient) ||
(node.flags & (NodeFlags.Export | NodeFlags.Default))) {
+7 -3
View File
@@ -323,8 +323,12 @@ namespace ts {
return keys;
}
export function getProperty<T>(map: Map<T>, key: string): T {
return hasOwnProperty.call(map, key) ? map[key] : undefined;
export function getProperty<T>(map: Map<T>, key: string): T | undefined {
return hasProperty(map, key) ? map[key] : undefined;
}
export function getOrUpdateProperty<T>(map: Map<T>, key: string, makeValue: () => T): T {
return hasProperty(map, key) ? map[key] : map[key] = makeValue();
}
export function isEmpty<T>(map: Map<T>) {
@@ -941,7 +945,7 @@ namespace ts {
* [^./] # matches everything up to the first . character (excluding directory seperators)
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
*/
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
const singleAsteriskRegexFragmentOther = "[^/]*";
export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") {
+4
View File
@@ -1947,6 +1947,10 @@
"category": "Error",
"code": 2689
},
"A class must be declared after its base class.": {
"category": "Error",
"code": 2690
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
+3 -2
View File
@@ -2578,7 +2578,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
operand = (<TypeAssertion | NonNullExpression>operand).expression;
}
// We have an expression of the form: (<Type>SubExpr)
// We have an expression of the form: (<Type>SubExpr) or (SubExpr as Type)
// Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is.
// Omitting the parentheses, however, could cause change in the semantics of the generated
// code if the casted expression has a lower precedence than the rest of the expression, e.g.:
@@ -2592,6 +2592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
operand.kind !== SyntaxKind.DeleteExpression &&
operand.kind !== SyntaxKind.PostfixUnaryExpression &&
operand.kind !== SyntaxKind.NewExpression &&
!(operand.kind === SyntaxKind.BinaryExpression && node.expression.kind === SyntaxKind.AsExpression) &&
!(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) &&
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) &&
!(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) {
@@ -6841,7 +6842,7 @@ const _super = (function (geti, seti) {
// export { x, y }
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
const name = (specifier.propertyName || specifier.name).text;
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier);
}
}
break;
+9 -10
View File
@@ -1055,19 +1055,15 @@ namespace ts {
return resolutions;
}
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
}
/**
* Given a set of options and a set of root files, returns the set of type directive names
* Given a set of options, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
// Use explicit type list from tsconfig.json
if (options.types) {
return options.types;
@@ -1080,7 +1076,10 @@ namespace ts {
if (typeRoots) {
for (const root of typeRoots) {
if (host.directoryExists(root)) {
result = result.concat(host.getDirectories(root));
for (const typeDirectivePath of host.getDirectories(root)) {
// Return just the type directive names
result = result.concat(getBaseFileName(normalizePath(typeDirectivePath)));
}
}
}
}
@@ -1155,11 +1154,11 @@ namespace ts {
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host);
if (typeReferences) {
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
// This containingFilename needs to match with the one used in managed-side
const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts");
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
+11
View File
@@ -1606,6 +1606,16 @@ namespace ts {
antecedent: FlowNode;
}
export type FlowType = Type | IncompleteType;
// Incomplete types occur during control flow analysis of loops. An IncompleteType
// is distinguished from a regular type by a flags value of zero. Incomplete type
// objects are internal to the getFlowTypeOfRefecence function and never escape it.
export interface IncompleteType {
flags: TypeFlags; // No flags set
type: Type; // The type marked incomplete
}
export interface AmdDependency {
path: string;
name: string;
@@ -2900,6 +2910,7 @@ namespace ts {
directoryExists?(directoryName: string): boolean;
realpath?(path: string): string;
getCurrentDirectory?(): string;
getDirectories?(path: string): string[];
}
export interface ResolvedModule {
+1
View File
@@ -1569,6 +1569,7 @@ namespace ts {
case SyntaxKind.MethodSignature:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.NamespaceImport:
case SyntaxKind.NamespaceExportDeclaration:
case SyntaxKind.Parameter:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.PropertyDeclaration:
+1 -1
View File
@@ -226,7 +226,7 @@ interface NumberConstructor {
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
*/
readonly MAX_SAFE_INTEGER: number;
+5
View File
@@ -1108,6 +1108,11 @@ interface Array<T> {
* Removes the last element from an array and returns it.
*/
pop(): T | undefined;
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
+3
View File
@@ -115,6 +115,9 @@ namespace ts.server {
readFile: fileName => this.host.readFile(fileName),
directoryExists: directoryName => this.host.directoryExists(directoryName)
};
if (this.host.realpath) {
this.moduleResolutionHost.realpath = path => this.host.realpath(path);
}
}
private resolveNamesWithLocalCache<T extends Timestamped & { failedLookupLocations: string[] }, R>(
+2
View File
@@ -10,6 +10,8 @@
"types": []
},
"files": [
"../services/shims.ts",
"../services/utilities.ts",
"editorServices.ts",
"protocol.d.ts",
"session.ts"
+6 -6
View File
@@ -453,9 +453,9 @@ namespace ts.formatting {
case SyntaxKind.MethodDeclaration:
if ((<MethodDeclaration>node).asteriskToken) {
return SyntaxKind.AsteriskToken;
}
// fall-through
}/*
fall-through
*/
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
return (<Declaration>node).name.kind;
@@ -732,7 +732,7 @@ namespace ts.formatting {
else {
// indent token only if end line of previous range does not match start line of the token
const prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
}
}
@@ -892,7 +892,7 @@ namespace ts.formatting {
}
function indentationIsDifferent(indentationString: string, startLinePosition: number): boolean {
return indentationString !== sourceFile.text.substr(startLinePosition , indentationString.length);
return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length);
}
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
@@ -936,7 +936,7 @@ namespace ts.formatting {
// shift all parts on the delta size
const delta = indentation - nonWhitespaceColumnInFirstPart.column;
for (let i = startIndex, len = parts.length; i < len; i++, startLine++) {
for (let i = startIndex, len = parts.length; i < len; i++ , startLine++) {
const startLinePos = getStartPositionOfLine(startLine, sourceFile);
const nonWhitespaceCharacterAndColumn =
i === 0
+37 -9
View File
@@ -231,6 +231,13 @@ namespace ts.formatting {
public NoSpaceBeforeCloseBraceInJsxExpression: Rule;
public SpaceBeforeCloseBraceInJsxExpression: Rule;
// JSX opening elements
public SpaceBeforeJsxAttribute: Rule;
public SpaceBeforeSlashInJsxOpeningElement: Rule;
public NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule;
public NoSpaceBeforeEqualInJsxAttribute: Rule;
public NoSpaceAfterEqualInJsxAttribute: Rule;
constructor() {
///
/// Common Rules
@@ -322,7 +329,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.isNonJsxElementContext, 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));
@@ -386,6 +393,13 @@ namespace ts.formatting {
// template string
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
// jsx opening element
this.SpaceBeforeJsxAttribute = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
this.SpaceBeforeSlashInJsxOpeningElement = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.SlashToken), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new Rule(RuleDescriptor.create1(SyntaxKind.SlashToken, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
this.NoSpaceBeforeEqualInJsxAttribute = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsToken), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterEqualInJsxAttribute = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules = [
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@@ -413,6 +427,8 @@ namespace ts.formatting {
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword,
this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement,
this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
@@ -450,8 +466,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.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));
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));
@@ -498,10 +514,10 @@ namespace ts.formatting {
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));
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));
@@ -741,14 +757,26 @@ namespace ts.formatting {
return context.TokensAreOnSameLine() && context.contextNode.kind !== SyntaxKind.JsxText;
}
static isNonJsxElementContext(context: FormattingContext): boolean {
static IsNonJsxElementContext(context: FormattingContext): boolean {
return context.contextNode.kind !== SyntaxKind.JsxElement;
}
static isJsxExpressionContext(context: FormattingContext): boolean {
static IsJsxExpressionContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.JsxExpression;
}
static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean {
return context.nextTokenParent.kind === SyntaxKind.JsxAttribute;
}
static IsJsxAttributeContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.JsxAttribute;
}
static IsJsxSelfClosingElementContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.JsxSelfClosingElement;
}
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context);
}
+2 -53
View File
@@ -506,7 +506,7 @@ namespace ts.NavigationBar {
function convertToTopLevelItem(n: NavigationBarNode): NavigationBarItem {
return {
text: getItemName(n.node),
kind: nodeKind(n.node),
kind: getNodeKind(n.node),
kindModifiers: getNodeModifiers(n.node),
spans: getSpans(n),
childItems: map(n.children, convertToChildItem) || emptyChildItemArray,
@@ -518,7 +518,7 @@ namespace ts.NavigationBar {
function convertToChildItem(n: NavigationBarNode): NavigationBarItem {
return {
text: getItemName(n.node),
kind: nodeKind(n.node),
kind: getNodeKind(n.node),
kindModifiers: getNodeModifiers(n.node),
spans: getSpans(n),
childItems: emptyChildItemArray,
@@ -539,57 +539,6 @@ namespace ts.NavigationBar {
}
}
// TODO: GH#9145: We should just use getNodeKind. No reason why navigationBar and navigateTo should have different behaviors.
function nodeKind(node: Node): string {
switch (node.kind) {
case SyntaxKind.SourceFile:
return ScriptElementKind.moduleElement;
case SyntaxKind.EnumMember:
return ScriptElementKind.memberVariableElement;
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
let variableDeclarationNode: Node;
let name: Node;
if (node.kind === SyntaxKind.BindingElement) {
name = (<BindingElement>node).name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
while (variableDeclarationNode && variableDeclarationNode.kind !== SyntaxKind.VariableDeclaration) {
variableDeclarationNode = variableDeclarationNode.parent;
}
Debug.assert(!!variableDeclarationNode);
}
else {
Debug.assert(!isBindingPattern((<VariableDeclaration>node).name));
variableDeclarationNode = node;
name = (<VariableDeclaration>node).name;
}
if (isConst(variableDeclarationNode)) {
return ts.ScriptElementKind.constElement;
}
else if (isLet(variableDeclarationNode)) {
return ts.ScriptElementKind.letElement;
}
else {
return ts.ScriptElementKind.variableElement;
}
case SyntaxKind.ArrowFunction:
return ts.ScriptElementKind.functionElement;
case SyntaxKind.JSDocTypedefTag:
return ScriptElementKind.typeElement;
default:
return getNodeKind(node);
}
}
function getModuleName(moduleDeclaration: ModuleDeclaration): string {
// We want to maintain quotation marks.
if (isAmbientModule(moduleDeclaration)) {
+38 -14
View File
@@ -1690,6 +1690,8 @@ namespace ts {
/** enum E */
export const enumElement = "enum";
// TODO: GH#9983
export const enumMemberElement = "const";
/**
* Inside module and script only
@@ -1884,7 +1886,7 @@ namespace ts {
};
}
// Cache host information about scrip Should be refreshed
// Cache host information about script should be refreshed
// at each language service public entry point, since we don't know when
// set of scripts handled by the host changes.
class HostCache {
@@ -2947,7 +2949,10 @@ namespace ts {
/* @internal */ export function getNodeKind(node: Node): string {
switch (node.kind) {
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
case SyntaxKind.SourceFile:
return isExternalModule(<SourceFile>node) ? ScriptElementKind.moduleElement : ScriptElementKind.scriptElement;
case SyntaxKind.ModuleDeclaration:
return ScriptElementKind.moduleElement;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
return ScriptElementKind.classElement;
@@ -2955,11 +2960,10 @@ namespace ts {
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
case SyntaxKind.VariableDeclaration:
return isConst(node)
? ScriptElementKind.constElement
: isLet(node)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
return getKindOfVariableDeclaration(<VariableDeclaration>node);
case SyntaxKind.BindingElement:
return getKindOfVariableDeclaration(<VariableDeclaration>getRootDeclaration(node));
case SyntaxKind.ArrowFunction:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
return ScriptElementKind.functionElement;
@@ -2976,7 +2980,7 @@ namespace ts {
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
case SyntaxKind.EnumMember: return ScriptElementKind.enumMemberElement;
case SyntaxKind.Parameter: return (node.flags & NodeFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportSpecifier:
@@ -2984,8 +2988,19 @@ namespace ts {
case SyntaxKind.ExportSpecifier:
case SyntaxKind.NamespaceImport:
return ScriptElementKind.alias;
case SyntaxKind.JSDocTypedefTag:
return ScriptElementKind.typeElement;
default:
return ScriptElementKind.unknown;
}
function getKindOfVariableDeclaration(v: VariableDeclaration): string {
return isConst(v)
? ScriptElementKind.constElement
: isLet(v)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
}
return ScriptElementKind.unknown;
}
class CancellationTokenObject implements CancellationToken {
@@ -3075,14 +3090,16 @@ namespace ts {
const oldSettings = program && program.getCompilerOptions();
const newSettings = hostCache.compilationSettings();
const changesInCompilationSettingsAffectSyntax = oldSettings &&
const shouldCreateNewSourceFiles = oldSettings &&
(oldSettings.target !== newSettings.target ||
oldSettings.module !== newSettings.module ||
oldSettings.moduleResolution !== newSettings.moduleResolution ||
oldSettings.noResolve !== newSettings.noResolve ||
oldSettings.jsx !== newSettings.jsx ||
oldSettings.allowJs !== newSettings.allowJs ||
oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit);
oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit ||
oldSettings.baseUrl !== newSettings.baseUrl ||
!mapIsEqualTo(oldSettings.paths, newSettings.paths));
// Now create a new compiler
const compilerHost: CompilerHost = {
@@ -3134,7 +3151,7 @@ namespace ts {
const oldSourceFiles = program.getSourceFiles();
const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings);
for (const oldSourceFile of oldSourceFiles) {
if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) {
if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) {
documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey);
}
}
@@ -3168,7 +3185,7 @@ namespace ts {
// Check if the language version has changed since we last created a program; if they are the same,
// it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
// can not be reused. we have to dump all syntax trees and create new ones.
if (!changesInCompilationSettingsAffectSyntax) {
if (!shouldCreateNewSourceFiles) {
// Check if the old program had this file already
const oldSourceFile = program && program.getSourceFileByPath(path);
if (oldSourceFile) {
@@ -4813,7 +4830,14 @@ namespace ts {
}
if (symbolFlags & SymbolFlags.Alias) {
addNewLineIfDisplayPartsExist();
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
if (symbol.declarations[0].kind === SyntaxKind.NamespaceExportDeclaration) {
displayParts.push(keywordPart(SyntaxKind.ExportKeyword));
displayParts.push(spacePart());
displayParts.push(keywordPart(SyntaxKind.NamespaceKeyword));
}
else {
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
}
displayParts.push(spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, declaration => {
+30 -5
View File
@@ -72,8 +72,13 @@ namespace ts {
directoryExists(directoryName: string): boolean;
}
/** Public interface of the the of a config service shim instance.*/
export interface CoreServicesShimHost extends Logger, ModuleResolutionHost {
/** Public interface of the core-services host instance used in managed side */
export interface CoreServicesShimHost extends Logger {
directoryExists(directoryName: string): boolean;
fileExists(fileName: string): boolean;
getCurrentDirectory(): string;
getDirectories(path: string): string;
/**
* Returns a JSON-encoded value of the type: string[]
*
@@ -81,9 +86,14 @@ namespace ts {
* when enumerating the directory.
*/
readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string;
useCaseSensitiveFileNames?(): boolean;
getCurrentDirectory(): string;
/**
* Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules
*/
readFile(fileName: string): string;
realpath?(path: string): string;
trace(s: string): void;
useCaseSensitiveFileNames?(): boolean;
}
///
@@ -240,6 +250,7 @@ namespace ts {
}
export interface CoreServicesShim extends Shim {
getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string;
getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
getDefaultCompilationSettings(): string;
@@ -492,6 +503,10 @@ namespace ts {
private readDirectoryFallback(rootDir: string, extension: string, exclude: string[]) {
return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)));
}
public getDirectories(path: string): string[] {
return JSON.parse(this.shimHost.getDirectories(path));
}
}
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any {
@@ -1003,7 +1018,7 @@ namespace ts {
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
return this.forwardJSONCall(
"getPreProcessedFileInfo('" + fileName + "')",
`getPreProcessedFileInfo('${fileName}')`,
() => {
// for now treat files as JavaScript
const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
@@ -1017,6 +1032,16 @@ namespace ts {
});
}
public getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string {
return this.forwardJSONCall(
`getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
() => {
const compilerOptions = <CompilerOptions>JSON.parse(compilerOptionsJson);
return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
}
);
}
private convertFileReferences(refs: FileReference[]): IFileReference[] {
if (!refs) {
return undefined;
@@ -0,0 +1,17 @@
tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
==== tests/cases/compiler/a.ts (2 errors) ====
import Foo = require("./b");
Foo.default.bar();
~~~~~~~
!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
Foo.default.default.foo();
~~~~~~~
!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
==== tests/cases/compiler/b.d.ts (0 errors) ====
export function foo();
export function bar();
@@ -0,0 +1,17 @@
//// [tests/cases/compiler/allowSyntheticDefaultImports10.ts] ////
//// [b.d.ts]
export function foo();
export function bar();
//// [a.ts]
import Foo = require("./b");
Foo.default.bar();
Foo.default.default.foo();
//// [a.js]
"use strict";
var Foo = require("./b");
Foo.default.bar();
Foo.default.default.foo();
@@ -0,0 +1,28 @@
//// [tests/cases/compiler/allowSyntheticDefaultImports7.ts] ////
//// [b.d.ts]
export function foo();
export function bar();
//// [a.ts]
import { default as Foo } from "./b";
Foo.bar();
Foo.foo();
//// [a.js]
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
return {
setters:[
function (b_1_1) {
b_1 = b_1_1;
}],
execute: function() {
b_1["default"].bar();
b_1["default"].foo();
}
}
});
@@ -0,0 +1,22 @@
=== tests/cases/compiler/b.d.ts ===
export function foo();
>foo : Symbol(foo, Decl(b.d.ts, 0, 0))
export function bar();
>bar : Symbol(bar, Decl(b.d.ts, 0, 22))
=== tests/cases/compiler/a.ts ===
import { default as Foo } from "./b";
>default : Symbol(Foo, Decl(a.ts, 0, 8))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
Foo.bar();
>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
Foo.foo();
>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
@@ -0,0 +1,24 @@
=== tests/cases/compiler/b.d.ts ===
export function foo();
>foo : () => any
export function bar();
>bar : () => any
=== tests/cases/compiler/a.ts ===
import { default as Foo } from "./b";
>default : typeof Foo
>Foo : typeof Foo
Foo.bar();
>Foo.bar() : any
>Foo.bar : () => any
>Foo : typeof Foo
>bar : () => any
Foo.foo();
>Foo.foo() : any
>Foo.foo : () => any
>Foo : typeof Foo
>foo : () => any
@@ -0,0 +1,14 @@
tests/cases/compiler/a.ts(1,10): error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'.
==== tests/cases/compiler/b.d.ts (0 errors) ====
export function foo();
export function bar();
==== tests/cases/compiler/a.ts (1 errors) ====
import { default as Foo } from "./b";
~~~~~~~
!!! error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'.
Foo.bar();
Foo.foo();
@@ -0,0 +1,28 @@
//// [tests/cases/compiler/allowSyntheticDefaultImports8.ts] ////
//// [b.d.ts]
export function foo();
export function bar();
//// [a.ts]
import { default as Foo } from "./b";
Foo.bar();
Foo.foo();
//// [a.js]
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
return {
setters:[
function (b_1_1) {
b_1 = b_1_1;
}],
execute: function() {
b_1["default"].bar();
b_1["default"].foo();
}
}
});
@@ -0,0 +1,17 @@
//// [tests/cases/compiler/allowSyntheticDefaultImports9.ts] ////
//// [b.d.ts]
export function foo();
export function bar();
//// [a.ts]
import { default as Foo } from "./b";
Foo.bar();
Foo.foo();
//// [a.js]
"use strict";
var b_1 = require("./b");
b_1["default"].bar();
b_1["default"].foo();
@@ -0,0 +1,22 @@
=== tests/cases/compiler/b.d.ts ===
export function foo();
>foo : Symbol(foo, Decl(b.d.ts, 0, 0))
export function bar();
>bar : Symbol(bar, Decl(b.d.ts, 0, 22))
=== tests/cases/compiler/a.ts ===
import { default as Foo } from "./b";
>default : Symbol(Foo, Decl(a.ts, 0, 8))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
Foo.bar();
>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
Foo.foo();
>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
@@ -0,0 +1,24 @@
=== tests/cases/compiler/b.d.ts ===
export function foo();
>foo : () => any
export function bar();
>bar : () => any
=== tests/cases/compiler/a.ts ===
import { default as Foo } from "./b";
>default : typeof Foo
>Foo : typeof Foo
Foo.bar();
>Foo.bar() : any
>Foo.bar : () => any
>Foo : typeof Foo
>bar : () => any
Foo.foo();
>Foo.foo() : any
>Foo.foo : () => any
>Foo : typeof Foo
>foo : () => any
@@ -0,0 +1,13 @@
=== tests/cases/compiler/a.d.ts ===
declare namespace ns {
>ns : Symbol(ns, Decl(a.d.ts, 0, 0))
class SecondNS extends FirstNS { }
>SecondNS : Symbol(SecondNS, Decl(a.d.ts, 1, 22))
>FirstNS : Symbol(FirstNS, Decl(a.d.ts, 2, 36))
class FirstNS { }
>FirstNS : Symbol(FirstNS, Decl(a.d.ts, 2, 36))
}
@@ -0,0 +1,13 @@
=== tests/cases/compiler/a.d.ts ===
declare namespace ns {
>ns : typeof ns
class SecondNS extends FirstNS { }
>SecondNS : SecondNS
>FirstNS : FirstNS
class FirstNS { }
>FirstNS : FirstNS
}
@@ -3,21 +3,21 @@ var a: string[] = [];
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
a.concat("hello", 'world');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
a.concat('Hello');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var b = new Array<string>();
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
b.concat('hello');
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
+6 -6
View File
@@ -5,17 +5,17 @@ var a: string[] = [];
a.concat("hello", 'world');
>a.concat("hello", 'world') : string[]
>a.concat : (...items: (string | string[])[]) => string[]
>a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>a : string[]
>concat : (...items: (string | string[])[]) => string[]
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>"hello" : string
>'world' : string
a.concat('Hello');
>a.concat('Hello') : string[]
>a.concat : (...items: (string | string[])[]) => string[]
>a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>a : string[]
>concat : (...items: (string | string[])[]) => string[]
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>'Hello' : string
var b = new Array<string>();
@@ -25,8 +25,8 @@ var b = new Array<string>();
b.concat('hello');
>b.concat('hello') : string[]
>b.concat : (...items: (string | string[])[]) => string[]
>b.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>b : string[]
>concat : (...items: (string | string[])[]) => string[]
>concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; }
>'hello' : string
@@ -2,8 +2,8 @@
var x = [].concat([{ a: 1 }], [{ a: 2 }])
>x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3))
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32))
@@ -4,9 +4,9 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }])
>[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[]
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
>[].concat([{ a: 1 }], [{ a: 2 }]) : any[]
>[].concat : (...items: any[]) => any[]
>[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
>[] : undefined[]
>concat : (...items: any[]) => any[]
>concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
>[{ a: 1 }] : { a: number; }[]
>{ a: 1 } : { a: number; }
>a : number
@@ -0,0 +1,19 @@
//// [asOpEmitParens.ts]
declare var x;
// Must emit as (x + 1) * 3
(x + 1 as number) * 3;
// Should still emit as x.y
(x as any).y;
// Emit as new (x())
new (x() as any);
//// [asOpEmitParens.js]
// Must emit as (x + 1) * 3
(x + 1) * 3;
// Should still emit as x.y
x.y;
// Emit as new (x())
new (x());
@@ -0,0 +1,16 @@
=== tests/cases/conformance/expressions/asOperator/asOpEmitParens.ts ===
declare var x;
>x : Symbol(x, Decl(asOpEmitParens.ts, 0, 11))
// Must emit as (x + 1) * 3
(x + 1 as number) * 3;
>x : Symbol(x, Decl(asOpEmitParens.ts, 0, 11))
// Should still emit as x.y
(x as any).y;
>x : Symbol(x, Decl(asOpEmitParens.ts, 0, 11))
// Emit as new (x())
new (x() as any);
>x : Symbol(x, Decl(asOpEmitParens.ts, 0, 11))
@@ -0,0 +1,30 @@
=== tests/cases/conformance/expressions/asOperator/asOpEmitParens.ts ===
declare var x;
>x : any
// Must emit as (x + 1) * 3
(x + 1 as number) * 3;
>(x + 1 as number) * 3 : number
>(x + 1 as number) : number
>x + 1 as number : number
>x + 1 : any
>x : any
>1 : number
>3 : number
// Should still emit as x.y
(x as any).y;
>(x as any).y : any
>(x as any) : any
>x as any : any
>x : any
>y : any
// Emit as new (x())
new (x() as any);
>new (x() as any) : any
>(x() as any) : any
>x() as any : any
>x() : any
>x : any
@@ -1,4 +1,20 @@
//// [baseTypeWrappingInstantiationChain.ts]
class CBaseBase<T3> {
constructor(x: Parameter<T3>) { }
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
}
class Parameter<T4> {
method(t: T4) { }
}
class Wrapper<T5> {
property: T5;
}
class C<T1> extends CBase<T1> {
public works() {
new CBaseBase<Wrapper<T1>>(this);
@@ -9,22 +25,7 @@ class C<T1> extends CBase<T1> {
public method(t: Wrapper<T1>) { }
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
}
class CBaseBase<T3> {
constructor(x: Parameter<T3>) { }
}
class Parameter<T4> {
method(t: T4) { }
}
class Wrapper<T5> {
property: T5;
}
//// [baseTypeWrappingInstantiationChain.js]
var __extends = (this && this.__extends) || function (d, b) {
@@ -32,6 +33,29 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var CBaseBase = (function () {
function CBaseBase(x) {
}
return CBaseBase;
}());
var CBase = (function (_super) {
__extends(CBase, _super);
function CBase() {
_super.apply(this, arguments);
}
return CBase;
}(CBaseBase));
var Parameter = (function () {
function Parameter() {
}
Parameter.prototype.method = function (t) { };
return Parameter;
}());
var Wrapper = (function () {
function Wrapper() {
}
return Wrapper;
}());
var C = (function (_super) {
__extends(C, _super);
function C() {
@@ -46,26 +70,3 @@ var C = (function (_super) {
C.prototype.method = function (t) { };
return C;
}(CBase));
var CBase = (function (_super) {
__extends(CBase, _super);
function CBase() {
_super.apply(this, arguments);
}
return CBase;
}(CBaseBase));
var CBaseBase = (function () {
function CBaseBase(x) {
}
return CBaseBase;
}());
var Parameter = (function () {
function Parameter() {
}
Parameter.prototype.method = function (t) { };
return Parameter;
}());
var Wrapper = (function () {
function Wrapper() {
}
return Wrapper;
}());
@@ -1,69 +1,70 @@
=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts ===
class C<T1> extends CBase<T1> {
>C : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
class CBaseBase<T3> {
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 0, 16))
public works() {
>works : Symbol(C.works, Decl(baseTypeWrappingInstantiationChain.ts, 0, 31))
new CBaseBase<Wrapper<T1>>(this);
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
}
public alsoWorks() {
>alsoWorks : Symbol(C.alsoWorks, Decl(baseTypeWrappingInstantiationChain.ts, 3, 5))
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
}
public method(t: Wrapper<T1>) { }
>method : Symbol(C.method, Decl(baseTypeWrappingInstantiationChain.ts, 6, 5))
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 8, 18))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
constructor(x: Parameter<T3>) { }
>x : Symbol(x, Decl(baseTypeWrappingInstantiationChain.ts, 1, 16))
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 6, 1))
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 0, 16))
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12))
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12))
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 2, 1))
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 4, 12))
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 10, 1))
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 4, 12))
}
class CBaseBase<T3> {
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16))
constructor(x: Parameter<T3>) { }
>x : Symbol(x, Decl(baseTypeWrappingInstantiationChain.ts, 16, 16))
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1))
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16))
}
class Parameter<T4> {
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1))
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16))
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 6, 1))
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 8, 16))
method(t: T4) { }
>method : Symbol(Parameter.method, Decl(baseTypeWrappingInstantiationChain.ts, 19, 21))
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 20, 11))
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16))
>method : Symbol(Parameter.method, Decl(baseTypeWrappingInstantiationChain.ts, 8, 21))
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 9, 11))
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 8, 16))
}
class Wrapper<T5> {
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 10, 1))
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 12, 14))
property: T5;
>property : Symbol(Wrapper.property, Decl(baseTypeWrappingInstantiationChain.ts, 23, 19))
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14))
>property : Symbol(Wrapper.property, Decl(baseTypeWrappingInstantiationChain.ts, 12, 19))
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 12, 14))
}
class C<T1> extends CBase<T1> {
>C : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 14, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 16, 8))
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 2, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 16, 8))
public works() {
>works : Symbol(C.works, Decl(baseTypeWrappingInstantiationChain.ts, 16, 31))
new CBaseBase<Wrapper<T1>>(this);
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 10, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 16, 8))
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 14, 1))
}
public alsoWorks() {
>alsoWorks : Symbol(C.alsoWorks, Decl(baseTypeWrappingInstantiationChain.ts, 19, 5))
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 2, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 16, 8))
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 14, 1))
}
public method(t: Wrapper<T1>) { }
>method : Symbol(C.method, Decl(baseTypeWrappingInstantiationChain.ts, 22, 5))
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 24, 18))
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 10, 1))
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 16, 8))
}
@@ -1,4 +1,42 @@
=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts ===
class CBaseBase<T3> {
>CBaseBase : CBaseBase<T3>
>T3 : T3
constructor(x: Parameter<T3>) { }
>x : Parameter<T3>
>Parameter : Parameter<T4>
>T3 : T3
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
>CBase : CBase<T2>
>T2 : T2
>CBaseBase : CBaseBase<Wrapper<T2>>
>Wrapper : Wrapper<T5>
>T2 : T2
}
class Parameter<T4> {
>Parameter : Parameter<T4>
>T4 : T4
method(t: T4) { }
>method : (t: T4) => void
>t : T4
>T4 : T4
}
class Wrapper<T5> {
>Wrapper : Wrapper<T5>
>T5 : T5
property: T5;
>property : T5
>T5 : T5
}
class C<T1> extends CBase<T1> {
>C : C<T1>
>T1 : T1
@@ -32,40 +70,3 @@ class C<T1> extends CBase<T1> {
>T1 : T1
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
>CBase : CBase<T2>
>T2 : T2
>CBaseBase : CBaseBase<Wrapper<T2>>
>Wrapper : Wrapper<T5>
>T2 : T2
}
class CBaseBase<T3> {
>CBaseBase : CBaseBase<T3>
>T3 : T3
constructor(x: Parameter<T3>) { }
>x : Parameter<T3>
>Parameter : Parameter<T4>
>T3 : T3
}
class Parameter<T4> {
>Parameter : Parameter<T4>
>T4 : T4
method(t: T4) { }
>method : (t: T4) => void
>t : T4
>T4 : T4
}
class Wrapper<T5> {
>Wrapper : Wrapper<T5>
>T5 : T5
property: T5;
>property : T5
>T5 : T5
}
@@ -0,0 +1,35 @@
//// [bestChoiceType.ts]
// Repro from #10041
(''.match(/ /) || []).map(s => s.toLowerCase());
// Similar cases
function f1() {
let x = ''.match(/ /);
let y = x || [];
let z = y.map(s => s.toLowerCase());
}
function f2() {
let x = ''.match(/ /);
let y = x ? x : [];
let z = y.map(s => s.toLowerCase());
}
//// [bestChoiceType.js]
// Repro from #10041
(''.match(/ /) || []).map(function (s) { return s.toLowerCase(); });
// Similar cases
function f1() {
var x = ''.match(/ /);
var y = x || [];
var z = y.map(function (s) { return s.toLowerCase(); });
}
function f2() {
var x = ''.match(/ /);
var y = x ? x : [];
var z = y.map(function (s) { return s.toLowerCase(); });
}
@@ -0,0 +1,63 @@
=== tests/cases/compiler/bestChoiceType.ts ===
// Repro from #10041
(''.match(/ /) || []).map(s => s.toLowerCase());
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 3, 26))
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 3, 26))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
// Similar cases
function f1() {
>f1 : Symbol(f1, Decl(bestChoiceType.ts, 3, 48))
let x = ''.match(/ /);
>x : Symbol(x, Decl(bestChoiceType.ts, 8, 7))
>''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
let y = x || [];
>y : Symbol(y, Decl(bestChoiceType.ts, 9, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 8, 7))
let z = y.map(s => s.toLowerCase());
>z : Symbol(z, Decl(bestChoiceType.ts, 10, 7))
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>y : Symbol(y, Decl(bestChoiceType.ts, 9, 7))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 10, 18))
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 10, 18))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
}
function f2() {
>f2 : Symbol(f2, Decl(bestChoiceType.ts, 11, 1))
let x = ''.match(/ /);
>x : Symbol(x, Decl(bestChoiceType.ts, 14, 7))
>''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
let y = x ? x : [];
>y : Symbol(y, Decl(bestChoiceType.ts, 15, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 14, 7))
>x : Symbol(x, Decl(bestChoiceType.ts, 14, 7))
let z = y.map(s => s.toLowerCase());
>z : Symbol(z, Decl(bestChoiceType.ts, 16, 7))
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>y : Symbol(y, Decl(bestChoiceType.ts, 15, 7))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 16, 18))
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(bestChoiceType.ts, 16, 18))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
}
@@ -0,0 +1,88 @@
=== tests/cases/compiler/bestChoiceType.ts ===
// Repro from #10041
(''.match(/ /) || []).map(s => s.toLowerCase());
>(''.match(/ /) || []).map(s => s.toLowerCase()) : string[]
>(''.match(/ /) || []).map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>(''.match(/ /) || []) : RegExpMatchArray
>''.match(/ /) || [] : RegExpMatchArray
>''.match(/ /) : RegExpMatchArray | null
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>'' : string
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>/ / : RegExp
>[] : never[]
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>s => s.toLowerCase() : (s: string) => string
>s : string
>s.toLowerCase() : string
>s.toLowerCase : () => string
>s : string
>toLowerCase : () => string
// Similar cases
function f1() {
>f1 : () => void
let x = ''.match(/ /);
>x : RegExpMatchArray | null
>''.match(/ /) : RegExpMatchArray | null
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>'' : string
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>/ / : RegExp
let y = x || [];
>y : RegExpMatchArray
>x || [] : RegExpMatchArray
>x : RegExpMatchArray | null
>[] : never[]
let z = y.map(s => s.toLowerCase());
>z : string[]
>y.map(s => s.toLowerCase()) : string[]
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>y : RegExpMatchArray
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>s => s.toLowerCase() : (s: string) => string
>s : string
>s.toLowerCase() : string
>s.toLowerCase : () => string
>s : string
>toLowerCase : () => string
}
function f2() {
>f2 : () => void
let x = ''.match(/ /);
>x : RegExpMatchArray | null
>''.match(/ /) : RegExpMatchArray | null
>''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>'' : string
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
>/ / : RegExp
let y = x ? x : [];
>y : RegExpMatchArray
>x ? x : [] : RegExpMatchArray
>x : RegExpMatchArray | null
>x : RegExpMatchArray
>[] : never[]
let z = y.map(s => s.toLowerCase());
>z : string[]
>y.map(s => s.toLowerCase()) : string[]
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>y : RegExpMatchArray
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>s => s.toLowerCase() : (s: string) => string
>s : string
>s.toLowerCase() : string
>s.toLowerCase : () => string
>s : string
>toLowerCase : () => string
}
@@ -0,0 +1,25 @@
tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts(5,28): error TS2690: A class must be declared after its base class.
==== tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts (1 errors) ====
// expected no error
module B {
export import a = A;
export class D extends a.C {
~~~
!!! error TS2690: A class must be declared after its base class.
id: number;
}
}
module A {
export class C { name: string }
export import b = B;
}
var c: { name: string };
var c = new B.a.C();
@@ -1,47 +0,0 @@
=== tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts ===
// expected no error
module B {
>B : Symbol(a.b, Decl(circularImportAlias.ts, 0, 0))
export import a = A;
>a : Symbol(a, Decl(circularImportAlias.ts, 2, 10))
>A : Symbol(a, Decl(circularImportAlias.ts, 7, 1))
export class D extends a.C {
>D : Symbol(D, Decl(circularImportAlias.ts, 3, 24))
>a.C : Symbol(a.C, Decl(circularImportAlias.ts, 9, 10))
>a : Symbol(a, Decl(circularImportAlias.ts, 2, 10))
>C : Symbol(a.C, Decl(circularImportAlias.ts, 9, 10))
id: number;
>id : Symbol(D.id, Decl(circularImportAlias.ts, 4, 32))
}
}
module A {
>A : Symbol(b.a, Decl(circularImportAlias.ts, 7, 1))
export class C { name: string }
>C : Symbol(C, Decl(circularImportAlias.ts, 9, 10))
>name : Symbol(C.name, Decl(circularImportAlias.ts, 10, 20))
export import b = B;
>b : Symbol(b, Decl(circularImportAlias.ts, 10, 35))
>B : Symbol(b, Decl(circularImportAlias.ts, 0, 0))
}
var c: { name: string };
>c : Symbol(c, Decl(circularImportAlias.ts, 14, 3), Decl(circularImportAlias.ts, 15, 3))
>name : Symbol(name, Decl(circularImportAlias.ts, 14, 8))
var c = new B.a.C();
>c : Symbol(c, Decl(circularImportAlias.ts, 14, 3), Decl(circularImportAlias.ts, 15, 3))
>B.a.C : Symbol(A.C, Decl(circularImportAlias.ts, 9, 10))
>B.a : Symbol(B.a, Decl(circularImportAlias.ts, 2, 10))
>B : Symbol(B, Decl(circularImportAlias.ts, 0, 0))
>a : Symbol(B.a, Decl(circularImportAlias.ts, 2, 10))
>C : Symbol(A.C, Decl(circularImportAlias.ts, 9, 10))
@@ -1,48 +0,0 @@
=== tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts ===
// expected no error
module B {
>B : typeof a.b
export import a = A;
>a : typeof a
>A : typeof a
export class D extends a.C {
>D : D
>a.C : a.C
>a : typeof a
>C : typeof a.C
id: number;
>id : number
}
}
module A {
>A : typeof b.a
export class C { name: string }
>C : C
>name : string
export import b = B;
>b : typeof b
>B : typeof b
}
var c: { name: string };
>c : { name: string; }
>name : string
var c = new B.a.C();
>c : { name: string; }
>new B.a.C() : A.C
>B.a.C : typeof A.C
>B.a : typeof A
>B : typeof B
>a : typeof A
>C : typeof A.C
@@ -0,0 +1,15 @@
tests/cases/conformance/classes/classExpressions/classExpression3.ts(1,23): error TS2690: A class must be declared after its base class.
tests/cases/conformance/classes/classExpressions/classExpression3.ts(1,37): error TS2690: A class must be declared after its base class.
==== tests/cases/conformance/classes/classExpressions/classExpression3.ts (2 errors) ====
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
let c = new C();
c.a;
c.b;
c.c;
@@ -1,26 +0,0 @@
=== tests/cases/conformance/classes/classExpressions/classExpression3.ts ===
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
>C : Symbol(C, Decl(classExpression3.ts, 0, 3))
>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43))
>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53))
>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
let c = new C();
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
>C : Symbol(C, Decl(classExpression3.ts, 0, 3))
c.a;
>c.a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43))
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43))
c.b;
>c.b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53))
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53))
c.c;
>c.c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
@@ -1,33 +0,0 @@
=== tests/cases/conformance/classes/classExpressions/classExpression3.ts ===
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
>C : typeof (Anonymous class)
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class)
>class extends class { a = 1 } { b = 2 } : (Anonymous class)
>class { a = 1 } : (Anonymous class)
>a : number
>1 : number
>b : number
>2 : number
>c : number
>3 : number
let c = new C();
>c : (Anonymous class)
>new C() : (Anonymous class)
>C : typeof (Anonymous class)
c.a;
>c.a : number
>c : (Anonymous class)
>a : number
c.b;
>c.b : number
>c : (Anonymous class)
>b : number
c.c;
>c.c : number
>c : (Anonymous class)
>c : number
@@ -0,0 +1,15 @@
tests/cases/conformance/es6/classExpressions/classExpressionES63.ts(1,23): error TS2690: A class must be declared after its base class.
tests/cases/conformance/es6/classExpressions/classExpressionES63.ts(1,37): error TS2690: A class must be declared after its base class.
==== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts (2 errors) ====
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
let c = new C();
c.a;
c.b;
c.c;
@@ -1,26 +0,0 @@
=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts ===
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3))
>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43))
>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53))
>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
let c = new C();
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3))
c.a;
>c.a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43))
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43))
c.b;
>c.b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53))
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53))
c.c;
>c.c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
@@ -1,33 +0,0 @@
=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts ===
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
>C : typeof (Anonymous class)
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class)
>class extends class { a = 1 } { b = 2 } : (Anonymous class)
>class { a = 1 } : (Anonymous class)
>a : number
>1 : number
>b : number
>2 : number
>c : number
>3 : number
let c = new C();
>c : (Anonymous class)
>new C() : (Anonymous class)
>C : typeof (Anonymous class)
c.a;
>c.a : number
>c : (Anonymous class)
>a : number
c.b;
>c.b : number
>c : (Anonymous class)
>b : number
c.c;
>c.c : number
>c : (Anonymous class)
>c : number
@@ -1,8 +1,11 @@
tests/cases/compiler/classInheritence.ts(1,17): error TS2690: A class must be declared after its base class.
tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression.
==== tests/cases/compiler/classInheritence.ts (1 errors) ====
==== tests/cases/compiler/classInheritence.ts (2 errors) ====
class B extends A { }
~
!!! error TS2690: A class must be declared after its base class.
class A extends A { }
~
!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression.
@@ -0,0 +1,25 @@
tests/cases/compiler/classOrder2.ts(2,17): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/classOrder2.ts (1 errors) ====
class A extends B {
~
!!! error TS2690: A class must be declared after its base class.
foo() { this.bar(); }
}
class B {
bar() { }
}
var a = new A();
a.foo();
@@ -1,33 +0,0 @@
=== tests/cases/compiler/classOrder2.ts ===
class A extends B {
>A : Symbol(A, Decl(classOrder2.ts, 0, 0))
>B : Symbol(B, Decl(classOrder2.ts, 5, 1))
foo() { this.bar(); }
>foo : Symbol(A.foo, Decl(classOrder2.ts, 1, 19))
>this.bar : Symbol(B.bar, Decl(classOrder2.ts, 7, 9))
>this : Symbol(A, Decl(classOrder2.ts, 0, 0))
>bar : Symbol(B.bar, Decl(classOrder2.ts, 7, 9))
}
class B {
>B : Symbol(B, Decl(classOrder2.ts, 5, 1))
bar() { }
>bar : Symbol(B.bar, Decl(classOrder2.ts, 7, 9))
}
var a = new A();
>a : Symbol(a, Decl(classOrder2.ts, 14, 3))
>A : Symbol(A, Decl(classOrder2.ts, 0, 0))
a.foo();
>a.foo : Symbol(A.foo, Decl(classOrder2.ts, 1, 19))
>a : Symbol(a, Decl(classOrder2.ts, 14, 3))
>foo : Symbol(A.foo, Decl(classOrder2.ts, 1, 19))
@@ -1,36 +0,0 @@
=== tests/cases/compiler/classOrder2.ts ===
class A extends B {
>A : A
>B : B
foo() { this.bar(); }
>foo : () => void
>this.bar() : void
>this.bar : () => void
>this : this
>bar : () => void
}
class B {
>B : B
bar() { }
>bar : () => void
}
var a = new A();
>a : A
>new A() : A
>A : typeof A
a.foo();
>a.foo() : void
>a.foo : () => void
>a : A
>foo : () => void
@@ -0,0 +1,26 @@
tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/classSideInheritance2.ts (1 errors) ====
interface IText {
foo: number;
}
interface TextSpan {}
class SubText extends TextBase {
~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
constructor(text: IText, span: TextSpan) {
super();
}
}
class TextBase implements IText {
public foo: number;
public subText(span: TextSpan): IText {
return new SubText(this, span);
}
}
@@ -1,45 +0,0 @@
=== tests/cases/compiler/classSideInheritance2.ts ===
interface IText {
>IText : Symbol(IText, Decl(classSideInheritance2.ts, 0, 0))
foo: number;
>foo : Symbol(IText.foo, Decl(classSideInheritance2.ts, 0, 17))
}
interface TextSpan {}
>TextSpan : Symbol(TextSpan, Decl(classSideInheritance2.ts, 2, 1))
class SubText extends TextBase {
>SubText : Symbol(SubText, Decl(classSideInheritance2.ts, 4, 21))
>TextBase : Symbol(TextBase, Decl(classSideInheritance2.ts, 11, 1))
constructor(text: IText, span: TextSpan) {
>text : Symbol(text, Decl(classSideInheritance2.ts, 8, 20))
>IText : Symbol(IText, Decl(classSideInheritance2.ts, 0, 0))
>span : Symbol(span, Decl(classSideInheritance2.ts, 8, 32))
>TextSpan : Symbol(TextSpan, Decl(classSideInheritance2.ts, 2, 1))
super();
>super : Symbol(TextBase, Decl(classSideInheritance2.ts, 11, 1))
}
}
class TextBase implements IText {
>TextBase : Symbol(TextBase, Decl(classSideInheritance2.ts, 11, 1))
>IText : Symbol(IText, Decl(classSideInheritance2.ts, 0, 0))
public foo: number;
>foo : Symbol(TextBase.foo, Decl(classSideInheritance2.ts, 13, 33))
public subText(span: TextSpan): IText {
>subText : Symbol(TextBase.subText, Decl(classSideInheritance2.ts, 14, 27))
>span : Symbol(span, Decl(classSideInheritance2.ts, 15, 23))
>TextSpan : Symbol(TextSpan, Decl(classSideInheritance2.ts, 2, 1))
>IText : Symbol(IText, Decl(classSideInheritance2.ts, 0, 0))
return new SubText(this, span);
>SubText : Symbol(SubText, Decl(classSideInheritance2.ts, 4, 21))
>this : Symbol(TextBase, Decl(classSideInheritance2.ts, 11, 1))
>span : Symbol(span, Decl(classSideInheritance2.ts, 15, 23))
}
}
@@ -1,47 +0,0 @@
=== tests/cases/compiler/classSideInheritance2.ts ===
interface IText {
>IText : IText
foo: number;
>foo : number
}
interface TextSpan {}
>TextSpan : TextSpan
class SubText extends TextBase {
>SubText : SubText
>TextBase : TextBase
constructor(text: IText, span: TextSpan) {
>text : IText
>IText : IText
>span : TextSpan
>TextSpan : TextSpan
super();
>super() : void
>super : typeof TextBase
}
}
class TextBase implements IText {
>TextBase : TextBase
>IText : IText
public foo: number;
>foo : number
public subText(span: TextSpan): IText {
>subText : (span: TextSpan) => IText
>span : TextSpan
>TextSpan : TextSpan
>IText : IText
return new SubText(this, span);
>new SubText(this, span) : SubText
>SubText : typeof SubText
>this : this
>span : TextSpan
}
}
@@ -0,0 +1,53 @@
tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/complexClassRelationships.ts (1 errors) ====
// There should be no errors in this file
class Derived extends Base {
~~~~
!!! error TS2690: A class must be declared after its base class.
public static createEmpty(): Derived {
var item = new Derived();
return item;
}
}
class BaseCollection<T extends Base> {
constructor(f: () => T) {
(item: Thing) => { return [item.Components]; };
}
}
class Base {
ownerCollection: BaseCollection<Base>;
}
class Thing {
public get Components(): ComponentCollection<any> { return null }
}
class ComponentCollection<T> {
private static sortComponents(p: Foo) {
return p.prop1;
}
}
class Foo {
public get prop1() {
return new GenericType<string>(this);
}
public populate() {
this.prop2;
}
public get prop2(): BaseCollection<Derived> {
return new BaseCollection<Derived>(Derived.createEmpty);
}
}
class GenericType<T> {
constructor(parent: FooBase) { }
}
class FooBase {
public populate() {
}
}
@@ -1,117 +0,0 @@
=== tests/cases/compiler/complexClassRelationships.ts ===
// There should be no errors in this file
class Derived extends Base {
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
>Base : Symbol(Base, Decl(complexClassRelationships.ts, 11, 1))
public static createEmpty(): Derived {
>createEmpty : Symbol(Derived.createEmpty, Decl(complexClassRelationships.ts, 1, 28))
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
var item = new Derived();
>item : Symbol(item, Decl(complexClassRelationships.ts, 3, 11))
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
return item;
>item : Symbol(item, Decl(complexClassRelationships.ts, 3, 11))
}
}
class BaseCollection<T extends Base> {
>BaseCollection : Symbol(BaseCollection, Decl(complexClassRelationships.ts, 6, 1))
>T : Symbol(T, Decl(complexClassRelationships.ts, 7, 21))
>Base : Symbol(Base, Decl(complexClassRelationships.ts, 11, 1))
constructor(f: () => T) {
>f : Symbol(f, Decl(complexClassRelationships.ts, 8, 16))
>T : Symbol(T, Decl(complexClassRelationships.ts, 7, 21))
(item: Thing) => { return [item.Components]; };
>item : Symbol(item, Decl(complexClassRelationships.ts, 9, 9))
>Thing : Symbol(Thing, Decl(complexClassRelationships.ts, 14, 1))
>item.Components : Symbol(Thing.Components, Decl(complexClassRelationships.ts, 16, 13))
>item : Symbol(item, Decl(complexClassRelationships.ts, 9, 9))
>Components : Symbol(Thing.Components, Decl(complexClassRelationships.ts, 16, 13))
}
}
class Base {
>Base : Symbol(Base, Decl(complexClassRelationships.ts, 11, 1))
ownerCollection: BaseCollection<Base>;
>ownerCollection : Symbol(Base.ownerCollection, Decl(complexClassRelationships.ts, 12, 12))
>BaseCollection : Symbol(BaseCollection, Decl(complexClassRelationships.ts, 6, 1))
>Base : Symbol(Base, Decl(complexClassRelationships.ts, 11, 1))
}
class Thing {
>Thing : Symbol(Thing, Decl(complexClassRelationships.ts, 14, 1))
public get Components(): ComponentCollection<any> { return null }
>Components : Symbol(Thing.Components, Decl(complexClassRelationships.ts, 16, 13))
>ComponentCollection : Symbol(ComponentCollection, Decl(complexClassRelationships.ts, 18, 1))
}
class ComponentCollection<T> {
>ComponentCollection : Symbol(ComponentCollection, Decl(complexClassRelationships.ts, 18, 1))
>T : Symbol(T, Decl(complexClassRelationships.ts, 20, 26))
private static sortComponents(p: Foo) {
>sortComponents : Symbol(ComponentCollection.sortComponents, Decl(complexClassRelationships.ts, 20, 30))
>p : Symbol(p, Decl(complexClassRelationships.ts, 21, 34))
>Foo : Symbol(Foo, Decl(complexClassRelationships.ts, 24, 1))
return p.prop1;
>p.prop1 : Symbol(Foo.prop1, Decl(complexClassRelationships.ts, 26, 11))
>p : Symbol(p, Decl(complexClassRelationships.ts, 21, 34))
>prop1 : Symbol(Foo.prop1, Decl(complexClassRelationships.ts, 26, 11))
}
}
class Foo {
>Foo : Symbol(Foo, Decl(complexClassRelationships.ts, 24, 1))
public get prop1() {
>prop1 : Symbol(Foo.prop1, Decl(complexClassRelationships.ts, 26, 11))
return new GenericType<string>(this);
>GenericType : Symbol(GenericType, Decl(complexClassRelationships.ts, 36, 1))
>this : Symbol(Foo, Decl(complexClassRelationships.ts, 24, 1))
}
public populate() {
>populate : Symbol(Foo.populate, Decl(complexClassRelationships.ts, 29, 5))
this.prop2;
>this.prop2 : Symbol(Foo.prop2, Decl(complexClassRelationships.ts, 32, 5))
>this : Symbol(Foo, Decl(complexClassRelationships.ts, 24, 1))
>prop2 : Symbol(Foo.prop2, Decl(complexClassRelationships.ts, 32, 5))
}
public get prop2(): BaseCollection<Derived> {
>prop2 : Symbol(Foo.prop2, Decl(complexClassRelationships.ts, 32, 5))
>BaseCollection : Symbol(BaseCollection, Decl(complexClassRelationships.ts, 6, 1))
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
return new BaseCollection<Derived>(Derived.createEmpty);
>BaseCollection : Symbol(BaseCollection, Decl(complexClassRelationships.ts, 6, 1))
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
>Derived.createEmpty : Symbol(Derived.createEmpty, Decl(complexClassRelationships.ts, 1, 28))
>Derived : Symbol(Derived, Decl(complexClassRelationships.ts, 0, 0))
>createEmpty : Symbol(Derived.createEmpty, Decl(complexClassRelationships.ts, 1, 28))
}
}
class GenericType<T> {
>GenericType : Symbol(GenericType, Decl(complexClassRelationships.ts, 36, 1))
>T : Symbol(T, Decl(complexClassRelationships.ts, 38, 18))
constructor(parent: FooBase) { }
>parent : Symbol(parent, Decl(complexClassRelationships.ts, 39, 16))
>FooBase : Symbol(FooBase, Decl(complexClassRelationships.ts, 40, 1))
}
class FooBase {
>FooBase : Symbol(FooBase, Decl(complexClassRelationships.ts, 40, 1))
public populate() {
>populate : Symbol(FooBase.populate, Decl(complexClassRelationships.ts, 42, 15))
}
}
@@ -1,123 +0,0 @@
=== tests/cases/compiler/complexClassRelationships.ts ===
// There should be no errors in this file
class Derived extends Base {
>Derived : Derived
>Base : Base
public static createEmpty(): Derived {
>createEmpty : () => Derived
>Derived : Derived
var item = new Derived();
>item : Derived
>new Derived() : Derived
>Derived : typeof Derived
return item;
>item : Derived
}
}
class BaseCollection<T extends Base> {
>BaseCollection : BaseCollection<T>
>T : T
>Base : Base
constructor(f: () => T) {
>f : () => T
>T : T
(item: Thing) => { return [item.Components]; };
>(item: Thing) => { return [item.Components]; } : (item: Thing) => ComponentCollection<any>[]
>item : Thing
>Thing : Thing
>[item.Components] : ComponentCollection<any>[]
>item.Components : ComponentCollection<any>
>item : Thing
>Components : ComponentCollection<any>
}
}
class Base {
>Base : Base
ownerCollection: BaseCollection<Base>;
>ownerCollection : BaseCollection<Base>
>BaseCollection : BaseCollection<T>
>Base : Base
}
class Thing {
>Thing : Thing
public get Components(): ComponentCollection<any> { return null }
>Components : ComponentCollection<any>
>ComponentCollection : ComponentCollection<T>
>null : null
}
class ComponentCollection<T> {
>ComponentCollection : ComponentCollection<T>
>T : T
private static sortComponents(p: Foo) {
>sortComponents : (p: Foo) => GenericType<string>
>p : Foo
>Foo : Foo
return p.prop1;
>p.prop1 : GenericType<string>
>p : Foo
>prop1 : GenericType<string>
}
}
class Foo {
>Foo : Foo
public get prop1() {
>prop1 : GenericType<string>
return new GenericType<string>(this);
>new GenericType<string>(this) : GenericType<string>
>GenericType : typeof GenericType
>this : this
}
public populate() {
>populate : () => void
this.prop2;
>this.prop2 : BaseCollection<Derived>
>this : this
>prop2 : BaseCollection<Derived>
}
public get prop2(): BaseCollection<Derived> {
>prop2 : BaseCollection<Derived>
>BaseCollection : BaseCollection<T>
>Derived : Derived
return new BaseCollection<Derived>(Derived.createEmpty);
>new BaseCollection<Derived>(Derived.createEmpty) : BaseCollection<Derived>
>BaseCollection : typeof BaseCollection
>Derived : Derived
>Derived.createEmpty : () => Derived
>Derived : typeof Derived
>createEmpty : () => Derived
}
}
class GenericType<T> {
>GenericType : GenericType<T>
>T : T
constructor(parent: FooBase) { }
>parent : FooBase
>FooBase : FooBase
}
class FooBase {
>FooBase : FooBase
public populate() {
>populate : () => void
}
}
@@ -14,15 +14,15 @@ var fa: number[];
fa = fa.concat([0]);
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
fa = fa.concat(0);
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fa : Symbol(fa, Decl(concatError.ts, 8, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
+4 -4
View File
@@ -16,9 +16,9 @@ fa = fa.concat([0]);
>fa = fa.concat([0]) : number[]
>fa : number[]
>fa.concat([0]) : number[]
>fa.concat : (...items: (number | number[])[]) => number[]
>fa.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
>fa : number[]
>concat : (...items: (number | number[])[]) => number[]
>concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
>[0] : number[]
>0 : number
@@ -26,9 +26,9 @@ fa = fa.concat(0);
>fa = fa.concat(0) : number[]
>fa : number[]
>fa.concat(0) : number[]
>fa.concat : (...items: (number | number[])[]) => number[]
>fa.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
>fa : number[]
>concat : (...items: (number | number[])[]) => number[]
>concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; }
>0 : number
@@ -0,0 +1,8 @@
//// [concatTuples.ts]
let ijs: [number, number][] = [[1, 2]];
ijs = ijs.concat([[3, 4], [5, 6]]);
//// [concatTuples.js]
var ijs = [[1, 2]];
ijs = ijs.concat([[3, 4], [5, 6]]);
@@ -0,0 +1,10 @@
=== tests/cases/compiler/concatTuples.ts ===
let ijs: [number, number][] = [[1, 2]];
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
ijs = ijs.concat([[3, 4], [5, 6]]);
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
>ijs.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>ijs : Symbol(ijs, Decl(concatTuples.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
@@ -0,0 +1,23 @@
=== tests/cases/compiler/concatTuples.ts ===
let ijs: [number, number][] = [[1, 2]];
>ijs : [number, number][]
>[[1, 2]] : [number, number][]
>[1, 2] : [number, number]
>1 : number
>2 : number
ijs = ijs.concat([[3, 4], [5, 6]]);
>ijs = ijs.concat([[3, 4], [5, 6]]) : [number, number][]
>ijs : [number, number][]
>ijs.concat([[3, 4], [5, 6]]) : [number, number][]
>ijs.concat : { (...items: [number, number][][]): [number, number][]; (...items: ([number, number] | [number, number][])[]): [number, number][]; }
>ijs : [number, number][]
>concat : { (...items: [number, number][][]): [number, number][]; (...items: ([number, number] | [number, number][])[]): [number, number][]; }
>[[3, 4], [5, 6]] : [number, number][]
>[3, 4] : [number, number]
>3 : number
>4 : number
>[5, 6] : [number, number]
>5 : number
>6 : number
@@ -0,0 +1,36 @@
tests/cases/compiler/derivedClasses.ts(1,19): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/derivedClasses.ts (1 errors) ====
class Red extends Color {
~~~~~
!!! error TS2690: A class must be declared after its base class.
public shade() {
var getHue = () => { return this.hue(); };
return getHue() + " red";
}
}
class Color {
public shade() { return "some shade"; }
public hue() { return "some hue"; }
}
class Blue extends Color {
public shade() {
var getHue = () => { return this.hue(); };
return getHue() + " blue";
}
}
var r = new Red();
var b = new Blue();
r.shade();
r.hue();
b.shade();
b.hue();
@@ -1,77 +0,0 @@
=== tests/cases/compiler/derivedClasses.ts ===
class Red extends Color {
>Red : Symbol(Red, Decl(derivedClasses.ts, 0, 0))
>Color : Symbol(Color, Decl(derivedClasses.ts, 5, 1))
public shade() {
>shade : Symbol(Red.shade, Decl(derivedClasses.ts, 0, 25))
var getHue = () => { return this.hue(); };
>getHue : Symbol(getHue, Decl(derivedClasses.ts, 2, 8))
>this.hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
>this : Symbol(Red, Decl(derivedClasses.ts, 0, 0))
>hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
return getHue() + " red";
>getHue : Symbol(getHue, Decl(derivedClasses.ts, 2, 8))
}
}
class Color {
>Color : Symbol(Color, Decl(derivedClasses.ts, 5, 1))
public shade() { return "some shade"; }
>shade : Symbol(Color.shade, Decl(derivedClasses.ts, 7, 13))
public hue() { return "some hue"; }
>hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
}
class Blue extends Color {
>Blue : Symbol(Blue, Decl(derivedClasses.ts, 10, 1))
>Color : Symbol(Color, Decl(derivedClasses.ts, 5, 1))
public shade() {
>shade : Symbol(Blue.shade, Decl(derivedClasses.ts, 12, 26))
var getHue = () => { return this.hue(); };
>getHue : Symbol(getHue, Decl(derivedClasses.ts, 15, 8))
>this.hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
>this : Symbol(Blue, Decl(derivedClasses.ts, 10, 1))
>hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
return getHue() + " blue";
>getHue : Symbol(getHue, Decl(derivedClasses.ts, 15, 8))
}
}
var r = new Red();
>r : Symbol(r, Decl(derivedClasses.ts, 20, 3))
>Red : Symbol(Red, Decl(derivedClasses.ts, 0, 0))
var b = new Blue();
>b : Symbol(b, Decl(derivedClasses.ts, 21, 3))
>Blue : Symbol(Blue, Decl(derivedClasses.ts, 10, 1))
r.shade();
>r.shade : Symbol(Red.shade, Decl(derivedClasses.ts, 0, 25))
>r : Symbol(r, Decl(derivedClasses.ts, 20, 3))
>shade : Symbol(Red.shade, Decl(derivedClasses.ts, 0, 25))
r.hue();
>r.hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
>r : Symbol(r, Decl(derivedClasses.ts, 20, 3))
>hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
b.shade();
>b.shade : Symbol(Blue.shade, Decl(derivedClasses.ts, 12, 26))
>b : Symbol(b, Decl(derivedClasses.ts, 21, 3))
>shade : Symbol(Blue.shade, Decl(derivedClasses.ts, 12, 26))
b.hue();
>b.hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
>b : Symbol(b, Decl(derivedClasses.ts, 21, 3))
>hue : Symbol(Color.hue, Decl(derivedClasses.ts, 8, 43))
@@ -1,95 +0,0 @@
=== tests/cases/compiler/derivedClasses.ts ===
class Red extends Color {
>Red : Red
>Color : Color
public shade() {
>shade : () => string
var getHue = () => { return this.hue(); };
>getHue : () => string
>() => { return this.hue(); } : () => string
>this.hue() : string
>this.hue : () => string
>this : this
>hue : () => string
return getHue() + " red";
>getHue() + " red" : string
>getHue() : string
>getHue : () => string
>" red" : string
}
}
class Color {
>Color : Color
public shade() { return "some shade"; }
>shade : () => string
>"some shade" : string
public hue() { return "some hue"; }
>hue : () => string
>"some hue" : string
}
class Blue extends Color {
>Blue : Blue
>Color : Color
public shade() {
>shade : () => string
var getHue = () => { return this.hue(); };
>getHue : () => string
>() => { return this.hue(); } : () => string
>this.hue() : string
>this.hue : () => string
>this : this
>hue : () => string
return getHue() + " blue";
>getHue() + " blue" : string
>getHue() : string
>getHue : () => string
>" blue" : string
}
}
var r = new Red();
>r : Red
>new Red() : Red
>Red : typeof Red
var b = new Blue();
>b : Blue
>new Blue() : Blue
>Blue : typeof Blue
r.shade();
>r.shade() : string
>r.shade : () => string
>r : Red
>shade : () => string
r.hue();
>r.hue() : string
>r.hue : () => string
>r : Red
>hue : () => string
b.shade();
>b.shade() : string
>b.shade : () => string
>b : Blue
>shade : () => string
b.hue();
>b.hue() : string
>b.hue : () => string
>b : Blue
>hue : () => string
@@ -15,9 +15,9 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any
>fn : Symbol(fn, Decl(emitSkipsThisWithRestParameter.ts, 0, 16))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
>[ this ].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>[ this ].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 1, 30))
};
@@ -18,10 +18,10 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : any
>[ this ].concat(args) : any[]
>[ this ].concat : (...items: any[]) => any[]
>[ this ].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
>[ this ] : any[]
>this : any
>concat : (...items: any[]) => any[]
>concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
>args : any[]
};
@@ -0,0 +1,9 @@
//// [exportToString.ts]
const toString = 0;
export { toString };
//// [exportToString.js]
"use strict";
var toString = 0;
exports.toString = toString;
@@ -0,0 +1,7 @@
=== tests/cases/compiler/exportToString.ts ===
const toString = 0;
>toString : Symbol(toString, Decl(exportToString.ts, 0, 5))
export { toString };
>toString : Symbol(toString, Decl(exportToString.ts, 1, 8))
@@ -0,0 +1,8 @@
=== tests/cases/compiler/exportToString.ts ===
const toString = 0;
>toString : number
>0 : number
export { toString };
>toString : number
@@ -0,0 +1,9 @@
tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts (1 errors) ====
class derived extends base { }
~~~~
!!! error TS2690: A class must be declared after its base class.
class base { constructor (public n: number) { } }
@@ -1,9 +0,0 @@
=== tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts ===
class derived extends base { }
>derived : Symbol(derived, Decl(extendBaseClassBeforeItsDeclared.ts, 0, 0))
>base : Symbol(base, Decl(extendBaseClassBeforeItsDeclared.ts, 0, 30))
class base { constructor (public n: number) { } }
>base : Symbol(base, Decl(extendBaseClassBeforeItsDeclared.ts, 0, 30))
>n : Symbol(base.n, Decl(extendBaseClassBeforeItsDeclared.ts, 2, 26))
@@ -1,9 +0,0 @@
=== tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts ===
class derived extends base { }
>derived : derived
>base : base
class base { constructor (public n: number) { } }
>base : base
>n : number
@@ -0,0 +1,14 @@
tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(1,17): error TS2690: A class must be declared after its base class.
tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20): error TS2690: A class must be declared after its base class.
==== tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts (2 errors) ====
class A extends B<string> { }
~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
class B<U> extends C { }
~
!!! error TS2690: A class must be declared after its base class.
class C {
constructor(p: string) { }
}
@@ -1,16 +0,0 @@
=== tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts ===
class A extends B<string> { }
>A : Symbol(A, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 0, 0))
>B : Symbol(B, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 0, 29))
class B<U> extends C { }
>B : Symbol(B, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 0, 29))
>U : Symbol(U, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 1, 8))
>C : Symbol(C, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 1, 24))
class C {
>C : Symbol(C, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 1, 24))
constructor(p: string) { }
>p : Symbol(p, Decl(genericClassInheritsConstructorFromNonGenericClass.ts, 3, 16))
}
@@ -1,16 +0,0 @@
=== tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts ===
class A extends B<string> { }
>A : A
>B : B<string>
class B<U> extends C { }
>B : B<U>
>U : U
>C : C
class C {
>C : C
constructor(p: string) { }
>p : string
}
@@ -3,9 +3,9 @@ var array: symbol[];
>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3))
array.concat([...new SymbolIterator]);
>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --))
>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38))
class SymbolIterator {
@@ -4,9 +4,9 @@ var array: symbol[];
array.concat([...new SymbolIterator]);
>array.concat([...new SymbolIterator]) : symbol[]
>array.concat : (...items: (symbol | symbol[])[]) => symbol[]
>array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; }
>array : symbol[]
>concat : (...items: (symbol | symbol[])[]) => symbol[]
>concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; }
>[...new SymbolIterator] : symbol[]
>...new SymbolIterator : symbol
>new SymbolIterator : SymbolIterator
@@ -1,5 +1,5 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
@@ -1,5 +1,5 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
@@ -1,5 +1,5 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory 'types'. ========",
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
@@ -5,7 +5,7 @@
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
@@ -4,7 +4,7 @@
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
@@ -1,8 +1,11 @@
tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,22): error TS2690: A class must be declared after its base class.
tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ====
==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (2 errors) ====
class George extends class { reset() { return this.y; } } {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
~
!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
constructor() {
@@ -0,0 +1,139 @@
//// [narrowingByDiscriminantInLoop.ts]
// Repro from #9977
type IDLMemberTypes = OperationMemberType | ConstantMemberType;
interface IDLTypeDescription {
origin: string;
}
interface InterfaceType {
members: IDLMemberTypes[];
}
interface OperationMemberType {
type: "operation";
idlType: IDLTypeDescription;
}
interface ConstantMemberType {
type: "const";
idlType: string;
}
function insertInterface(callbackType: InterfaceType) {
for (const memberType of callbackType.members) {
if (memberType.type === "const") {
memberType.idlType; // string
}
else if (memberType.type === "operation") {
memberType.idlType.origin; // string
(memberType.idlType as IDLTypeDescription);
}
}
}
function insertInterface2(callbackType: InterfaceType) {
for (const memberType of callbackType.members) {
if (memberType.type === "operation") {
memberType.idlType.origin; // string
}
}
}
function foo(memberType: IDLMemberTypes) {
if (memberType.type === "const") {
memberType.idlType; // string
}
else if (memberType.type === "operation") {
memberType.idlType.origin; // string
}
}
// Repro for issue similar to #8383
interface A {
kind: true;
prop: { a: string; };
}
interface B {
kind: false;
prop: { b: string; }
}
function f1(x: A | B) {
while (true) {
x.prop;
if (x.kind === true) {
x.prop.a;
}
if (x.kind === false) {
x.prop.b;
}
}
}
function f2(x: A | B) {
while (true) {
if (x.kind) {
x.prop.a;
}
if (!x.kind) {
x.prop.b;
}
}
}
//// [narrowingByDiscriminantInLoop.js]
// Repro from #9977
function insertInterface(callbackType) {
for (var _i = 0, _a = callbackType.members; _i < _a.length; _i++) {
var memberType = _a[_i];
if (memberType.type === "const") {
memberType.idlType; // string
}
else if (memberType.type === "operation") {
memberType.idlType.origin; // string
memberType.idlType;
}
}
}
function insertInterface2(callbackType) {
for (var _i = 0, _a = callbackType.members; _i < _a.length; _i++) {
var memberType = _a[_i];
if (memberType.type === "operation") {
memberType.idlType.origin; // string
}
}
}
function foo(memberType) {
if (memberType.type === "const") {
memberType.idlType; // string
}
else if (memberType.type === "operation") {
memberType.idlType.origin; // string
}
}
function f1(x) {
while (true) {
x.prop;
if (x.kind === true) {
x.prop.a;
}
if (x.kind === false) {
x.prop.b;
}
}
}
function f2(x) {
while (true) {
if (x.kind) {
x.prop.a;
}
if (!x.kind) {
x.prop.b;
}
}
}
@@ -0,0 +1,238 @@
=== tests/cases/compiler/narrowingByDiscriminantInLoop.ts ===
// Repro from #9977
type IDLMemberTypes = OperationMemberType | ConstantMemberType;
>IDLMemberTypes : Symbol(IDLMemberTypes, Decl(narrowingByDiscriminantInLoop.ts, 0, 0))
>OperationMemberType : Symbol(OperationMemberType, Decl(narrowingByDiscriminantInLoop.ts, 11, 1))
>ConstantMemberType : Symbol(ConstantMemberType, Decl(narrowingByDiscriminantInLoop.ts, 16, 1))
interface IDLTypeDescription {
>IDLTypeDescription : Symbol(IDLTypeDescription, Decl(narrowingByDiscriminantInLoop.ts, 3, 63))
origin: string;
>origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
}
interface InterfaceType {
>InterfaceType : Symbol(InterfaceType, Decl(narrowingByDiscriminantInLoop.ts, 7, 1))
members: IDLMemberTypes[];
>members : Symbol(InterfaceType.members, Decl(narrowingByDiscriminantInLoop.ts, 9, 25))
>IDLMemberTypes : Symbol(IDLMemberTypes, Decl(narrowingByDiscriminantInLoop.ts, 0, 0))
}
interface OperationMemberType {
>OperationMemberType : Symbol(OperationMemberType, Decl(narrowingByDiscriminantInLoop.ts, 11, 1))
type: "operation";
>type : Symbol(OperationMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31))
idlType: IDLTypeDescription;
>idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>IDLTypeDescription : Symbol(IDLTypeDescription, Decl(narrowingByDiscriminantInLoop.ts, 3, 63))
}
interface ConstantMemberType {
>ConstantMemberType : Symbol(ConstantMemberType, Decl(narrowingByDiscriminantInLoop.ts, 16, 1))
type: "const";
>type : Symbol(ConstantMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
idlType: string;
>idlType : Symbol(ConstantMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 19, 18))
}
function insertInterface(callbackType: InterfaceType) {
>insertInterface : Symbol(insertInterface, Decl(narrowingByDiscriminantInLoop.ts, 21, 1))
>callbackType : Symbol(callbackType, Decl(narrowingByDiscriminantInLoop.ts, 23, 25))
>InterfaceType : Symbol(InterfaceType, Decl(narrowingByDiscriminantInLoop.ts, 7, 1))
for (const memberType of callbackType.members) {
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>callbackType.members : Symbol(InterfaceType.members, Decl(narrowingByDiscriminantInLoop.ts, 9, 25))
>callbackType : Symbol(callbackType, Decl(narrowingByDiscriminantInLoop.ts, 23, 25))
>members : Symbol(InterfaceType.members, Decl(narrowingByDiscriminantInLoop.ts, 9, 25))
if (memberType.type === "const") {
>memberType.type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
memberType.idlType; // string
>memberType.idlType : Symbol(ConstantMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 19, 18))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>idlType : Symbol(ConstantMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 19, 18))
}
else if (memberType.type === "operation") {
>memberType.type : Symbol(OperationMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>type : Symbol(OperationMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31))
memberType.idlType.origin; // string
>memberType.idlType.origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
>memberType.idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
(memberType.idlType as IDLTypeDescription);
>memberType.idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 24, 14))
>idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>IDLTypeDescription : Symbol(IDLTypeDescription, Decl(narrowingByDiscriminantInLoop.ts, 3, 63))
}
}
}
function insertInterface2(callbackType: InterfaceType) {
>insertInterface2 : Symbol(insertInterface2, Decl(narrowingByDiscriminantInLoop.ts, 33, 1))
>callbackType : Symbol(callbackType, Decl(narrowingByDiscriminantInLoop.ts, 35, 26))
>InterfaceType : Symbol(InterfaceType, Decl(narrowingByDiscriminantInLoop.ts, 7, 1))
for (const memberType of callbackType.members) {
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 36, 14))
>callbackType.members : Symbol(InterfaceType.members, Decl(narrowingByDiscriminantInLoop.ts, 9, 25))
>callbackType : Symbol(callbackType, Decl(narrowingByDiscriminantInLoop.ts, 35, 26))
>members : Symbol(InterfaceType.members, Decl(narrowingByDiscriminantInLoop.ts, 9, 25))
if (memberType.type === "operation") {
>memberType.type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 36, 14))
>type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
memberType.idlType.origin; // string
>memberType.idlType.origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
>memberType.idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 36, 14))
>idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
}
}
}
function foo(memberType: IDLMemberTypes) {
>foo : Symbol(foo, Decl(narrowingByDiscriminantInLoop.ts, 41, 1))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 43, 13))
>IDLMemberTypes : Symbol(IDLMemberTypes, Decl(narrowingByDiscriminantInLoop.ts, 0, 0))
if (memberType.type === "const") {
>memberType.type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 43, 13))
>type : Symbol(type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31), Decl(narrowingByDiscriminantInLoop.ts, 18, 30))
memberType.idlType; // string
>memberType.idlType : Symbol(ConstantMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 19, 18))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 43, 13))
>idlType : Symbol(ConstantMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 19, 18))
}
else if (memberType.type === "operation") {
>memberType.type : Symbol(OperationMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 43, 13))
>type : Symbol(OperationMemberType.type, Decl(narrowingByDiscriminantInLoop.ts, 13, 31))
memberType.idlType.origin; // string
>memberType.idlType.origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
>memberType.idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>memberType : Symbol(memberType, Decl(narrowingByDiscriminantInLoop.ts, 43, 13))
>idlType : Symbol(OperationMemberType.idlType, Decl(narrowingByDiscriminantInLoop.ts, 14, 22))
>origin : Symbol(IDLTypeDescription.origin, Decl(narrowingByDiscriminantInLoop.ts, 5, 30))
}
}
// Repro for issue similar to #8383
interface A {
>A : Symbol(A, Decl(narrowingByDiscriminantInLoop.ts, 50, 1))
kind: true;
>kind : Symbol(A.kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13))
prop: { a: string; };
>prop : Symbol(A.prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15))
>a : Symbol(a, Decl(narrowingByDiscriminantInLoop.ts, 56, 11))
}
interface B {
>B : Symbol(B, Decl(narrowingByDiscriminantInLoop.ts, 57, 1))
kind: false;
>kind : Symbol(B.kind, Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
prop: { b: string; }
>prop : Symbol(B.prop, Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>b : Symbol(b, Decl(narrowingByDiscriminantInLoop.ts, 61, 11))
}
function f1(x: A | B) {
>f1 : Symbol(f1, Decl(narrowingByDiscriminantInLoop.ts, 62, 1))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>A : Symbol(A, Decl(narrowingByDiscriminantInLoop.ts, 50, 1))
>B : Symbol(B, Decl(narrowingByDiscriminantInLoop.ts, 57, 1))
while (true) {
x.prop;
>x.prop : Symbol(prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15), Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>prop : Symbol(prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15), Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
if (x.kind === true) {
>x.kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
x.prop.a;
>x.prop.a : Symbol(a, Decl(narrowingByDiscriminantInLoop.ts, 56, 11))
>x.prop : Symbol(A.prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>prop : Symbol(A.prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15))
>a : Symbol(a, Decl(narrowingByDiscriminantInLoop.ts, 56, 11))
}
if (x.kind === false) {
>x.kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
x.prop.b;
>x.prop.b : Symbol(b, Decl(narrowingByDiscriminantInLoop.ts, 61, 11))
>x.prop : Symbol(B.prop, Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 64, 12))
>prop : Symbol(B.prop, Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>b : Symbol(b, Decl(narrowingByDiscriminantInLoop.ts, 61, 11))
}
}
}
function f2(x: A | B) {
>f2 : Symbol(f2, Decl(narrowingByDiscriminantInLoop.ts, 74, 1))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 76, 12))
>A : Symbol(A, Decl(narrowingByDiscriminantInLoop.ts, 50, 1))
>B : Symbol(B, Decl(narrowingByDiscriminantInLoop.ts, 57, 1))
while (true) {
if (x.kind) {
>x.kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 76, 12))
>kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
x.prop.a;
>x.prop.a : Symbol(a, Decl(narrowingByDiscriminantInLoop.ts, 56, 11))
>x.prop : Symbol(A.prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 76, 12))
>prop : Symbol(A.prop, Decl(narrowingByDiscriminantInLoop.ts, 55, 15))
>a : Symbol(a, Decl(narrowingByDiscriminantInLoop.ts, 56, 11))
}
if (!x.kind) {
>x.kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 76, 12))
>kind : Symbol(kind, Decl(narrowingByDiscriminantInLoop.ts, 54, 13), Decl(narrowingByDiscriminantInLoop.ts, 59, 13))
x.prop.b;
>x.prop.b : Symbol(b, Decl(narrowingByDiscriminantInLoop.ts, 61, 11))
>x.prop : Symbol(B.prop, Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>x : Symbol(x, Decl(narrowingByDiscriminantInLoop.ts, 76, 12))
>prop : Symbol(B.prop, Decl(narrowingByDiscriminantInLoop.ts, 60, 16))
>b : Symbol(b, Decl(narrowingByDiscriminantInLoop.ts, 61, 11))
}
}
}
@@ -0,0 +1,261 @@
=== tests/cases/compiler/narrowingByDiscriminantInLoop.ts ===
// Repro from #9977
type IDLMemberTypes = OperationMemberType | ConstantMemberType;
>IDLMemberTypes : IDLMemberTypes
>OperationMemberType : OperationMemberType
>ConstantMemberType : ConstantMemberType
interface IDLTypeDescription {
>IDLTypeDescription : IDLTypeDescription
origin: string;
>origin : string
}
interface InterfaceType {
>InterfaceType : InterfaceType
members: IDLMemberTypes[];
>members : IDLMemberTypes[]
>IDLMemberTypes : IDLMemberTypes
}
interface OperationMemberType {
>OperationMemberType : OperationMemberType
type: "operation";
>type : "operation"
idlType: IDLTypeDescription;
>idlType : IDLTypeDescription
>IDLTypeDescription : IDLTypeDescription
}
interface ConstantMemberType {
>ConstantMemberType : ConstantMemberType
type: "const";
>type : "const"
idlType: string;
>idlType : string
}
function insertInterface(callbackType: InterfaceType) {
>insertInterface : (callbackType: InterfaceType) => void
>callbackType : InterfaceType
>InterfaceType : InterfaceType
for (const memberType of callbackType.members) {
>memberType : IDLMemberTypes
>callbackType.members : IDLMemberTypes[]
>callbackType : InterfaceType
>members : IDLMemberTypes[]
if (memberType.type === "const") {
>memberType.type === "const" : boolean
>memberType.type : "operation" | "const"
>memberType : IDLMemberTypes
>type : "operation" | "const"
>"const" : "const"
memberType.idlType; // string
>memberType.idlType : string
>memberType : ConstantMemberType
>idlType : string
}
else if (memberType.type === "operation") {
>memberType.type === "operation" : boolean
>memberType.type : "operation"
>memberType : OperationMemberType
>type : "operation"
>"operation" : "operation"
memberType.idlType.origin; // string
>memberType.idlType.origin : string
>memberType.idlType : IDLTypeDescription
>memberType : OperationMemberType
>idlType : IDLTypeDescription
>origin : string
(memberType.idlType as IDLTypeDescription);
>(memberType.idlType as IDLTypeDescription) : IDLTypeDescription
>memberType.idlType as IDLTypeDescription : IDLTypeDescription
>memberType.idlType : IDLTypeDescription
>memberType : OperationMemberType
>idlType : IDLTypeDescription
>IDLTypeDescription : IDLTypeDescription
}
}
}
function insertInterface2(callbackType: InterfaceType) {
>insertInterface2 : (callbackType: InterfaceType) => void
>callbackType : InterfaceType
>InterfaceType : InterfaceType
for (const memberType of callbackType.members) {
>memberType : IDLMemberTypes
>callbackType.members : IDLMemberTypes[]
>callbackType : InterfaceType
>members : IDLMemberTypes[]
if (memberType.type === "operation") {
>memberType.type === "operation" : boolean
>memberType.type : "operation" | "const"
>memberType : IDLMemberTypes
>type : "operation" | "const"
>"operation" : "operation"
memberType.idlType.origin; // string
>memberType.idlType.origin : string
>memberType.idlType : IDLTypeDescription
>memberType : OperationMemberType
>idlType : IDLTypeDescription
>origin : string
}
}
}
function foo(memberType: IDLMemberTypes) {
>foo : (memberType: IDLMemberTypes) => void
>memberType : IDLMemberTypes
>IDLMemberTypes : IDLMemberTypes
if (memberType.type === "const") {
>memberType.type === "const" : boolean
>memberType.type : "operation" | "const"
>memberType : IDLMemberTypes
>type : "operation" | "const"
>"const" : "const"
memberType.idlType; // string
>memberType.idlType : string
>memberType : ConstantMemberType
>idlType : string
}
else if (memberType.type === "operation") {
>memberType.type === "operation" : boolean
>memberType.type : "operation"
>memberType : OperationMemberType
>type : "operation"
>"operation" : "operation"
memberType.idlType.origin; // string
>memberType.idlType.origin : string
>memberType.idlType : IDLTypeDescription
>memberType : OperationMemberType
>idlType : IDLTypeDescription
>origin : string
}
}
// Repro for issue similar to #8383
interface A {
>A : A
kind: true;
>kind : true
>true : true
prop: { a: string; };
>prop : { a: string; }
>a : string
}
interface B {
>B : B
kind: false;
>kind : false
>false : false
prop: { b: string; }
>prop : { b: string; }
>b : string
}
function f1(x: A | B) {
>f1 : (x: A | B) => void
>x : A | B
>A : A
>B : B
while (true) {
>true : boolean
x.prop;
>x.prop : { a: string; } | { b: string; }
>x : A | B
>prop : { a: string; } | { b: string; }
if (x.kind === true) {
>x.kind === true : boolean
>x.kind : boolean
>x : A | B
>kind : boolean
>true : true
x.prop.a;
>x.prop.a : string
>x.prop : { a: string; }
>x : A
>prop : { a: string; }
>a : string
}
if (x.kind === false) {
>x.kind === false : boolean
>x.kind : boolean
>x : A | B
>kind : boolean
>false : false
x.prop.b;
>x.prop.b : string
>x.prop : { b: string; }
>x : B
>prop : { b: string; }
>b : string
}
}
}
function f2(x: A | B) {
>f2 : (x: A | B) => void
>x : A | B
>A : A
>B : B
while (true) {
>true : boolean
if (x.kind) {
>x.kind : boolean
>x : A | B
>kind : boolean
x.prop.a;
>x.prop.a : string
>x.prop : { a: string; }
>x : A
>prop : { a: string; }
>a : string
}
if (!x.kind) {
>!x.kind : boolean
>x.kind : boolean
>x : A | B
>kind : boolean
x.prop.b;
>x.prop.b : string
>x.prop : { b: string; }
>x : B
>prop : { b: string; }
>b : string
}
}
}
@@ -28,8 +28,8 @@ var e: Ellement;
>Ellement : Symbol(Ellement, Decl(nonContextuallyTypedLogicalOr.ts, 3, 1))
(c || e).dummy;
>(c || e).dummy : Symbol(dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22), Decl(nonContextuallyTypedLogicalOr.ts, 5, 20))
>(c || e).dummy : Symbol(Contextual.dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22))
>c : Symbol(c, Decl(nonContextuallyTypedLogicalOr.ts, 10, 3))
>e : Symbol(e, Decl(nonContextuallyTypedLogicalOr.ts, 11, 3))
>dummy : Symbol(dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22), Decl(nonContextuallyTypedLogicalOr.ts, 5, 20))
>dummy : Symbol(Contextual.dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22))
@@ -29,8 +29,8 @@ var e: Ellement;
(c || e).dummy;
>(c || e).dummy : any
>(c || e) : Contextual | Ellement
>c || e : Contextual | Ellement
>(c || e) : Contextual
>c || e : Contextual
>c : Contextual
>e : Ellement
>dummy : any
@@ -1,11 +1,13 @@
tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts(16,67): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(17,67): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(20,63): error TS2690: A class must be declared after its base class.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS2690: A class must be declared after its base class.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(64,55): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'.
tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'.
==== tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts (4 errors) ====
==== tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts (6 errors) ====
export module publicModule {
export class publicClassInPublicModule {
@@ -28,10 +30,14 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65):
}
class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
}
export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error
~~~~~~~~~~~~~
!!! error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2690: A class must be declared after its base class.
}
}
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More