merged with master

This commit is contained in:
Arthur Ozga
2015-07-31 10:03:48 -07:00
165 changed files with 4977 additions and 1600 deletions
+12 -12
View File
@@ -17,7 +17,7 @@ var docDirectory = "doc/";
var builtDirectory = "built/";
var builtLocalDirectory = "built/local/";
var LKGDirectory = "bin/";
var LKGDirectory = "lib/";
var copyright = "CopyrightNotice.txt";
var thirdParty = "ThirdPartyNoticeText.txt";
@@ -218,7 +218,7 @@ var compilerFilename = "tsc.js";
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
file(outFile, prereqs, function() {
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
var options = "--module commonjs -noImplicitAny";
var options = "--module commonjs --noImplicitAny --noEmitOnError";
// Keep comments when specifically requested
// or when in debug mode.
@@ -339,10 +339,10 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
complete();
});
ex.run();
}, {async: true});
}, {async: true});
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
task("generate-diagnostics", [diagnosticInfoMapTs]);
task("generate-diagnostics", [diagnosticInfoMapTs]);
// Publish nightly
@@ -479,11 +479,11 @@ file(specMd, [word2mdJs, specWord], function () {
child_process.exec(cmd, function () {
complete();
});
}, {async: true});
}, {async: true});
desc("Generates a Markdown version of the Language Specification");
task("generate-spec", [specMd]);
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
@@ -615,7 +615,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
exec(cmd, deleteTemporaryProjectOutput);
}, {async: true});
desc("Generates code coverage data via instanbul");
desc("Generates code coverage data via instanbul");
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
console.log(cmd);
@@ -658,7 +658,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
function getDiffTool() {
var program = process.env['DIFF']
if (!program) {
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
}
return program;
}
@@ -667,14 +667,14 @@ function getDiffTool() {
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff', function () {
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
console.log(cmd);
console.log(cmd);
exec(cmd);
}, {async: true});
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff-rwc', function () {
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
console.log(cmd);
console.log(cmd);
exec(cmd);
}, {async: true});
@@ -775,9 +775,9 @@ task("lint", [], function() {
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }};
var lintTargets = compilerSources.concat(harnessCoreSources);
for(var i in lintTargets) {
for (var i in lintTargets) {
var f = lintTargets[i];
var cmd = 'tslint -f ' + f;
var cmd = 'tslint -c tslint.json ' + f;
exec(cmd, success(f), failure(f));
}
}, { async: true });
+15 -1
View File
@@ -8,6 +8,19 @@
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
## Installing
For the latest stable version:
```
npm install -g typescript
```
For our nightly builds:
```
npm install -g typescript@next
```
## Contribute
@@ -63,7 +76,8 @@ jake runtests # Run tests using the built compiler and test infrastructu
# Use host=<hostName> or tests=<testPath>.
jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional
parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
jake lint # Runs tslint on the TypeScript source.
jake -T # List the above commands.
```
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./tsc.js')
require('../lib/tsc.js')
Regular → Executable
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./tsserver.js')
require('../lib/tsserver.js')
Binary file not shown.
Binary file not shown.
+1621 -1165
View File
File diff suppressed because it is too large Load Diff
View File
View File
View File
View File
View File
View File
View File
View File
View File
+1 -2
View File
@@ -19,8 +19,7 @@
"type": "git",
"url": "https://github.com/Microsoft/TypeScript.git"
},
"preferGlobal": true,
"main": "./bin/typescript.js",
"main": "./lib/typescript.js",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
+29 -6
View File
@@ -1,8 +1,16 @@
// word2md - Word to Markdown conversion tool
//
// word2md converts a Microsoft Word document to Markdown formatted text. The tool uses the
// Word Automation APIs to start an instance of Word and access the contents of the document
// being converted. The tool must be run using the cscript.exe script host and requires Word
// to be installed on the target machine. The name of the document to convert must be specified
// as a command line argument and the resulting Markdown is written to standard output. The
// tool recognizes the specific Word styles used in the TypeScript Language Specification.
var sys = (function () {
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2;
fileStream.Type = 2 /*text*/;
var binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1;
binaryStream.Type = 1 /*binary*/;
var args = [];
for (var i = 0; i < WScript.Arguments.length; i++) {
args[i] = WScript.Arguments.Item(i);
@@ -17,11 +25,13 @@ var sys = (function () {
fileStream.Open();
binaryStream.Open();
try {
// Write characters in UTF-8 encoding
fileStream.Charset = "utf-8";
fileStream.WriteText(data);
// We don't want the BOM, skip it by setting the starting location to 3 (size of BOM).
fileStream.Position = 3;
fileStream.CopyTo(binaryStream);
binaryStream.SaveToFile(fileName, 2);
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
}
finally {
binaryStream.Close();
@@ -59,6 +69,17 @@ function convertDocumentToMarkdown(doc) {
setProperties(replace, replaceOptions);
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
}
function write(s) {
result += s;
}
@@ -184,14 +205,15 @@ function convertDocumentToMarkdown(doc) {
findReplace("&lt;", { style: "Code Fragment" }, "<", {});
findReplace("&lt;", { style: "Terminal" }, "<", {});
findReplace("", { font: { subscript: true } }, "<sub>^&</sub>", { font: { subscript: false } });
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 });
findReplace("", { style: "Production" }, "*^&*", { style: -66 });
findReplace("", { style: "Terminal" }, "`^&`", { style: -66 });
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */ });
findReplace("", { style: "Terminal" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { font: { bold: true, italic: true } }, "***^&***", { font: { bold: false, italic: false } });
findReplace("", { font: { italic: true } }, "*^&*", { font: { italic: false } });
doc.fields.toggleShowCodes();
findReplace("^19 REF", {}, "[^&](#^&)", {});
doc.fields.toggleShowCodes();
fixHyperlinks();
writeDocument();
result = result.replace(/\x85/g, "\u2026");
result = result.replace(/\x96/g, "\u2013");
@@ -210,3 +232,4 @@ function main(args) {
app.quit();
}
main(sys.args);
//# sourceMappingURL=file:///c:/ts/scripts/word2md.js.map
+24
View File
@@ -100,9 +100,19 @@ module Word {
toggleShowCodes(): void;
}
export interface Hyperlink {
address: string;
textToDisplay: string;
range: Range;
}
export interface Hyperlinks extends Collection<Hyperlink> {
}
export interface Document {
fields: Fields;
paragraphs: Paragraphs;
hyperlinks: Hyperlinks;
builtInDocumentProperties: Collection<any>;
close(saveChanges: boolean): void;
range(): Range;
@@ -195,6 +205,18 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
}
function write(s: string) {
result += s;
}
@@ -347,6 +369,8 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
findReplace("^19 REF", {}, "[^&](#^&)", {});
doc.fields.toggleShowCodes();
fixHyperlinks();
writeDocument();
result = result.replace(/\x85/g, "\u2026");
+156 -90
View File
@@ -91,7 +91,8 @@ namespace ts {
getExportsOfModule: getExportsOfModuleAsArray,
getJsxElementAttributesType,
getJsxIntrinsicTagNames
getJsxIntrinsicTagNames,
isOptionalParameter
};
let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -113,6 +114,10 @@ namespace ts {
emptyGenericType.instantiations = {};
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false);
@@ -587,7 +592,19 @@ namespace ts {
declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
return undefined;
}
if (result.flags & SymbolFlags.BlockScopedVariable) {
// Only check for block-scoped variable if we are looking for the
// name with variable meaning
// For example,
// declare module foo {
// interface bar {}
// }
// let foo/*1*/: foo/*2*/.bar;
// The foo at /*1*/ and /*2*/ will share same symbol with two meaning
// block - scope variable and namespace module. However, only when we
// try to resolve name in /*1*/ which is used in variable position,
// we want to check for block- scoped
if (meaning & SymbolFlags.BlockScopedVariable && result.flags & SymbolFlags.BlockScopedVariable) {
checkResolvedBlockScopedVariable(result, errorLocation);
}
}
@@ -1994,15 +2011,15 @@ namespace ts {
}
return _displayBuilder || (_displayBuilder = {
buildSymbolDisplay: buildSymbolDisplay,
buildTypeDisplay: buildTypeDisplay,
buildTypeParameterDisplay: buildTypeParameterDisplay,
buildParameterDisplay: buildParameterDisplay,
buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters,
buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters,
buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol,
buildSignatureDisplay: buildSignatureDisplay,
buildReturnTypeDisplay: buildReturnTypeDisplay
buildSymbolDisplay,
buildTypeDisplay,
buildTypeParameterDisplay,
buildParameterDisplay,
buildDisplayForParametersAndDelimiters,
buildDisplayForTypeParametersAndDelimiters,
buildTypeParameterDisplayFromSymbol,
buildSignatureDisplay,
buildReturnTypeDisplay
});
}
@@ -3517,7 +3534,19 @@ namespace ts {
}
function isOptionalParameter(node: ParameterDeclaration) {
return hasQuestionToken(node) || !!node.initializer;
if (hasQuestionToken(node)) {
return true;
}
if (node.initializer) {
let signatureDeclaration = <SignatureDeclaration>node.parent;
let signature = getSignatureFromDeclaration(signatureDeclaration);
let parameterIndex = signatureDeclaration.parameters.indexOf(node);
Debug.assert(parameterIndex >= 0);
return parameterIndex >= signature.minArgumentCount;
}
return false;
}
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
@@ -3535,11 +3564,16 @@ namespace ts {
if (param.type && param.type.kind === SyntaxKind.StringLiteral) {
hasStringLiterals = true;
}
if (minArgumentCount < 0) {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (minArgumentCount < 0) {
minArgumentCount = i;
}
}
else {
// If we see any required parameters, it means the prior ones were not in fact optional.
minArgumentCount = -1;
}
}
if (minArgumentCount < 0) {
@@ -3757,22 +3791,23 @@ namespace ts {
}
}
// This function is used to propagate widening flags when creating new object types references and union types.
// It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type
// of an object literal (since those types have widening related information we need to track).
function getWideningFlagsOfTypes(types: Type[]): TypeFlags {
// This function is used to propagate certain flags when creating new object type references and union types.
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
// of an object literal or the anyFunctionType. This is because there are operations in the type checker
// that care about the presence of such types at arbitrary depth in a containing type.
function getPropagatingFlagsOfTypes(types: Type[]): TypeFlags {
let result: TypeFlags = 0;
for (let type of types) {
result |= type.flags;
}
return result & TypeFlags.RequiresWidening;
return result & TypeFlags.PropagatingFlags;
}
function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference {
let id = getTypeListId(typeArguments);
let type = target.instantiations[id];
if (!type) {
let flags = TypeFlags.Reference | getWideningFlagsOfTypes(typeArguments);
let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes(typeArguments);
type = target.instantiations[id] = <TypeReference>createObjectType(flags, target.symbol);
type.target = target;
type.typeArguments = typeArguments;
@@ -4026,7 +4061,7 @@ namespace ts {
let id = getTypeListId(elementTypes);
let type = tupleTypes[id];
if (!type) {
type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getWideningFlagsOfTypes(elementTypes));
type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes));
type.elementTypes = elementTypes;
}
return type;
@@ -4175,7 +4210,7 @@ namespace ts {
let id = getTypeListId(typeSet);
let type = unionTypes[id];
if (!type) {
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet));
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes(typeSet));
type.types = typeSet;
}
return type;
@@ -4209,7 +4244,7 @@ namespace ts {
let id = getTypeListId(typeSet);
let type = intersectionTypes[id];
if (!type) {
type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet));
type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes(typeSet));
type.types = typeSet;
}
return type;
@@ -4364,11 +4399,11 @@ namespace ts {
return getInferredType(context, i);
}
}
return t;
return t;
};
mapper.context = context;
return mapper;
return mapper;
}
function identityMapper(type: Type): Type {
@@ -5216,7 +5251,7 @@ namespace ts {
return indexTypesIdenticalTo(IndexKind.String, source, target);
}
let targetType = getIndexTypeOfType(target, IndexKind.String);
if (targetType) {
if (targetType && !(targetType.flags & TypeFlags.Any)) {
let sourceType = getIndexTypeOfType(source, IndexKind.String);
if (!sourceType) {
if (reportErrors) {
@@ -5241,7 +5276,7 @@ namespace ts {
return indexTypesIdenticalTo(IndexKind.Number, source, target);
}
let targetType = getIndexTypeOfType(target, IndexKind.Number);
if (targetType) {
if (targetType && !(targetType.flags & TypeFlags.Any)) {
let sourceStringType = getIndexTypeOfType(source, IndexKind.String);
let sourceNumberType = getIndexTypeOfType(source, IndexKind.Number);
if (!(sourceStringType || sourceNumberType)) {
@@ -5656,11 +5691,17 @@ namespace ts {
}
function inferFromTypes(source: Type, target: Type) {
if (source === anyFunctionType) {
return;
}
if (target.flags & TypeFlags.TypeParameter) {
// If target is a type parameter, make an inference
// If target is a type parameter, make an inference, unless the source type contains
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
// it as an inference candidate. Hopefully, a better candidate will come along that does
// not contain anyFunctionType when we come back to this argument for its second round
// of inference.
if (source.flags & TypeFlags.ContainsAnyFunctionType) {
return;
}
let typeParameters = context.typeParameters;
for (let i = 0; i < typeParameters.length; i++) {
if (target === typeParameters[i]) {
@@ -7093,7 +7134,7 @@ namespace ts {
let stringIndexType = getIndexType(IndexKind.String);
let numberIndexType = getIndexType(IndexKind.Number);
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags);
return result;
function getIndexType(kind: IndexKind) {
@@ -7324,10 +7365,9 @@ namespace ts {
* For example, in the element <MyClass>, the element instance type is `MyClass` (not `typeof MyClass`).
*/
function getJsxElementInstanceType(node: JsxOpeningLikeElement) {
if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) {
// There is no such thing as an instance type for a non-class element
return undefined;
}
// There is no such thing as an instance type for a non-class element. This
// line shouldn't be hit.
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), 'Should not call getJsxElementInstanceType on non-class Element');
let classSymbol = getJsxElementTagSymbol(node);
if (classSymbol === unknownSymbol) {
@@ -7350,16 +7390,11 @@ namespace ts {
if (signatures.length === 0) {
// We found no signatures at all, which is an error
error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName));
return undefined;
return unknownType;
}
}
// Check that the constructor/factory returns an object type
let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s)));
if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) {
error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type);
return undefined;
}
let returnType = getUnionType(signatures.map(getReturnTypeOfSignature));
// Issue an error if this return type isn't assignable to JSX.ElementClass
let elemClassType = getJsxGlobalElementClassType();
@@ -7420,7 +7455,7 @@ namespace ts {
let elemInstanceType = getJsxElementInstanceType(node);
if (isTypeAny(elemInstanceType)) {
return links.resolvedJsxType = anyType;
return links.resolvedJsxType = elemInstanceType;
}
let propsName = getJsxElementPropertiesName();
@@ -10437,9 +10472,17 @@ namespace ts {
// TS 1.0 spec (April 2014): 8.3.2
// Constructors of classes with no extends clause may not contain super calls, whereas
// constructors of derived classes must contain at least one super call somewhere in their function body.
if (getClassExtendsHeritageClauseElement(<ClassDeclaration>node.parent)) {
let containingClassDecl = <ClassDeclaration>node.parent;
if (getClassExtendsHeritageClauseElement(containingClassDecl)) {
let containingClassSymbol = getSymbolOfNode(containingClassDecl);
let containingClassInstanceType = <InterfaceType>getDeclaredTypeOfSymbol(containingClassSymbol);
let baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType);
if (containsSuperCall(node.body)) {
if (baseConstructorType === nullType) {
error(node, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
}
// The first statement in the body of a constructor (excluding prologue directives) must be a super call
// if both of the following are true:
// - The containing class is a derived class.
@@ -10472,7 +10515,7 @@ namespace ts {
}
}
}
else {
else if (baseConstructorType !== nullType) {
error(node, Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
}
}
@@ -10863,9 +10906,6 @@ namespace ts {
return;
}
// Exports should be checked only if enclosing module contains both exported and non exported declarations.
// In case if all declarations are non-exported check is unnecessary.
// if localSymbol is defined on node then node itself is exported - check is required
let symbol = node.localSymbol;
if (!symbol) {
@@ -10885,27 +10925,45 @@ namespace ts {
// we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace
// to denote disjoint declarationSpaces (without making new enum type).
let exportedDeclarationSpaces: SymbolFlags = 0;
let nonExportedDeclarationSpaces: SymbolFlags = 0;
forEach(symbol.declarations, d => {
let exportedDeclarationSpaces = SymbolFlags.None;
let nonExportedDeclarationSpaces = SymbolFlags.None;
let defaultExportedDeclarationSpaces = SymbolFlags.None;
for (let d of symbol.declarations) {
let declarationSpaces = getDeclarationSpaces(d);
if (getEffectiveDeclarationFlags(d, NodeFlags.Export)) {
exportedDeclarationSpaces |= declarationSpaces;
let effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default);
if (effectiveDeclarationFlags & NodeFlags.Export) {
if (effectiveDeclarationFlags & NodeFlags.Default) {
defaultExportedDeclarationSpaces |= declarationSpaces;
}
else {
exportedDeclarationSpaces |= declarationSpaces;
}
}
else {
nonExportedDeclarationSpaces |= declarationSpaces;
}
});
}
let commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
// Spaces for anyting not declared a 'default export'.
let nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
let commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
let commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
if (commonDeclarationSpace) {
if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
// declaration spaces for exported and non-exported declarations intersect
forEach(symbol.declarations, d => {
if (getDeclarationSpaces(d) & commonDeclarationSpace) {
for (let d of symbol.declarations) {
let declarationSpaces = getDeclarationSpaces(d);
// Only error on the declarations that conributed to the intersecting spaces.
if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name));
}
else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(d.name));
}
});
}
}
function getDeclarationSpaces(d: Declaration): SymbolFlags {
@@ -12750,28 +12808,7 @@ namespace ts {
}
let initializer = member.initializer;
if (initializer) {
autoValue = getConstantValueForEnumMemberInitializer(initializer);
if (autoValue === undefined) {
if (enumIsConst) {
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
else if (!ambient) {
// Only here do we need to check that the initializer is assignable to the enum type.
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
// Also, we do not need to check this for ambients because there is already
// a syntax error if it is not a constant.
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
}
}
else if (enumIsConst) {
if (isNaN(autoValue)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN);
}
else if (!isFinite(autoValue)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
}
}
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
}
else if (ambient && !enumIsConst) {
autoValue = undefined;
@@ -12785,8 +12822,36 @@ namespace ts {
nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed;
}
function getConstantValueForEnumMemberInitializer(initializer: Expression): number {
return evalConstant(initializer);
function computeConstantValueForEnumMemberInitializer(initializer: Expression, enumType: Type, enumIsConst: boolean, ambient: boolean): number {
// Controls if error should be reported after evaluation of constant value is completed
// Can be false if another more precise error was already reported during evaluation.
let reportError = true;
let value = evalConstant(initializer);
if (reportError) {
if (value === undefined) {
if (enumIsConst) {
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
else if (!ambient) {
// Only here do we need to check that the initializer is assignable to the enum type.
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
// Also, we do not need to check this for ambients because there is already
// a syntax error if it is not a constant.
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
}
}
else if (enumIsConst) {
if (isNaN(value)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN);
}
else if (!isFinite(value)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
}
}
}
return value;
function evalConstant(e: Node): number {
switch (e.kind) {
@@ -12895,6 +12960,8 @@ namespace ts {
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
return undefined;
}
@@ -14376,6 +14443,7 @@ namespace ts {
getBlockScopedVariableId,
getReferencedValueDeclaration,
getTypeReferenceSerializationKind,
isOptionalParameter
};
}
@@ -14771,17 +14839,15 @@ namespace ts {
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
}
}
else if (parameter.questionToken || parameter.initializer) {
else if (parameter.questionToken) {
seenOptionalParameter = true;
if (parameter.questionToken && parameter.initializer) {
if (parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
}
}
else {
if (seenOptionalParameter) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
else if (seenOptionalParameter && !parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
}
}
+4 -1
View File
@@ -422,10 +422,13 @@ namespace ts {
if (json["files"] instanceof Array) {
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
}
else {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, 'files', 'Array'));
}
}
else {
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
for (let i = 0; i < sysFiles.length; i++) {
let name = sysFiles[i];
if (fileExtensionIs(name, ".d.ts")) {
+1 -1
View File
@@ -1371,7 +1371,7 @@ namespace ts {
else {
writeTextOfNode(currentSourceFile, node.name);
}
if (node.initializer || hasQuestionToken(node)) {
if (resolver.isOptionalParameter(node)) {
write("?");
}
decreaseIndent();
@@ -294,7 +294,7 @@ namespace ts {
Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." },
Duplicate_function_implementation: { code: 2393, category: DiagnosticCategory.Error, key: "Duplicate function implementation." },
Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." },
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." },
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." },
Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." },
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." },
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." },
@@ -425,6 +425,8 @@ namespace ts {
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -509,7 +511,6 @@ namespace ts {
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." },
Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." },
Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." },
Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." },
@@ -614,5 +615,6 @@ namespace ts {
Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." },
JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." },
Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." },
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" },
};
}
+14 -6
View File
@@ -1,4 +1,4 @@
{
{
"Unterminated string literal.": {
"category": "Error",
"code": 1002
@@ -1165,7 +1165,7 @@
"category": "Error",
"code": 2394
},
"Individual declarations in merged declaration {0} must be all exported or all local.": {
"Individual declarations in merged declaration '{0}' must be all exported or all local.": {
"category": "Error",
"code": 2395
},
@@ -1689,6 +1689,14 @@
"category": "Error",
"code": 2650
},
"A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": {
"category": "Error",
"code": 2651
},
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@@ -2025,10 +2033,6 @@
"category": "Error",
"code": 5042
},
"Option 'sourceMap' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5043
},
"Option 'declaration' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5044
@@ -2449,5 +2453,9 @@
"Cannot use JSX unless the '--jsx' flag is provided.": {
"category": "Error",
"code": 17004
},
"A constructor cannot contain a 'super' call when its class extends 'null'": {
"category": "Error",
"code": 17005
}
}
+12 -2
View File
@@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.IfStatement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxSpreadAttribute:
case SyntaxKind.JsxExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ParenthesizedExpression:
@@ -4866,6 +4867,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitSerializedTypeNode(node: TypeNode) {
if (!node) {
return;
}
switch (node.kind) {
case SyntaxKind.VoidKeyword:
write("void 0");
@@ -5032,7 +5037,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
if (node && isFunctionLike(node)) {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
@@ -6474,7 +6479,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case JsxEmit.Preserve:
default: // Emit JSX-preserve as default when no --jsx flag is specified
write(getTextOfNode(node, true));
writer.writeLiteral(getTextOfNode(node, true));
break;
}
}
@@ -6841,6 +6846,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return leadingComments;
}
/**
* Removes all but the pinned or triple slash comments.
* @param ranges The array to be filtered
* @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
*/
function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] {
// If we're removing comments, then we want to strip out all but the pinned or
// triple slash comments.
-4
View File
@@ -602,10 +602,6 @@ namespace ts {
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.sourceMap) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules));
}
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules));
}
+1 -1
View File
@@ -3,7 +3,7 @@
namespace ts {
export interface SourceFile {
fileWatcher: FileWatcher;
fileWatcher?: FileWatcher;
}
/**
+9 -3
View File
@@ -1431,6 +1431,7 @@ namespace ts {
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
getJsxIntrinsicTagNames(): Symbol[];
isOptionalParameter(node: ParameterDeclaration): boolean;
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
@@ -1574,7 +1575,8 @@ namespace ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
getBlockScopedVariableId(node: Identifier): number;
getReferencedValueDeclaration(reference: Identifier): Declaration;
getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind;
getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind;
isOptionalParameter(node: ParameterDeclaration): boolean;
}
export const enum SymbolFlags {
@@ -1768,7 +1770,9 @@ namespace ts {
ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type
/* @internal */
ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type
ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6
/* @internal */
ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@@ -1780,7 +1784,9 @@ namespace ts {
UnionOrIntersection = Union | Intersection,
StructuredType = ObjectType | Union | Intersection,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
/* @internal */
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
}
// Properties common to all types
+1 -3
View File
@@ -988,15 +988,13 @@ namespace ts {
if (node) {
switch (node.kind) {
case SyntaxKind.Parameter:
return (<ParameterDeclaration>node).questionToken !== undefined;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return (<MethodDeclaration>node).questionToken !== undefined;
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return (<PropertyDeclaration>node).questionToken !== undefined;
return (<ParameterDeclaration | MethodDeclaration | PropertyDeclaration>node).questionToken !== undefined;
}
}
+28
View File
@@ -2488,6 +2488,17 @@ module FourSlash {
}
}
// @Filename is the only directive that can be used in a test that contains tsconfig.json file.
if (containTSConfigJson(files)) {
let directive = getNonFileNameOptionInFileList(files);
if (!directive) {
directive = getNonFileNameOptionInObject(globalOptions);
}
if (directive) {
throw Error("It is not allowed to use tsconfig.json along with directive '" + directive + "'");
}
}
return {
markerPositions,
markers,
@@ -2497,6 +2508,23 @@ module FourSlash {
};
}
function containTSConfigJson(files: FourSlashFile[]): boolean {
return ts.forEach(files, f => f.fileOptions['Filename'] === 'tsconfig.json');
}
function getNonFileNameOptionInFileList(files: FourSlashFile[]): string {
return ts.forEach(files, f => getNonFileNameOptionInObject(f.fileOptions));
}
function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string {
for (let option in optionObject) {
if (option !== metadataOptionNames.fileName) {
return option;
}
}
return undefined;
}
const enum State {
none,
inSlashStarMarker,
+3 -3
View File
@@ -493,7 +493,7 @@ module Harness {
export let readFile: typeof IO.readFile = ts.sys.readFile;
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
export let fileExists: typeof IO.fileExists = fs.existsSync;
export let log: typeof IO.log = console.log;
export let log: typeof IO.log = s => console.log(s);
export function createDirectory(path: string) {
if (!directoryExists(path)) {
@@ -673,7 +673,7 @@ module Harness {
};
export let listFiles = Utils.memoize(_listFilesImpl);
export let log = console.log;
export let log = (s: string) => console.log(s);
export function readFile(file: string) {
let response = Http.getFileFromServerSync(serverRoot + file);
@@ -1451,7 +1451,7 @@ module Harness {
}
export function isJSMap(fileName: string) {
return stringEndsWith(fileName, '.js.map');
return stringEndsWith(fileName, '.js.map') || stringEndsWith(fileName, '.jsx.map');
}
/** Contains the code and errors of a compilation and some helper methods to check its status. */
+2 -4
View File
@@ -803,9 +803,6 @@ namespace ts.server {
} else {
this.log("no config file");
}
if (configFileName) {
configFileName = getAbsolutePath(configFileName, searchPath);
}
if (configFileName && (!this.configProjectIsActive(configFileName))) {
var configResult = this.openConfigFile(configFileName, fileName);
if (!configResult.success) {
@@ -910,7 +907,8 @@ namespace ts.server {
configFilename = ts.normalizePath(configFilename);
// file references will be relative to dirPath (or absolute)
var dirPath = ts.getDirectoryPath(configFilename);
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.readConfigFile(configFilename);
var contents = this.host.readFile(configFilename)
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents);
if (rawConfig.error) {
return rawConfig.error;
}
+60 -28
View File
@@ -261,26 +261,25 @@ namespace ts {
}
public getFirstToken(sourceFile?: SourceFile): Node {
let children = this.getChildren();
for (let child of children) {
if (child.kind < SyntaxKind.FirstNode) {
return child;
}
return child.getFirstToken(sourceFile);
let children = this.getChildren(sourceFile);
if (!children.length) {
return undefined;
}
let child = children[0];
return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile);
}
public getLastToken(sourceFile?: SourceFile): Node {
let children = this.getChildren(sourceFile);
for (let i = children.length - 1; i >= 0; i--) {
let child = children[i];
if (child.kind < SyntaxKind.FirstNode) {
return child;
}
return child.getLastToken(sourceFile);
let child = lastOrUndefined(children);
if (!child) {
return undefined;
}
return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile);
}
}
@@ -1767,18 +1766,31 @@ namespace ts {
sourceFile.version = version;
sourceFile.scriptSnapshot = scriptSnapshot;
}
export interface TranspileOptions {
compilerOptions?: CompilerOptions;
fileName?: string;
reportDiagnostics?: boolean;
moduleName?: string;
}
export interface TranspileOutput {
outputText: string;
diagnostics?: Diagnostic[];
sourceMapText?: string;
}
/*
* This function will compile source text from 'input' argument using specified compiler options.
* If not options are provided - it will use a set of default compiler options.
* Extra compiler options that will unconditionally be used bu this function are:
* Extra compiler options that will unconditionally be used by this function are:
* - isolatedModules = true
* - allowNonTsExtensions = true
* - noLib = true
* - noResolve = true
*/
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string {
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
*/
export function transpileModule(input: string, transpileOptions?: TranspileOptions): TranspileOutput {
let options = transpileOptions.compilerOptions ? clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions();
options.isolatedModules = true;
@@ -1794,23 +1806,30 @@ namespace ts {
options.noResolve = true;
// Parse
let inputFileName = fileName || "module.ts";
let inputFileName = transpileOptions.fileName || "module.ts";
let sourceFile = createSourceFile(inputFileName, input, options.target);
if (moduleName) {
sourceFile.moduleName = moduleName;
if (transpileOptions.moduleName) {
sourceFile.moduleName = transpileOptions.moduleName;
}
let newLine = getNewLineCharacter(options);
// Output
let outputText: string;
let sourceMapText: string;
// Create a compilerHost object to allow the compiler to read and write files
let compilerHost: CompilerHost = {
getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined,
writeFile: (name, text, writeByteOrderMark) => {
Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name);
outputText = text;
if (fileExtensionIs(name, ".map")) {
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);
sourceMapText = text;
}
else {
Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name);
outputText = text;
}
},
getDefaultLibFileName: () => "lib.d.ts",
useCaseSensitiveFileNames: () => false,
@@ -1820,16 +1839,29 @@ namespace ts {
};
let program = createProgram([inputFileName], options, compilerHost);
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
let diagnostics: Diagnostic[];
if (transpileOptions.reportDiagnostics) {
diagnostics = [];
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
}
// Emit
program.emit();
Debug.assert(outputText !== undefined, "Output generation failed");
return outputText;
return { outputText, diagnostics, sourceMapText };
}
/*
* This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result.
*/
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string {
let output = transpileModule(input, { compilerOptions, fileName, reportDiagnostics: !!diagnostics, moduleName });
// addRange correctly handles cases when wither 'from' or 'to' argument is missing
addRange(diagnostics, output.diagnostics);
return output.outputText;
}
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
+1 -3
View File
@@ -611,13 +611,11 @@ namespace ts.SignatureHelp {
let displayParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
let isOptional = hasQuestionToken(parameter.valueDeclaration);
return {
name: parameter.name,
documentation: parameter.getDocumentationComment(),
displayParts,
isOptional
isOptional: typeChecker.isOptionalParameter(<ParameterDeclaration>parameter.valueDeclaration)
};
}
@@ -1,18 +1,21 @@
tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type '{ one: number; }'.
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ====
var x = {one: 1};
var y: {[index:string]: any};
x = y;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
~
!!! error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: string]: any; }'.
y = x;
y = x; // Ok because index signature type is any
x = z; // Error
~
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type '{ one: number; }'.
!!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'.
z = x; // Ok because index signature type is any
+13 -7
View File
@@ -1,12 +1,18 @@
//// [assignmentCompat1.ts]
var x = {one: 1};
var y: {[index:string]: any};
x = y;
y = x;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
//// [assignmentCompat1.js]
var x = { one: 1 };
var y;
x = y;
y = x;
var z;
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
@@ -1,17 +0,0 @@
tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability36.ts (1 errors) ====
module __test1__ {
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
export var __val__obj4 = obj4;
}
module __test2__ {
export var aa:{[index:string]:any;};;
export var __val__aa = aa;
}
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -0,0 +1,39 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 58))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>two : Symbol(two, Decl(assignmentCompatability36.ts, 1, 66))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 139))
export var __val__obj4 = obj4;
>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
}
module __test2__ {
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
export var aa:{[index:string]:any;};;
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
>index : Symbol(index, Decl(assignmentCompatability36.ts, 5, 20))
export var __val__aa = aa;
>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
@@ -0,0 +1,42 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : typeof __test1__
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>T : T
>U : U
>one : T
>T : T
>two : U
>U : U
>obj4 : interfaceWithPublicAndOptional<number, string>
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>{ one: 1 } : { one: number; }
>one : number
>1 : number
export var __val__obj4 = obj4;
>__val__obj4 : interfaceWithPublicAndOptional<number, string>
>obj4 : interfaceWithPublicAndOptional<number, string>
}
module __test2__ {
>__test2__ : typeof __test2__
export var aa:{[index:string]:any;};;
>aa : { [index: string]: any; }
>index : string
export var __val__aa = aa;
>__val__aa : { [index: string]: any; }
>aa : { [index: string]: any; }
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test2__.__val__aa : { [index: string]: any; }
>__test2__ : typeof __test2__
>__val__aa : { [index: string]: any; }
>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test1__ : typeof __test1__
>__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
@@ -0,0 +1,21 @@
tests/cases/compiler/classExtendsNull.ts(2,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
==== tests/cases/compiler/classExtendsNull.ts (1 errors) ====
class C extends null {
constructor() {
~~~~~~~~~~~~~~~
super();
~~~~~~~~~~~~~~~~
return Object.create(null);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~
!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
}
class D extends null {
constructor() {
return Object.create(null);
}
}
@@ -0,0 +1,35 @@
//// [classExtendsNull.ts]
class C extends null {
constructor() {
super();
return Object.create(null);
}
}
class D extends null {
constructor() {
return Object.create(null);
}
}
//// [classExtendsNull.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.call(this);
return Object.create(null);
}
return C;
})(null);
var D = (function (_super) {
__extends(D, _super);
function D() {
return Object.create(null);
}
return D;
})(null);
@@ -1,6 +1,6 @@
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
@@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
// forward reference to the element of the same enum
X = Y,
~
!!! error TS2474: In 'const' enum declarations member initializer must be constant expression.
!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
// forward reference to the element of the same enum
Y = E1.Z,
~~~~
@@ -0,0 +1,31 @@
//// [decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts]
declare var decorator: any;
class MyClass {
constructor(test: string, test2: number) {
}
@decorator
doSomething() {
}
}
//// [decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js]
var MyClass = (function () {
function MyClass(test, test2) {
}
MyClass.prototype.doSomething = function () {
};
Object.defineProperty(MyClass.prototype, "doSomething",
__decorate([
decorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', []),
__metadata('design:returntype', void 0)
], MyClass.prototype, "doSomething", Object.getOwnPropertyDescriptor(MyClass.prototype, "doSomething")));
return MyClass;
})();
@@ -0,0 +1,23 @@
=== tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts ===
declare var decorator: any;
>decorator : Symbol(decorator, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 11))
class MyClass {
>MyClass : Symbol(MyClass, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 27))
constructor(test: string, test2: number) {
>test : Symbol(test, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 4, 16))
>test2 : Symbol(test2, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 4, 29))
}
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 11))
doSomething() {
>doSomething : Symbol(doSomething, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 6, 5))
}
}
@@ -0,0 +1,23 @@
=== tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts ===
declare var decorator: any;
>decorator : any
class MyClass {
>MyClass : MyClass
constructor(test: string, test2: number) {
>test : string
>test2 : number
}
@decorator
>decorator : any
doSomething() {
>doSomething : () => void
}
}
@@ -0,0 +1,49 @@
tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'.
tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does not exist on type '() => number'.
==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ====
export default function Decl() {
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
return 0;
}
export interface Decl {
p1: number;
p2: number;
}
export namespace Decl {
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
export var x = 10;
export var y = 20;
interface I {
}
}
==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ====
import Entity from "m1"
Entity();
var x: Entity;
~~~~~~
!!! error TS2304: Cannot find name 'Entity'.
var y: Entity.I;
~~~~~~
!!! error TS2503: Cannot find namespace 'Entity'.
Entity.x;
~
!!! error TS2339: Property 'x' does not exist on type '() => number'.
Entity.y;
~
!!! error TS2339: Property 'y' does not exist on type '() => number'.
@@ -0,0 +1,50 @@
//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts] ////
//// [m1.ts]
export default function Decl() {
return 0;
}
export interface Decl {
p1: number;
p2: number;
}
export namespace Decl {
export var x = 10;
export var y = 20;
interface I {
}
}
//// [m2.ts]
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
Entity.x;
Entity.y;
//// [m1.js]
function Decl() {
return 0;
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Decl;
var Decl;
(function (Decl) {
Decl.x = 10;
Decl.y = 20;
})(Decl = exports.Decl || (exports.Decl = {}));
//// [m2.js]
var m1_1 = require("m1");
m1_1.default();
var x;
var y;
m1_1.default.x;
m1_1.default.y;
@@ -0,0 +1,44 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'.
tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'.
==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ====
export default class Decl {
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
}
export interface Decl {
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
p1: number;
p2: number;
}
export namespace Decl {
interface I {
}
}
==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ====
import Entity from "m1"
Entity();
~~~~~~~~
!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
var x: Entity;
var y: Entity.I;
~~~~~~
!!! error TS2503: Cannot find namespace 'Entity'.
var z = new Entity();
var sum = z.p1 + z.p2
~~
!!! error TS2339: Property 'p1' does not exist on type 'Decl'.
~~
!!! error TS2339: Property 'p2' does not exist on type 'Decl'.
@@ -0,0 +1,42 @@
//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts] ////
//// [m1.ts]
export default class Decl {
}
export interface Decl {
p1: number;
p2: number;
}
export namespace Decl {
interface I {
}
}
//// [m2.ts]
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
var z = new Entity();
var sum = z.p1 + z.p2
//// [m1.js]
var Decl = (function () {
function Decl() {
}
return Decl;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Decl;
//// [m2.js]
var m1_1 = require("m1");
m1_1.default();
var x;
var y;
var z = new m1_1.default();
var sum = z.p1 + z.p2;
@@ -0,0 +1,47 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'.
tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'.
==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ====
export default class Decl {
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
}
interface Decl {
~~~~
!!! error TS2518: Only an ambient class can be merged with an interface.
~~~~
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
p1: number;
p2: number;
}
namespace Decl {
interface I {
}
}
==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ====
import Entity from "m1"
Entity();
~~~~~~~~
!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
var x: Entity;
var y: Entity.I;
~~~~~~
!!! error TS2503: Cannot find namespace 'Entity'.
var z = new Entity();
var sum = z.p1 + z.p2
~~
!!! error TS2339: Property 'p1' does not exist on type 'Decl'.
~~
!!! error TS2339: Property 'p2' does not exist on type 'Decl'.
@@ -0,0 +1,42 @@
//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts] ////
//// [m1.ts]
export default class Decl {
}
interface Decl {
p1: number;
p2: number;
}
namespace Decl {
interface I {
}
}
//// [m2.ts]
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
var z = new Entity();
var sum = z.p1 + z.p2
//// [m1.js]
var Decl = (function () {
function Decl() {
}
return Decl;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Decl;
//// [m2.js]
var m1_1 = require("m1");
m1_1.default();
var x;
var y;
var z = new m1_1.default();
var sum = z.p1 + z.p2;
@@ -0,0 +1,28 @@
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(2,25): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(5,11): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(9,11): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(12,18): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
==== tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts (4 errors) ====
export default function Foo() {
~~~
!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
}
namespace Foo {
~~~
!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
export var x;
}
interface Foo {
~~~
!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
}
export interface Foo {
~~~
!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
}
@@ -0,0 +1,23 @@
//// [defaultExportsCannotMerge04.ts]
export default function Foo() {
}
namespace Foo {
export var x;
}
interface Foo {
}
export interface Foo {
}
//// [defaultExportsCannotMerge04.js]
function Foo() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Foo;
var Foo;
(function (Foo) {
})(Foo || (Foo = {}));
@@ -1,21 +1,21 @@
tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration I must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration I must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration E must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration E must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration inst must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration inst must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration v must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration v must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration w must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration w must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration F must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged
tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration F must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration C must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration C must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration C must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration D must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration D must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local.
tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local.
==== tests/cases/compiler/duplicateSymbolsExportMatching.ts (18 errors) ====
@@ -44,28 +44,28 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind
module N2 {
interface I { }
~
!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local.
export interface I { } // error
~
!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local.
export interface E { }
~
!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local.
interface E { } // error
~
!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local.
}
// Should report error only once for instantiated module
module M {
module inst {
~~~~
!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local.
var t;
}
export module inst { // one error
~~~~
!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local.
var t;
}
}
@@ -74,41 +74,41 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind
module M2 {
var v: string;
~
!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local.
export var v: string; // one error (visibility)
~
!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local.
var w: number;
~
!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local.
export var w: string; // two errors (visibility and type mismatch)
~
!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local.
}
module M {
module F {
~
!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local.
~
!!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged
var t;
}
export function F() { } // Only one error for duplicate identifier (don't consider visibility)
~
!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local.
}
module M {
class C { }
~
!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
module C { }
~
!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol)
~
!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local.
var t;
}
}
@@ -116,7 +116,7 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind
// Top level
interface D { }
~
!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local.
export interface D { }
~
!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local.
@@ -1,10 +1,9 @@
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(1,9): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(2,8): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(4,5): error TS1048: A rest parameter cannot have an initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016: A required parameter cannot follow an optional parameter.
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (4 errors) ====
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (3 errors) ====
(arg1?, arg2) => 101;
~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
@@ -16,7 +15,5 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016
~~~
!!! error TS1048: A rest parameter cannot have an initializer.
// Non optional parameter following an optional one
(arg1 = 1, arg2) => 1;
~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
@@ -4,7 +4,7 @@
(...arg) => 103;
(...arg:number [] = []) => 104;
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
//// [fatarrowfunctionsOptionalArgsErrors1.js]
@@ -30,7 +30,7 @@
}
return 104;
});
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(function (arg1, arg2) {
if (arg1 === void 0) { arg1 = 1; }
return 1;
@@ -1,14 +1,13 @@
tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ====
interface Red {
[n:number]; // ok
~~~~~~~~~~~
@@ -37,8 +36,6 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
interface Green {
[n:number]: Orange; // error
~~~~~~~~~~~~~~~~~~~
!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
[s:string]: Yellow; // ok
}
@@ -13,7 +13,7 @@ function foo<T extends { m(p: string): number }>(x: T): T {
}
foo({ m(x) { return x.length } });
>foo({ m(x) { return x.length } }) : { }
>foo({ m(x) { return x.length } }) : { m(x: string): number; }
>foo : <T extends { m(p: string): number; }>(x: T) => T
>{ m(x) { return x.length } } : { m(x: string): number; }
>m : (x: string) => number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType1.ts]
function f<T extends { "0": (p1: number) => number }>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType1.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType1.ts ===
function f<T extends { "0": (p1: number) => number }>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType1.ts, 0, 29))
>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType1.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType1.ts ===
function f<T extends { "0": (p1: number) => number }>(p: T): T {
>f : <T extends { "0": (p1: number) => number; }>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : [(x: number) => number]
>f([x => x]) : [(x: number) => number]
>f : <T extends { "0": (p1: number) => number; }>(p: T) => T
>[x => x] : [(x: number) => number]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType2.ts]
function f<T extends [(p1: number) => number]>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType2.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType2.ts ===
function f<T extends [(p1: number) => number]>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType2.ts, 0, 23))
>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType2.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType2.ts ===
function f<T extends [(p1: number) => number]>(p: T): T {
>f : <T extends [(p1: number) => number]>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : [(x: number) => number]
>f([x => x]) : [(x: number) => number]
>f : <T extends [(p1: number) => number]>(p: T) => T
>[x => x] : [(x: number) => number]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType3.ts]
function f<T extends ((p1: number) => number)[]>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType3.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType3.ts ===
function f<T extends ((p1: number) => number)[]>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType3.ts, 0, 23))
>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType3.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType3.ts ===
function f<T extends ((p1: number) => number)[]>(p: T): T {
>f : <T extends ((p1: number) => number)[]>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : ((x: number) => number)[]
>f([x => x]) : ((x: number) => number)[]
>f : <T extends ((p1: number) => number)[]>(p: T) => T
>[x => x] : ((x: number) => number)[]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType4.ts]
function f<T extends (p1: number) => number>(p: T): T {
return p;
}
var v = f(x => x);
//// [inferringAnyFunctionType4.js]
function f(p) {
return p;
}
var v = f(function (x) { return x; });
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType4.ts ===
function f<T extends (p1: number) => number>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType4.ts, 0, 22))
>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45))
}
var v = f(x => x);
>v : Symbol(v, Decl(inferringAnyFunctionType4.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10))
>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10))
@@ -0,0 +1,21 @@
=== tests/cases/compiler/inferringAnyFunctionType4.ts ===
function f<T extends (p1: number) => number>(p: T): T {
>f : <T extends (p1: number) => number>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f(x => x);
>v : (x: number) => number
>f(x => x) : (x: number) => number
>f : <T extends (p1: number) => number>(p: T) => T
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType5.ts]
function f<T extends { q: (p1: number) => number }>(p: T): T {
return p;
}
var v = f({ q: x => x });
//// [inferringAnyFunctionType5.js]
function f(p) {
return p;
}
var v = f({ q: function (x) { return x; } });
@@ -0,0 +1,21 @@
=== tests/cases/compiler/inferringAnyFunctionType5.ts ===
function f<T extends { q: (p1: number) => number }>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 0, 22))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType5.ts, 0, 27))
>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52))
}
var v = f({ q: x => x });
>v : Symbol(v, Decl(inferringAnyFunctionType5.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0))
>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14))
>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14))
@@ -0,0 +1,24 @@
=== tests/cases/compiler/inferringAnyFunctionType5.ts ===
function f<T extends { q: (p1: number) => number }>(p: T): T {
>f : <T extends { q: (p1: number) => number; }>(p: T) => T
>T : T
>q : (p1: number) => number
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f({ q: x => x });
>v : { q: (x: number) => number; }
>f({ q: x => x }) : { q: (x: number) => number; }
>f : <T extends { q: (p1: number) => number; }>(p: T) => T
>{ q: x => x } : { q: (x: number) => number; }
>q : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
@@ -1,7 +1,7 @@
tests/cases/compiler/innerModExport2.ts(5,5): error TS2304: Cannot find name 'module'.
tests/cases/compiler/innerModExport2.ts(5,12): error TS1005: ';' expected.
tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local.
tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local.
tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExportFunc' does not exist on type 'typeof Outer'.
@@ -18,7 +18,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport
var non_export_var = 0;
export var export_var = 1;
~~~~~~~~~~
!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
function NonExportFunc() { return 0; }
@@ -26,7 +26,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport
}
var export_var: number;
~~~~~~~~~~
!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
export var outer_var_export = 0;
export function outerFuncExport() { return 0; }
@@ -29,15 +29,7 @@ tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not
tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'.
tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(141,5): error TS2322: Type 'Object' is not assignable to type 'i4'.
Index signature is missing in type 'Object'.
tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(143,5): error TS2322: Type 'Base' is not assignable to type 'i4'.
Index signature is missing in type 'Base'.
tests/cases/compiler/intTypeCheck.ts(145,5): error TS2322: Type '() => void' is not assignable to type 'i4'.
Index signature is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'.
tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@@ -73,21 +65,13 @@ tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not
tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'.
tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(197,5): error TS2322: Type 'Object' is not assignable to type 'i8'.
Index signature is missing in type 'Object'.
tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(199,5): error TS2322: Type 'Base' is not assignable to type 'i8'.
Index signature is missing in type 'Base'.
tests/cases/compiler/intTypeCheck.ts(201,5): error TS2322: Type '() => void' is not assignable to type 'i8'.
Index signature is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'.
tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
==== tests/cases/compiler/intTypeCheck.ts (69 errors) ====
==== tests/cases/compiler/intTypeCheck.ts (61 errors) ====
interface i1 {
//Property Signatures
p;
@@ -287,27 +271,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj33: i4;
var obj34: i4 = {};
var obj35: i4 = new Object();
~~~~~
!!! error TS2322: Type 'Object' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Object'.
var obj36: i4 = new obj33;
~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj37: i4 = new Base;
~~~~~
!!! error TS2322: Type 'Base' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Base'.
var obj38: i4 = null;
var obj39: i4 = function () { };
~~~~~
!!! error TS2322: Type '() => void' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type '() => void'.
//var obj40: i4 = function foo() { };
var obj41: i4 = <i4> anyVar;
var obj42: i4 = new <i4> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@@ -421,27 +393,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj77: i8;
var obj78: i8 = {};
var obj79: i8 = new Object();
~~~~~
!!! error TS2322: Type 'Object' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Object'.
var obj80: i8 = new obj77;
~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj81: i8 = new Base;
~~~~~
!!! error TS2322: Type 'Base' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Base'.
var obj82: i8 = null;
var obj83: i8 = function () { };
~~~~~
!!! error TS2322: Type '() => void' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type '() => void'.
//var obj84: i8 = function foo() { };
var obj85: i8 = <i8> anyVar;
var obj86: i8 = new <i8> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@@ -1,7 +0,0 @@
error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'.
!!! error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'.
==== tests/cases/compiler/isolatedModulesSourceMap.ts (0 errors) ====
export var x;
@@ -1,7 +1,7 @@
//// [isolatedModulesSourceMap.ts]
export var x;
export var x = 1;
//// [isolatedModulesSourceMap.js]
export var x;
export var x = 1;
//# sourceMappingURL=isolatedModulesSourceMap.js.map
@@ -1,2 +1,2 @@
//// [isolatedModulesSourceMap.js.map]
{"version":3,"file":"isolatedModulesSourceMap.js","sourceRoot":"","sources":["isolatedModulesSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,CAAC"}
{"version":3,"file":"isolatedModulesSourceMap.js","sourceRoot":"","sources":["isolatedModulesSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,GAAG,CAAC,CAAC"}
@@ -8,20 +8,26 @@ sources: isolatedModulesSourceMap.ts
emittedFile:tests/cases/compiler/isolatedModulesSourceMap.js
sourceFile:isolatedModulesSourceMap.ts
-------------------------------------------------------------------
>>>export var x;
>>>export var x = 1;
1 >
2 >^^^^^^^^^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
4 > ^^^
5 > ^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >export var
3 > x
4 > ;
4 > =
5 > 1
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
3 >Emitted(1, 13) Source(2, 13) + SourceIndex(0)
4 >Emitted(1, 14) Source(2, 14) + SourceIndex(0)
4 >Emitted(1, 16) Source(2, 16) + SourceIndex(0)
5 >Emitted(1, 17) Source(2, 17) + SourceIndex(0)
6 >Emitted(1, 18) Source(2, 18) + SourceIndex(0)
---
>>>//# sourceMappingURL=isolatedModulesSourceMap.js.map
@@ -0,0 +1,5 @@
=== tests/cases/compiler/isolatedModulesSourceMap.ts ===
export var x = 1;
>x : Symbol(x, Decl(isolatedModulesSourceMap.ts, 1, 10))
@@ -0,0 +1,6 @@
=== tests/cases/compiler/isolatedModulesSourceMap.ts ===
export var x = 1;
>x : number
>1 : number
@@ -0,0 +1,27 @@
tests/cases/compiler/consumer.tsx(5,17): error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures.
==== tests/cases/compiler/consumer.tsx (1 errors) ====
/// <reference path="component.d.ts" />
import BaseComponent = require('BaseComponent');
class TestComponent extends React.Component<any, {}> {
render() {
return <BaseComponent />;
~~~~~~~~~~~~~
!!! error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures.
}
}
==== tests/cases/compiler/component.d.ts (0 errors) ====
declare module JSX {
interface ElementAttributesProperty { props; }
}
declare module React {
class Component<T, U> { }
}
declare module "BaseComponent" {
var base: React.Component<any, {}>;
export = base;
}
+43
View File
@@ -0,0 +1,43 @@
//// [tests/cases/compiler/jsxViaImport.tsx] ////
//// [component.d.ts]
declare module JSX {
interface ElementAttributesProperty { props; }
}
declare module React {
class Component<T, U> { }
}
declare module "BaseComponent" {
var base: React.Component<any, {}>;
export = base;
}
//// [consumer.tsx]
/// <reference path="component.d.ts" />
import BaseComponent = require('BaseComponent');
class TestComponent extends React.Component<any, {}> {
render() {
return <BaseComponent />;
}
}
//// [consumer.jsx]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/// <reference path="component.d.ts" />
var BaseComponent = require('BaseComponent');
var TestComponent = (function (_super) {
__extends(TestComponent, _super);
function TestComponent() {
_super.apply(this, arguments);
}
TestComponent.prototype.render = function () {
return <BaseComponent />;
};
return TestComponent;
})(React.Component);
@@ -0,0 +1,31 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2300: Duplicate identifier 'foo'.
tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2300: Duplicate identifier 'bar'.
tests/cases/conformance/es6/modules/m1.ts(11,1): error TS2300: Duplicate identifier 'default'.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'?
==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ====
export default class foo {
~~~
!!! error TS2300: Duplicate identifier 'foo'.
}
export default function bar() {
~~~
!!! error TS2300: Duplicate identifier 'bar'.
}
var x = 10;
export default x;
~~~~~~~~~~~~~~~~~
!!! error TS2300: Duplicate identifier 'default'.
==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ====
import Entity from "m1"
Entity();
~~~~~~~~
!!! error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'?
@@ -0,0 +1,38 @@
//// [tests/cases/conformance/es6/modules/multipleDefaultExports01.ts] ////
//// [m1.ts]
export default class foo {
}
export default function bar() {
}
var x = 10;
export default x;
//// [m2.ts]
import Entity from "m1"
Entity();
//// [m1.js]
var foo = (function () {
function foo() {
}
return foo;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = foo;
function bar() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bar;
var x = 10;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x;
//// [m2.js]
var m1_1 = require("m1");
m1_1.default();
@@ -0,0 +1,22 @@
tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2393: Duplicate function implementation.
tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate function implementation.
==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ====
export default function foo() {
~~~
!!! error TS2393: Duplicate function implementation.
}
export default function bar() {
~~~
!!! error TS2393: Duplicate function implementation.
}
==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ====
import Entity from "m1"
Entity();
@@ -0,0 +1,29 @@
//// [tests/cases/conformance/es6/modules/multipleDefaultExports02.ts] ////
//// [m1.ts]
export default function foo() {
}
export default function bar() {
}
//// [m2.ts]
import Entity from "m1"
Entity();
//// [m1.js]
function foo() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = foo;
function bar() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bar;
//// [m2.js]
var m1_1 = require("m1");
m1_1.default();
@@ -1,5 +1,5 @@
tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local.
tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local.
tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local.
tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local.
==== tests/cases/compiler/multivar.ts (2 errors) ====
@@ -10,7 +10,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in
export var a, b2: number = 10, b;
~~
!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local.
var m1;
var a2, b22: number = 10, b222;
var m3;
@@ -28,7 +28,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in
declare var d1, d2;
var b2;
~~
!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local.
!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local.
declare var v1;
}
@@ -1,6 +1,6 @@
tests/cases/compiler/optionalParamArgsTest.ts(31,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(35,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(35,47): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/compiler/optionalParamArgsTest.ts(34,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(99,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(100,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(101,1): error TS2346: Supplied parameters do not match any signature of call target.
@@ -20,10 +20,9 @@ tests/cases/compiler/optionalParamArgsTest.ts(114,1): error TS2346: Supplied par
tests/cases/compiler/optionalParamArgsTest.ts(115,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(116,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/optionalParamArgsTest.ts (23 errors) ====
==== tests/cases/compiler/optionalParamArgsTest.ts (22 errors) ====
// Optional parameter and default argument tests
// Key:
@@ -58,13 +57,10 @@ tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied par
~~~~
!!! error TS2393: Duplicate function implementation.
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
~~~~
!!! error TS2393: Duplicate function implementation.
~~~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
}
class C2 extends C1 {
@@ -31,8 +31,7 @@ class C1 {
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; }
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
}
@@ -152,8 +151,7 @@ var C1 = (function () {
if (C1M5A2 === void 0) { C1M5A2 = 0; }
return C1M5A1 + C1M5A2;
};
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
C1.prototype.C1M5 = function (C1M5A1, C1M5A2, C1M5A3) {
if (C1M5A2 === void 0) { C1M5A2 = 0; }
return C1M5A1 + C1M5A2;
@@ -0,0 +1,28 @@
tests/cases/compiler/requiredInitializedParameter1.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/requiredInitializedParameter1.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/requiredInitializedParameter1.ts (2 errors) ====
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,51 @@
//// [requiredInitializedParameter1.ts]
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
//// [requiredInitializedParameter1.js]
function f1(a, b, c) {
if (b === void 0) { b = 0; }
}
function f2(a, b, c) {
if (b === void 0) { b = 0; }
if (c === void 0) { c = 0; }
}
function f3(a, b, c) {
if (b === void 0) { b = 0; }
}
function f4(a, b) {
if (b === void 0) { b = 0; }
var c = [];
for (var _i = 2; _i < arguments.length; _i++) {
c[_i - 2] = arguments[_i];
}
}
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,17 @@
tests/cases/compiler/requiredInitializedParameter2.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'I1'.
Types of property 'method' are incompatible.
Type '(a: number, b: any) => void' is not assignable to type '() => any'.
==== tests/cases/compiler/requiredInitializedParameter2.ts (1 errors) ====
interface I1 {
method();
}
class C1 implements I1 {
~~
!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'.
!!! error TS2420: Types of property 'method' are incompatible.
!!! error TS2420: Type '(a: number, b: any) => void' is not assignable to type '() => any'.
method(a = 0, b) { }
}
@@ -0,0 +1,18 @@
//// [requiredInitializedParameter2.ts]
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b) { }
}
//// [requiredInitializedParameter2.js]
var C1 = (function () {
function C1() {
}
C1.prototype.method = function (a, b) {
if (a === void 0) { a = 0; }
};
return C1;
})();

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