Merge branch 'master' into glob2
This commit is contained in:
commit
5de2fcc100
|
@ -36,11 +36,13 @@ Your pull request should:
|
|||
|
||||
The library sources are in: [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib)
|
||||
|
||||
To build the library files, run
|
||||
Library files in `built/local/` are updated by running
|
||||
```Shell
|
||||
jake lib
|
||||
jake
|
||||
```
|
||||
|
||||
The files in `lib/` are used to bootstrap compilation and usually do not need to be updated.
|
||||
|
||||
#### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts`
|
||||
|
||||
These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator
|
||||
|
|
12
Jakefile.js
12
Jakefile.js
|
@ -113,7 +113,8 @@ var scriptSources = [
|
|||
"tslint/nextLineRule.ts",
|
||||
"tslint/noNullRule.ts",
|
||||
"tslint/preferConstRule.ts",
|
||||
"tslint/typeOperatorSpacingRule.ts"
|
||||
"tslint/typeOperatorSpacingRule.ts",
|
||||
"tslint/noInOperatorRule.ts"
|
||||
].map(function (f) {
|
||||
return path.join(scriptsDirectory, f);
|
||||
});
|
||||
|
@ -876,7 +877,8 @@ var tslintRules = ([
|
|||
"noNullRule",
|
||||
"preferConstRule",
|
||||
"booleanTriviaRule",
|
||||
"typeOperatorSpacingRule"
|
||||
"typeOperatorSpacingRule",
|
||||
"noInOperatorRule"
|
||||
]);
|
||||
var tslintRulesFiles = tslintRules.map(function(p) {
|
||||
return path.join(tslintRuleDir, p + ".ts");
|
||||
|
@ -927,13 +929,17 @@ var lintTargets = compilerSources
|
|||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", ["build-rules"], function() {
|
||||
var lintOptions = getLinterOptions();
|
||||
var failed = 0;
|
||||
for (var i in lintTargets) {
|
||||
var result = lintFile(lintOptions, lintTargets[i]);
|
||||
if (result.failureCount > 0) {
|
||||
console.log(result.output);
|
||||
fail('Linter errors.', result.failureCount);
|
||||
failed += result.failureCount;
|
||||
}
|
||||
}
|
||||
if (failed > 0) {
|
||||
fail('Linter errors.', failed);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1323,7 +1323,7 @@ x = "hello"; // Ok
|
|||
x = 42; // Ok
|
||||
x = test; // Error, boolean not assignable
|
||||
x = test ? 5 : "five"; // Ok
|
||||
x = test ? 0 : false; // Error, number | boolean not asssignable
|
||||
x = test ? 0 : false; // Error, number | boolean not assignable
|
||||
```
|
||||
|
||||
it is possible to assign 'x' a value of type `string`, `number`, or the union type `string | number`, but not any other type. To access a value in 'x', a type guard can be used to first narrow the type of 'x' to either `string` or `number`:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Read this!
|
||||
|
||||
These files are not meant to be edited by hand.
|
||||
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
|
||||
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. Running `jake LKG` will then appropriately update the files in this directory.
|
||||
|
|
20
scripts/tslint/noInOperatorRule.ts
Normal file
20
scripts/tslint/noInOperatorRule.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
public static FAILURE_STRING = "Don't use the 'in' keyword - use 'hasProperty' to check for key presence instead";
|
||||
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new InWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
}
|
||||
|
||||
class InWalker extends Lint.RuleWalker {
|
||||
visitNode(node: ts.Node) {
|
||||
super.visitNode(node);
|
||||
if (node.kind === ts.SyntaxKind.InKeyword && node.parent && node.parent.kind === ts.SyntaxKind.BinaryExpression) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ namespace ts {
|
|||
const emitResolver = createResolver();
|
||||
|
||||
const undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||
undefinedSymbol.declarations = [];
|
||||
const argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments");
|
||||
|
||||
const checker: TypeChecker = {
|
||||
|
@ -234,6 +235,10 @@ namespace ts {
|
|||
ResolvedReturnType
|
||||
}
|
||||
|
||||
const builtinGlobals: SymbolTable = {
|
||||
[undefinedSymbol.name]: undefinedSymbol
|
||||
};
|
||||
|
||||
initializeTypeChecker();
|
||||
|
||||
return checker;
|
||||
|
@ -360,6 +365,24 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) {
|
||||
for (const id in source) {
|
||||
if (hasProperty(source, id)) {
|
||||
if (hasProperty(target, id)) {
|
||||
// Error on redeclarations
|
||||
forEach(target[id].declarations, addDeclarationDiagnostic(id, message));
|
||||
}
|
||||
else {
|
||||
target[id] = source[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addDeclarationDiagnostic(id: string, message: DiagnosticMessage) {
|
||||
return (declaration: Declaration) => diagnostics.add(createDiagnosticForNode(declaration, message, id));
|
||||
}
|
||||
}
|
||||
|
||||
function getSymbolLinks(symbol: Symbol): SymbolLinks {
|
||||
if (symbol.flags & SymbolFlags.Transient) return <TransientSymbol>symbol;
|
||||
const id = getSymbolId(symbol);
|
||||
|
@ -379,6 +402,14 @@ namespace ts {
|
|||
return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(<SourceFile>node);
|
||||
}
|
||||
|
||||
/** Is this type one of the apparent types created from the primitive types. */
|
||||
function isPrimitiveApparentType(type: Type): boolean {
|
||||
return type === globalStringType ||
|
||||
type === globalNumberType ||
|
||||
type === globalBooleanType ||
|
||||
type === globalESSymbolType;
|
||||
}
|
||||
|
||||
function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol {
|
||||
if (meaning && hasProperty(symbols, name)) {
|
||||
const symbol = symbols[name];
|
||||
|
@ -1095,39 +1126,81 @@ namespace ts {
|
|||
return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol));
|
||||
}
|
||||
|
||||
function extendExportSymbols(target: SymbolTable, source: SymbolTable) {
|
||||
interface ExportCollisionTracker {
|
||||
specifierText: string;
|
||||
exportsWithDuplicate: ExportDeclaration[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends one symbol table with another while collecting information on name collisions for error message generation into the `lookupTable` argument
|
||||
* Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables
|
||||
*/
|
||||
function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map<ExportCollisionTracker>, exportNode?: ExportDeclaration) {
|
||||
for (const id in source) {
|
||||
if (id !== "default" && !hasProperty(target, id)) {
|
||||
target[id] = source[id];
|
||||
if (lookupTable && exportNode) {
|
||||
lookupTable[id] = {
|
||||
specifierText: getTextOfNode(exportNode.moduleSpecifier)
|
||||
} as ExportCollisionTracker;
|
||||
}
|
||||
}
|
||||
else if (lookupTable && exportNode && id !== "default" && hasProperty(target, id) && resolveSymbol(target[id]) !== resolveSymbol(source[id])) {
|
||||
if (!lookupTable[id].exportsWithDuplicate) {
|
||||
lookupTable[id].exportsWithDuplicate = [exportNode];
|
||||
}
|
||||
else {
|
||||
lookupTable[id].exportsWithDuplicate.push(exportNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getExportsForModule(moduleSymbol: Symbol): SymbolTable {
|
||||
let result: SymbolTable;
|
||||
const visitedSymbols: Symbol[] = [];
|
||||
visit(moduleSymbol);
|
||||
return result || moduleSymbol.exports;
|
||||
return visit(moduleSymbol) || moduleSymbol.exports;
|
||||
|
||||
// The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example,
|
||||
// module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error.
|
||||
function visit(symbol: Symbol) {
|
||||
if (symbol && symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol)) {
|
||||
visitedSymbols.push(symbol);
|
||||
if (symbol !== moduleSymbol) {
|
||||
if (!result) {
|
||||
result = cloneSymbolTable(moduleSymbol.exports);
|
||||
}
|
||||
extendExportSymbols(result, symbol.exports);
|
||||
}
|
||||
// All export * declarations are collected in an __export symbol by the binder
|
||||
const exportStars = symbol.exports["__export"];
|
||||
if (exportStars) {
|
||||
for (const node of exportStars.declarations) {
|
||||
visit(resolveExternalModuleName(node, (<ExportDeclaration>node).moduleSpecifier));
|
||||
}
|
||||
}
|
||||
function visit(symbol: Symbol): SymbolTable {
|
||||
if (!(symbol && symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol))) {
|
||||
return;
|
||||
}
|
||||
visitedSymbols.push(symbol);
|
||||
const symbols = cloneSymbolTable(symbol.exports);
|
||||
// All export * declarations are collected in an __export symbol by the binder
|
||||
const exportStars = symbol.exports["__export"];
|
||||
if (exportStars) {
|
||||
const nestedSymbols: SymbolTable = {};
|
||||
const lookupTable: Map<ExportCollisionTracker> = {};
|
||||
for (const node of exportStars.declarations) {
|
||||
const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier);
|
||||
const exportedSymbols = visit(resolvedModule);
|
||||
extendExportSymbols(
|
||||
nestedSymbols,
|
||||
exportedSymbols,
|
||||
lookupTable,
|
||||
node as ExportDeclaration
|
||||
);
|
||||
}
|
||||
for (const id in lookupTable) {
|
||||
const { exportsWithDuplicate } = lookupTable[id];
|
||||
// It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself
|
||||
if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || hasProperty(symbols, id)) {
|
||||
continue;
|
||||
}
|
||||
for (const node of exportsWithDuplicate) {
|
||||
diagnostics.add(createDiagnosticForNode(
|
||||
node,
|
||||
Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity,
|
||||
lookupTable[id].specifierText,
|
||||
id
|
||||
));
|
||||
}
|
||||
}
|
||||
extendExportSymbols(symbols, nestedSymbols);
|
||||
}
|
||||
return symbols;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1521,9 +1594,9 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
|
||||
function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string {
|
||||
const writer = getSingleLineStringWriter();
|
||||
getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
|
||||
getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind);
|
||||
const result = writer.string();
|
||||
releaseStringWriter(writer);
|
||||
|
||||
|
@ -1875,7 +1948,7 @@ namespace ts {
|
|||
if (flags & TypeFormatFlags.InElementType) {
|
||||
writePunctuation(writer, SyntaxKind.OpenParenToken);
|
||||
}
|
||||
buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, symbolStack);
|
||||
buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack);
|
||||
if (flags & TypeFormatFlags.InElementType) {
|
||||
writePunctuation(writer, SyntaxKind.CloseParenToken);
|
||||
}
|
||||
|
@ -1887,7 +1960,7 @@ namespace ts {
|
|||
}
|
||||
writeKeyword(writer, SyntaxKind.NewKeyword);
|
||||
writeSpace(writer);
|
||||
buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, symbolStack);
|
||||
buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack);
|
||||
if (flags & TypeFormatFlags.InElementType) {
|
||||
writePunctuation(writer, SyntaxKind.CloseParenToken);
|
||||
}
|
||||
|
@ -1901,15 +1974,12 @@ namespace ts {
|
|||
writer.writeLine();
|
||||
writer.increaseIndent();
|
||||
for (const signature of resolved.callSignatures) {
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack);
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack);
|
||||
writePunctuation(writer, SyntaxKind.SemicolonToken);
|
||||
writer.writeLine();
|
||||
}
|
||||
for (const signature of resolved.constructSignatures) {
|
||||
writeKeyword(writer, SyntaxKind.NewKeyword);
|
||||
writeSpace(writer);
|
||||
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack);
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, SignatureKind.Construct, symbolStack);
|
||||
writePunctuation(writer, SyntaxKind.SemicolonToken);
|
||||
writer.writeLine();
|
||||
}
|
||||
|
@ -1950,7 +2020,7 @@ namespace ts {
|
|||
if (p.flags & SymbolFlags.Optional) {
|
||||
writePunctuation(writer, SyntaxKind.QuestionToken);
|
||||
}
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack);
|
||||
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack);
|
||||
writePunctuation(writer, SyntaxKind.SemicolonToken);
|
||||
writer.writeLine();
|
||||
}
|
||||
|
@ -2070,7 +2140,12 @@ namespace ts {
|
|||
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
|
||||
function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
|
||||
function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, symbolStack?: Symbol[]) {
|
||||
if (kind === SignatureKind.Construct) {
|
||||
writeKeyword(writer, SyntaxKind.NewKeyword);
|
||||
writeSpace(writer);
|
||||
}
|
||||
|
||||
if (signature.target && (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature)) {
|
||||
// Instantiated signature, write type arguments instead
|
||||
// This is achieved by passing in the mapper separately
|
||||
|
@ -2938,10 +3013,6 @@ namespace ts {
|
|||
return type.resolvedBaseConstructorType;
|
||||
}
|
||||
|
||||
function hasClassBaseType(type: InterfaceType): boolean {
|
||||
return !!forEach(getBaseTypes(type), t => !!(t.symbol.flags & SymbolFlags.Class));
|
||||
}
|
||||
|
||||
function getBaseTypes(type: InterfaceType): ObjectType[] {
|
||||
const isClass = type.symbol.flags & SymbolFlags.Class;
|
||||
const isInterface = type.symbol.flags & SymbolFlags.Interface;
|
||||
|
@ -3375,11 +3446,11 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getDefaultConstructSignatures(classType: InterfaceType): Signature[] {
|
||||
if (!hasClassBaseType(classType)) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
}
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct);
|
||||
if (baseSignatures.length === 0) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
}
|
||||
const baseTypeNode = getBaseTypeNodeOfClass(classType);
|
||||
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
|
||||
const typeArgCount = typeArguments ? typeArguments.length : 0;
|
||||
|
@ -3597,7 +3668,7 @@ namespace ts {
|
|||
return <ResolvedType>type;
|
||||
}
|
||||
|
||||
// Return properties of an object type or an empty array for other types
|
||||
/** Return properties of an object type or an empty array for other types */
|
||||
function getPropertiesOfObjectType(type: Type): Symbol[] {
|
||||
if (type.flags & TypeFlags.ObjectType) {
|
||||
return resolveStructuredTypeMembers(<ObjectType>type).properties;
|
||||
|
@ -3605,8 +3676,8 @@ namespace ts {
|
|||
return emptyArray;
|
||||
}
|
||||
|
||||
// If the given type is an object type and that type has a property by the given name,
|
||||
// return the symbol for that property.Otherwise return undefined.
|
||||
/** If the given type is an object type and that type has a property by the given name,
|
||||
* return the symbol for that property. Otherwise return undefined. */
|
||||
function getPropertyOfObjectType(type: Type, name: string): Symbol {
|
||||
if (type.flags & TypeFlags.ObjectType) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
|
@ -5073,9 +5144,6 @@ namespace ts {
|
|||
}
|
||||
return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false);
|
||||
}
|
||||
if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) {
|
||||
return typeParameterIdenticalTo(<TypeParameter>source, <TypeParameter>target);
|
||||
}
|
||||
if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union ||
|
||||
source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) {
|
||||
if (result = eachTypeRelatedToSomeType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target)) {
|
||||
|
@ -5206,17 +5274,6 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary {
|
||||
// covers case when both type parameters does not have constraint (both equal to noConstraintType)
|
||||
if (source.constraint === target.constraint) {
|
||||
return Ternary.True;
|
||||
}
|
||||
if (source.constraint === noConstraintType || target.constraint === noConstraintType) {
|
||||
return Ternary.False;
|
||||
}
|
||||
return isIdenticalTo(source.constraint, target.constraint);
|
||||
}
|
||||
|
||||
// Determine if two object types are related by structure. First, check if the result is already available in the global cache.
|
||||
// Second, check if we have already started a comparison of the given two types in which case we assume the result to be true.
|
||||
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
|
||||
|
@ -5442,20 +5499,26 @@ namespace ts {
|
|||
|
||||
outer: for (const t of targetSignatures) {
|
||||
if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) {
|
||||
let localErrors = reportErrors;
|
||||
const checkedAbstractAssignability = false;
|
||||
// Only elaborate errors from the first failure
|
||||
let shouldElaborateErrors = reportErrors;
|
||||
for (const s of sourceSignatures) {
|
||||
if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) {
|
||||
const related = signatureRelatedTo(s, t, localErrors);
|
||||
const related = signatureRelatedTo(s, t, shouldElaborateErrors);
|
||||
if (related) {
|
||||
result &= related;
|
||||
errorInfo = saveErrorInfo;
|
||||
continue outer;
|
||||
}
|
||||
// Only report errors from the first failure
|
||||
localErrors = false;
|
||||
shouldElaborateErrors = false;
|
||||
}
|
||||
}
|
||||
// don't elaborate the primitive apparent types (like Number)
|
||||
// because the actual primitives will have already been reported.
|
||||
if (shouldElaborateErrors && !isPrimitiveApparentType(source)) {
|
||||
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
|
||||
typeToString(source),
|
||||
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
|
@ -5765,26 +5828,19 @@ namespace ts {
|
|||
if (!(isMatchingSignature(source, target, partialMatch))) {
|
||||
return Ternary.False;
|
||||
}
|
||||
let result = Ternary.True;
|
||||
if (source.typeParameters && target.typeParameters) {
|
||||
if (source.typeParameters.length !== target.typeParameters.length) {
|
||||
return Ternary.False;
|
||||
}
|
||||
for (let i = 0, len = source.typeParameters.length; i < len; ++i) {
|
||||
const related = compareTypes(source.typeParameters[i], target.typeParameters[i]);
|
||||
if (!related) {
|
||||
return Ternary.False;
|
||||
}
|
||||
result &= related;
|
||||
}
|
||||
}
|
||||
else if (source.typeParameters || target.typeParameters) {
|
||||
// Check that the two signatures have the same number of type parameters. We might consider
|
||||
// also checking that any type parameter constraints match, but that would require instantiating
|
||||
// the constraints with a common set of type arguments to get relatable entities in places where
|
||||
// type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile,
|
||||
// particularly as we're comparing erased versions of the signatures below.
|
||||
if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) {
|
||||
return Ternary.False;
|
||||
}
|
||||
// Spec 1.0 Section 3.8.3 & 3.8.4:
|
||||
// M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
|
||||
source = getErasedSignature(source);
|
||||
target = getErasedSignature(target);
|
||||
let result = Ternary.True;
|
||||
const targetLen = target.parameters.length;
|
||||
for (let i = 0; i < targetLen; i++) {
|
||||
const s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
|
||||
|
@ -6092,14 +6148,25 @@ namespace ts {
|
|||
function inferFromTypes(source: Type, target: Type) {
|
||||
if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union ||
|
||||
source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) {
|
||||
// Source and target are both unions or both intersections. To improve the quality of
|
||||
// inferences we first reduce the types by removing constituents that are identically
|
||||
// matched by a constituent in the other type. For example, when inferring from
|
||||
// 'string | string[]' to 'string | T', we reduce the types to 'string[]' and 'T'.
|
||||
const reducedSource = reduceUnionOrIntersectionType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target);
|
||||
const reducedTarget = reduceUnionOrIntersectionType(<UnionOrIntersectionType>target, <UnionOrIntersectionType>source);
|
||||
source = reducedSource;
|
||||
target = reducedTarget;
|
||||
// Source and target are both unions or both intersections. First, find each
|
||||
// target constituent type that has an identically matching source constituent
|
||||
// type, and for each such target constituent type infer from the type to itself.
|
||||
// When inferring from a type to itself we effectively find all type parameter
|
||||
// occurrences within that type and infer themselves as their type arguments.
|
||||
let matchingTypes: Type[];
|
||||
for (const t of (<UnionOrIntersectionType>target).types) {
|
||||
if (typeIdenticalToSomeType(t, (<UnionOrIntersectionType>source).types)) {
|
||||
(matchingTypes || (matchingTypes = [])).push(t);
|
||||
inferFromTypes(t, t);
|
||||
}
|
||||
}
|
||||
// Next, to improve the quality of inferences, reduce the source and target types by
|
||||
// removing the identically matched constituents. For example, when inferring from
|
||||
// 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'.
|
||||
if (matchingTypes) {
|
||||
source = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>source, matchingTypes);
|
||||
target = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & TypeFlags.TypeParameter) {
|
||||
// If target is a type parameter, make an inference, unless the source type contains
|
||||
|
@ -6183,9 +6250,12 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
source = getApparentType(source);
|
||||
if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) ||
|
||||
(target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) {
|
||||
// If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members
|
||||
if (source.flags & TypeFlags.ObjectType && (
|
||||
target.flags & TypeFlags.Reference && (<TypeReference>target).typeArguments ||
|
||||
target.flags & TypeFlags.Tuple ||
|
||||
target.flags & TypeFlags.Anonymous && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) {
|
||||
// If source is an object type, and target is a type reference with type arguments, a tuple type,
|
||||
// the type of a method, or a type literal, infer from members
|
||||
if (isInProcess(source, target)) {
|
||||
return;
|
||||
}
|
||||
|
@ -6258,9 +6328,9 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function typeIdenticalToSomeType(source: Type, target: UnionOrIntersectionType): boolean {
|
||||
for (const t of target.types) {
|
||||
if (isTypeIdenticalTo(source, t)) {
|
||||
function typeIdenticalToSomeType(type: Type, types: Type[]): boolean {
|
||||
for (const t of types) {
|
||||
if (isTypeIdenticalTo(t, type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6268,29 +6338,17 @@ namespace ts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the reduced form of the source type. This type is computed by by removing all source
|
||||
* constituents that have an identical match in the target type.
|
||||
* Return a new union or intersection type computed by removing a given set of types
|
||||
* from a given union or intersection type.
|
||||
*/
|
||||
function reduceUnionOrIntersectionType(source: UnionOrIntersectionType, target: UnionOrIntersectionType) {
|
||||
let sourceTypes = source.types;
|
||||
let sourceIndex = 0;
|
||||
let modified = false;
|
||||
while (sourceIndex < sourceTypes.length) {
|
||||
if (typeIdenticalToSomeType(sourceTypes[sourceIndex], target)) {
|
||||
if (!modified) {
|
||||
sourceTypes = sourceTypes.slice(0);
|
||||
modified = true;
|
||||
}
|
||||
sourceTypes.splice(sourceIndex, 1);
|
||||
}
|
||||
else {
|
||||
sourceIndex++;
|
||||
function removeTypesFromUnionOrIntersection(type: UnionOrIntersectionType, typesToRemove: Type[]) {
|
||||
const reducedTypes: Type[] = [];
|
||||
for (const t of type.types) {
|
||||
if (!typeIdenticalToSomeType(t, typesToRemove)) {
|
||||
reducedTypes.push(t);
|
||||
}
|
||||
}
|
||||
if (modified) {
|
||||
return source.flags & TypeFlags.Union ? getUnionType(sourceTypes, /*noSubtypeReduction*/ true) : getIntersectionType(sourceTypes);
|
||||
}
|
||||
return source;
|
||||
return type.flags & TypeFlags.Union ? getUnionType(reducedTypes, /*noSubtypeReduction*/ true) : getIntersectionType(reducedTypes);
|
||||
}
|
||||
|
||||
function getInferenceCandidates(context: InferenceContext, index: number): Type[] {
|
||||
|
@ -14134,8 +14192,29 @@ namespace ts {
|
|||
const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
|
||||
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
|
||||
}
|
||||
// Checks for export * conflicts
|
||||
const exports = getExportsOfModule(moduleSymbol);
|
||||
for (const id in exports) {
|
||||
if (id === "__export") {
|
||||
continue;
|
||||
}
|
||||
const { declarations, flags } = exports[id];
|
||||
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
||||
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && declarations.length > 1) {
|
||||
const exportedDeclarations: Declaration[] = filter(declarations, isNotOverload);
|
||||
if (exportedDeclarations.length > 1) {
|
||||
for (const declaration of exportedDeclarations) {
|
||||
diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Cannot_redeclare_exported_variable_0, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
links.exportsChecked = true;
|
||||
}
|
||||
|
||||
function isNotOverload(declaration: Declaration): boolean {
|
||||
return declaration.kind !== SyntaxKind.FunctionDeclaration || !!(declaration as FunctionDeclaration).body;
|
||||
}
|
||||
}
|
||||
|
||||
function checkTypePredicate(node: TypePredicateNode) {
|
||||
|
@ -15270,10 +15349,12 @@ namespace ts {
|
|||
}
|
||||
});
|
||||
|
||||
// Setup global builtins
|
||||
addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
|
||||
|
||||
getSymbolLinks(undefinedSymbol).type = undefinedType;
|
||||
getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments");
|
||||
getSymbolLinks(unknownSymbol).type = unknownType;
|
||||
globals[undefinedSymbol.name] = undefinedSymbol;
|
||||
|
||||
// Initialize special types
|
||||
globalArrayType = <GenericType>getGlobalType("Array", /*arity*/ 1);
|
||||
|
@ -15411,6 +15492,11 @@ namespace ts {
|
|||
let flags = 0;
|
||||
for (const modifier of node.modifiers) {
|
||||
switch (modifier.kind) {
|
||||
case SyntaxKind.ConstKeyword:
|
||||
if (node.kind !== SyntaxKind.EnumDeclaration && node.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword));
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
|
@ -15967,13 +16053,27 @@ namespace ts {
|
|||
if (forInOrOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
const variableList = <VariableDeclarationList>forInOrOfStatement.initializer;
|
||||
if (!checkGrammarVariableDeclarationList(variableList)) {
|
||||
if (variableList.declarations.length > 1) {
|
||||
const declarations = variableList.declarations;
|
||||
|
||||
// declarations.length can be zero if there is an error in variable declaration in for-of or for-in
|
||||
// See http://www.ecma-international.org/ecma-262/6.0/#sec-for-in-and-for-of-statements for details
|
||||
// For example:
|
||||
// var let = 10;
|
||||
// for (let of [1,2,3]) {} // this is invalid ES6 syntax
|
||||
// for (let in [1,2,3]) {} // this is invalid ES6 syntax
|
||||
// We will then want to skip on grammar checking on variableList declaration
|
||||
if (!declarations.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (declarations.length > 1) {
|
||||
const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement
|
||||
? Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
|
||||
: Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
|
||||
return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
|
||||
}
|
||||
const firstDeclaration = variableList.declarations[0];
|
||||
const firstDeclaration = declarations[0];
|
||||
|
||||
if (firstDeclaration.initializer) {
|
||||
const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement
|
||||
? Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
|
||||
|
@ -16172,7 +16272,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
const checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node));
|
||||
const checkLetConstNames = (isLet(node) || isConst(node));
|
||||
|
||||
// 1. LexicalDeclaration : LetOrConst BindingList ;
|
||||
// It is a Syntax Error if the BoundNames of BindingList contains "let".
|
||||
|
@ -16186,7 +16286,7 @@ namespace ts {
|
|||
|
||||
function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean {
|
||||
if (name.kind === SyntaxKind.Identifier) {
|
||||
if ((<Identifier>name).text === "let") {
|
||||
if ((<Identifier>name).originalKeywordKind === SyntaxKind.LetKeyword) {
|
||||
return grammarErrorOnNode(name, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -791,7 +791,10 @@
|
|||
"category": "Error",
|
||||
"code": 1247
|
||||
},
|
||||
|
||||
"A class member cannot have the '{0}' keyword.": {
|
||||
"category": "Error",
|
||||
"code": 1248
|
||||
},
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
"code": 1300
|
||||
|
@ -844,6 +847,10 @@
|
|||
"category": "Error",
|
||||
"code": 2307
|
||||
},
|
||||
"Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.": {
|
||||
"category": "Error",
|
||||
"code": 2308
|
||||
},
|
||||
"An export assignment cannot be used in a module with other exported elements.": {
|
||||
"category": "Error",
|
||||
"code": 2309
|
||||
|
@ -900,6 +907,10 @@
|
|||
"category": "Error",
|
||||
"code": 2322
|
||||
},
|
||||
"Cannot redeclare exported variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2323
|
||||
},
|
||||
"Property '{0}' is missing in type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2324
|
||||
|
@ -1180,6 +1191,10 @@
|
|||
"category": "Error",
|
||||
"code": 2396
|
||||
},
|
||||
"Declaration name conflicts with built-in global identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2397
|
||||
},
|
||||
"Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": {
|
||||
"category": "Error",
|
||||
"code": 2399
|
||||
|
@ -1732,6 +1747,10 @@
|
|||
"category": "Error",
|
||||
"code": 2657
|
||||
},
|
||||
"Type '{0}' provides no match for the signature '{1}'": {
|
||||
"category": "Error",
|
||||
"code": 2658
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
|
|
@ -1453,6 +1453,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
|
@ -3628,12 +3629,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
// only allow export default at a source file level
|
||||
if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) {
|
||||
if (!isEs6Module) {
|
||||
if (languageVersion === ScriptTarget.ES5) {
|
||||
if (languageVersion !== ScriptTarget.ES3) {
|
||||
// default value of configurable, enumerable, writable are `false`.
|
||||
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
|
||||
writeLine();
|
||||
}
|
||||
else if (languageVersion === ScriptTarget.ES3) {
|
||||
else {
|
||||
write("exports.__esModule = true;");
|
||||
writeLine();
|
||||
}
|
||||
|
@ -4530,7 +4531,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
|
||||
const isAsync = isAsyncFunctionLike(node);
|
||||
if (isAsync && languageVersion === ScriptTarget.ES6) {
|
||||
if (isAsync) {
|
||||
emitAsyncFunctionBodyForES6(node);
|
||||
}
|
||||
else {
|
||||
|
@ -5171,35 +5172,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
if (!(node.flags & NodeFlags.Export)) {
|
||||
return;
|
||||
}
|
||||
// If this is an exported class, but not on the top level (i.e. on an internal
|
||||
// module), export it
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
// if this is a top level default export of decorated class, write the export after the declaration.
|
||||
writeLine();
|
||||
if (thisNodeIsDecorated && modulekind === ModuleKind.ES6) {
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
else if (modulekind === ModuleKind.System) {
|
||||
write(`${exportFunctionForFile}("default", `);
|
||||
emitDeclarationName(node);
|
||||
write(");");
|
||||
}
|
||||
else if (modulekind !== ModuleKind.ES6) {
|
||||
write(`exports.default = `);
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
if (modulekind !== ModuleKind.ES6) {
|
||||
emitExportMemberAssignment(node as ClassDeclaration);
|
||||
}
|
||||
else if (node.parent.kind !== SyntaxKind.SourceFile || (modulekind !== ModuleKind.ES6 && !(node.flags & NodeFlags.Default))) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
emitModuleMemberName(node);
|
||||
write(" = ");
|
||||
emitDeclarationName(node);
|
||||
emitEnd(node);
|
||||
write(";");
|
||||
else {
|
||||
// If this is an exported class, but not on the top level (i.e. on an internal
|
||||
// module), export it
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
// if this is a top level default export of decorated class, write the export after the declaration.
|
||||
if (thisNodeIsDecorated) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
else if (node.parent.kind !== SyntaxKind.SourceFile) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
emitModuleMemberName(node);
|
||||
write(" = ");
|
||||
emitDeclarationName(node);
|
||||
emitEnd(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5800,9 +5796,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
|
||||
if (!shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
// do not emit var if variable was already hoisted
|
||||
if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) {
|
||||
|
||||
const isES6ExportedEnum = isES6ExportedDeclaration(node);
|
||||
if (!(node.flags & NodeFlags.Export) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.EnumDeclaration))) {
|
||||
emitStart(node);
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
if (isES6ExportedEnum) {
|
||||
write("export ");
|
||||
}
|
||||
write("var ");
|
||||
|
@ -5899,6 +5897,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
return languageVersion === ScriptTarget.ES6 && !!(resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalModuleMergesWithClass);
|
||||
}
|
||||
|
||||
function isFirstDeclarationOfKind(node: Declaration, declarations: Declaration[], kind: SyntaxKind) {
|
||||
return !forEach(declarations, declaration => declaration.kind === kind && declaration.pos < node.pos);
|
||||
}
|
||||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
// Emit only if this module is non-ambient.
|
||||
const shouldEmit = shouldEmitModuleDeclaration(node);
|
||||
|
@ -5910,15 +5912,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
const emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
|
||||
|
||||
if (emitVarForModule) {
|
||||
emitStart(node);
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
write("export ");
|
||||
const isES6ExportedNamespace = isES6ExportedDeclaration(node);
|
||||
if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.ModuleDeclaration)) {
|
||||
emitStart(node);
|
||||
if (isES6ExportedNamespace) {
|
||||
write("export ");
|
||||
}
|
||||
write("var ");
|
||||
emit(node.name);
|
||||
write(";");
|
||||
emitEnd(node);
|
||||
writeLine();
|
||||
}
|
||||
write("var ");
|
||||
emit(node.name);
|
||||
write(";");
|
||||
emitEnd(node);
|
||||
writeLine();
|
||||
}
|
||||
|
||||
emitStart(node);
|
||||
|
@ -7819,6 +7824,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
const shebang = getShebang(currentText);
|
||||
if (shebang) {
|
||||
write(shebang);
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1134,6 +1134,14 @@ namespace ts {
|
|||
return token === t && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
|
||||
function nextTokenIsOnSameLineAndCanFollowModifier() {
|
||||
nextToken();
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
return false;
|
||||
}
|
||||
return canFollowModifier();
|
||||
}
|
||||
|
||||
function nextTokenCanFollowModifier() {
|
||||
if (token === SyntaxKind.ConstKeyword) {
|
||||
// 'const' is only a modifier if followed by 'enum'.
|
||||
|
@ -1154,11 +1162,7 @@ namespace ts {
|
|||
return canFollowModifier();
|
||||
}
|
||||
|
||||
nextToken();
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
return false;
|
||||
}
|
||||
return canFollowModifier();
|
||||
return nextTokenIsOnSameLineAndCanFollowModifier();
|
||||
}
|
||||
|
||||
function parseAnyContextualModifier(): boolean {
|
||||
|
@ -4923,15 +4927,31 @@ namespace ts {
|
|||
return decorators;
|
||||
}
|
||||
|
||||
function parseModifiers(): ModifiersArray {
|
||||
/*
|
||||
* There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member.
|
||||
* In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect
|
||||
* and turns it into a standalone declaration), then it is better to parse it and report an error later.
|
||||
*
|
||||
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
|
||||
*/
|
||||
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
|
||||
let flags = 0;
|
||||
let modifiers: ModifiersArray;
|
||||
while (true) {
|
||||
const modifierStart = scanner.getStartPos();
|
||||
const modifierKind = token;
|
||||
|
||||
if (!parseAnyContextualModifier()) {
|
||||
break;
|
||||
if (token === SyntaxKind.ConstKeyword && permitInvalidConstAsModifier) {
|
||||
// We need to ensure that any subsequent modifiers appear on the same line
|
||||
// so that when 'const' is a standalone declaration, we don't issue an error.
|
||||
if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!parseAnyContextualModifier()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!modifiers) {
|
||||
|
@ -4976,7 +4996,7 @@ namespace ts {
|
|||
|
||||
const fullStart = getNodePos();
|
||||
const decorators = parseDecorators();
|
||||
const modifiers = parseModifiers();
|
||||
const modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true);
|
||||
|
||||
const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers);
|
||||
if (accessor) {
|
||||
|
@ -5310,16 +5330,17 @@ namespace ts {
|
|||
}
|
||||
|
||||
function parseModuleSpecifier(): Expression {
|
||||
// We allow arbitrary expressions here, even though the grammar only allows string
|
||||
// literals. We check to ensure that it is only a string literal later in the grammar
|
||||
// walker.
|
||||
const result = parseExpression();
|
||||
// Ensure the string being required is in our 'identifier' table. This will ensure
|
||||
// that features like 'find refs' will look inside this file when search for its name.
|
||||
if (result.kind === SyntaxKind.StringLiteral) {
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
const result = parseLiteralNode();
|
||||
internIdentifier((<LiteralExpression>result).text);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
// We allow arbitrary expressions here, even though the grammar only allows string
|
||||
// literals. We check to ensure that it is only a string literal later in the grammar
|
||||
// check pass.
|
||||
return parseExpression();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseNamespaceImport(): NamespaceImport {
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace ts {
|
|||
jsonContent = { typings: undefined };
|
||||
}
|
||||
|
||||
if (jsonContent.typings) {
|
||||
if (typeof jsonContent.typings === "string") {
|
||||
const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
|
||||
if (result) {
|
||||
return result;
|
||||
|
@ -661,19 +661,17 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
return getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
return runWithCancellationToken(() => {
|
||||
const typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
const bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
const checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ?
|
||||
getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) :
|
||||
typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
|
@ -1079,6 +1077,8 @@ namespace ts {
|
|||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
|
||||
// this check is ok. Otherwise this would be never true for javascript file
|
||||
if (!isExternalModule(importedFile)) {
|
||||
const start = getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
|
|
|
@ -49,6 +49,21 @@ namespace ts {
|
|||
constructor(o: any);
|
||||
}
|
||||
|
||||
declare var ChakraHost: {
|
||||
args: string[];
|
||||
currentDirectory: string;
|
||||
executingFile: string;
|
||||
echo(s: string): void;
|
||||
quit(exitCode?: number): void;
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
createDirectory(path: string): void;
|
||||
resolvePath(path: string): string;
|
||||
readFile(path: string): string;
|
||||
writeFile(path: string, contents: string): void;
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
};
|
||||
|
||||
export var sys: System = (function () {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
|
@ -208,6 +223,7 @@ namespace ts {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getNodeSystem(): System {
|
||||
const _fs = require("fs");
|
||||
const _path = require("path");
|
||||
|
@ -494,6 +510,37 @@ namespace ts {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getChakraSystem(): System {
|
||||
|
||||
return {
|
||||
newLine: "\r\n",
|
||||
args: ChakraHost.args,
|
||||
useCaseSensitiveFileNames: false,
|
||||
write: ChakraHost.echo,
|
||||
readFile(path: string, encoding?: string) {
|
||||
// encoding is automatically handled by the implementation in ChakraHost
|
||||
return ChakraHost.readFile(path);
|
||||
},
|
||||
writeFile(path: string, data: string, writeByteOrderMark?: boolean) {
|
||||
// If a BOM is required, emit one
|
||||
if (writeByteOrderMark) {
|
||||
data = "\uFEFF" + data;
|
||||
}
|
||||
|
||||
ChakraHost.writeFile(path, data);
|
||||
},
|
||||
resolvePath: ChakraHost.resolvePath,
|
||||
fileExists: ChakraHost.fileExists,
|
||||
directoryExists: ChakraHost.directoryExists,
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
|
||||
return getWScriptSystem();
|
||||
}
|
||||
|
@ -502,8 +549,13 @@ namespace ts {
|
|||
// process.browser check excludes webpack and browserify
|
||||
return getNodeSystem();
|
||||
}
|
||||
else if (typeof ChakraHost !== "undefined") {
|
||||
return getChakraSystem();
|
||||
}
|
||||
else {
|
||||
return undefined; // Unsupported host
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1785,7 +1785,7 @@ namespace ts {
|
|||
export interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
|
||||
|
|
|
@ -1889,8 +1889,10 @@ namespace ts {
|
|||
* Resolves a local path to a path which is absolute to the base of the emit
|
||||
*/
|
||||
export function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string {
|
||||
const dir = toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(dir, fileName, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/ false);
|
||||
const getCanonicalFileName = (f: string) => host.getCanonicalFileName(f);
|
||||
const dir = toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
|
||||
const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
return removeFileExtension(relativePath);
|
||||
}
|
||||
|
||||
|
@ -2398,7 +2400,7 @@ namespace ts {
|
|||
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
|
||||
* as the fallback implementation does not check for circular references by default.
|
||||
*/
|
||||
export const stringify: (value: any) => string = JSON && JSON.stringify
|
||||
export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify
|
||||
? JSON.stringify
|
||||
: stringifyFallback;
|
||||
|
||||
|
|
13
src/lib/es6.d.ts
vendored
13
src/lib/es6.d.ts
vendored
|
@ -1224,7 +1224,7 @@ declare namespace Reflect {
|
|||
function isExtensible(target: any): boolean;
|
||||
function ownKeys(target: any): Array<PropertyKey>;
|
||||
function preventExtensions(target: any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}
|
||||
|
||||
|
@ -1272,7 +1272,16 @@ interface PromiseConstructor {
|
|||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
|
||||
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
|
|
|
@ -461,6 +461,7 @@ namespace ts.formatting {
|
|||
case SyntaxKind.ParenthesizedType:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.NamedImports:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -3751,7 +3751,8 @@ namespace ts {
|
|||
// Ignore omitted expressions for missing members
|
||||
if (m.kind !== SyntaxKind.PropertyAssignment &&
|
||||
m.kind !== SyntaxKind.ShorthandPropertyAssignment &&
|
||||
m.kind !== SyntaxKind.BindingElement) {
|
||||
m.kind !== SyntaxKind.BindingElement &&
|
||||
m.kind !== SyntaxKind.MethodDeclaration) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
23
tests/baselines/reference/ClassDeclaration26.errors.txt
Normal file
23
tests/baselines/reference/ClassDeclaration26.errors.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
tests/cases/compiler/ClassDeclaration26.ts(2,22): error TS1005: ';' expected.
|
||||
tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: '=' expected.
|
||||
tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected.
|
||||
tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ClassDeclaration26.ts (5 errors) ====
|
||||
class C {
|
||||
public const var export foo = 10;
|
||||
~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
var constructor() { }
|
||||
~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~
|
||||
!!! error TS1005: '=>' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
15
tests/baselines/reference/ClassDeclaration26.js
Normal file
15
tests/baselines/reference/ClassDeclaration26.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [ClassDeclaration26.ts]
|
||||
class C {
|
||||
public const var export foo = 10;
|
||||
|
||||
var constructor() { }
|
||||
}
|
||||
|
||||
//// [ClassDeclaration26.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.foo = 10;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var constructor = function () { };
|
|
@ -0,0 +1,9 @@
|
|||
tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts(2,3): error TS1248: A class member cannot have the 'const' keyword.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts (1 errors) ====
|
||||
class AtomicNumbers {
|
||||
static const H = 1;
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1248: A class member cannot have the 'const' keyword.
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts]
|
||||
class AtomicNumbers {
|
||||
static const H = 1;
|
||||
}
|
||||
|
||||
//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration.js]
|
||||
var AtomicNumbers = (function () {
|
||||
function AtomicNumbers() {
|
||||
}
|
||||
AtomicNumbers.H = 1;
|
||||
return AtomicNumbers;
|
||||
})();
|
|
@ -0,0 +1,13 @@
|
|||
//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts]
|
||||
class C {
|
||||
const
|
||||
x = 10;
|
||||
}
|
||||
|
||||
//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration2.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.x = 10;
|
||||
}
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 0, 0))
|
||||
|
||||
const
|
||||
>const : Symbol(const, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 0, 9))
|
||||
|
||||
x = 10;
|
||||
>x : Symbol(x, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 1, 9))
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
const
|
||||
>const : any
|
||||
|
||||
x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
}
|
|
@ -11,11 +11,13 @@ define(["require", "exports"], function (require, exports) {
|
|||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
//// [b.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
|
|
@ -10,8 +10,10 @@ export default function() {}
|
|||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
|
|
|
@ -18,6 +18,7 @@ export default function() {}
|
|||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
//// [b.js]
|
||||
|
@ -31,5 +32,6 @@ export default function() {}
|
|||
})(function (require, exports) {
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(28,1): error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
Type 'S2' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(29,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(30,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
Type '(x: string) => number' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(31,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
Type '(x: string) => string' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(32,1): error TS2322: Type 'S2' is not assignable to type 'new (x: number) => void'.
|
||||
Type 'S2' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(33,1): error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(34,1): error TS2322: Type '(x: string) => number' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => number' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(35,1): error TS2322: Type '(x: string) => string' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => string' provides no match for the signature 'new (x: number): void'
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts (8 errors) ====
|
||||
|
@ -39,25 +47,33 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
t = s2;
|
||||
~
|
||||
!!! error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type 'S2' provides no match for the signature 'new (x: number): void'
|
||||
t = a3;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
t = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '(x: string) => number' provides no match for the signature 'new (x: number): void'
|
||||
t = function (x: string) { return ''; }
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '(x: string) => string' provides no match for the signature 'new (x: number): void'
|
||||
a = s2;
|
||||
~
|
||||
!!! error TS2322: Type 'S2' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type 'S2' provides no match for the signature 'new (x: number): void'
|
||||
a = a3;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
a = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => number' provides no match for the signature 'new (x: number): void'
|
||||
a = function (x: string) { return ''; }
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => string' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => string' provides no match for the signature 'new (x: number): void'
|
||||
|
|
@ -9,9 +9,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(34,1): error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(35,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(36,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
Property 'f' is missing in type '(x: string) => number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(37,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
|
@ -19,9 +21,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(38,1): error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(39,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(40,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
Property 'f' is missing in type '(x: string) => number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(41,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
|
@ -79,11 +83,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
!!! error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
t = a3;
|
||||
~
|
||||
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
t = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
|
@ -97,11 +103,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
!!! error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
a = a3;
|
||||
~
|
||||
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'
|
||||
a = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'.
|
||||
|
|
|
@ -11,12 +11,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
|
||||
|
@ -116,6 +118,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
!!! error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
b16 = a16; // error
|
||||
~~~
|
||||
!!! error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
|
||||
|
@ -128,6 +131,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
|||
!!! error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
b17 = a17; // error
|
||||
~~~
|
||||
!!! error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/assignmentCompatability24.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tstring>(a: Tstring): Tstring'
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatability24.ts (1 errors) ====
|
||||
|
@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability24.ts(9,1): error TS2322: Type 'inte
|
|||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tstring>(a: Tstring): Tstring'
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/assignmentCompatability33.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tstring>(a: Tstring): Tstring'
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatability33.ts (1 errors) ====
|
||||
|
@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability33.ts(9,1): error TS2322: Type 'inte
|
|||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tstring>(a: Tstring): Tstring'
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/assignmentCompatability34.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tnumber>(a: Tnumber) => Tnumber'.
|
||||
Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tnumber>(a: Tnumber): Tnumber'
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatability34.ts (1 errors) ====
|
||||
|
@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability34.ts(9,1): error TS2322: Type 'inte
|
|||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tnumber>(a: Tnumber) => Tnumber'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tnumber>(a: Tnumber) => Tnumber'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature '<Tnumber>(a: Tnumber): Tnumber'
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/assignmentCompatability37.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tnumber>(param: Tnumber) => any'.
|
||||
Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature 'new <Tnumber>(param: Tnumber): any'
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatability37.ts (1 errors) ====
|
||||
|
@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability37.ts(9,1): error TS2322: Type 'inte
|
|||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tnumber>(param: Tnumber) => any'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tnumber>(param: Tnumber) => any'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature 'new <Tnumber>(param: Tnumber): any'
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/assignmentCompatability38.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tstring>(param: Tstring) => any'.
|
||||
Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature 'new <Tstring>(param: Tstring): any'
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatability38.ts (1 errors) ====
|
||||
|
@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability38.ts(9,1): error TS2322: Type 'inte
|
|||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tstring>(param: Tstring) => any'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tstring>(param: Tstring) => any'.
|
||||
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' provides no match for the signature 'new <Tstring>(param: Tstring): any'
|
|
@ -1,5 +1,7 @@
|
|||
tests/cases/compiler/callConstructAssignment.ts(7,1): error TS2322: Type 'new () => any' is not assignable to type '() => void'.
|
||||
Type 'new () => any' provides no match for the signature '(): void'
|
||||
tests/cases/compiler/callConstructAssignment.ts(8,1): error TS2322: Type '() => void' is not assignable to type 'new () => any'.
|
||||
Type '() => void' provides no match for the signature 'new (): any'
|
||||
|
||||
|
||||
==== tests/cases/compiler/callConstructAssignment.ts (2 errors) ====
|
||||
|
@ -12,6 +14,8 @@ tests/cases/compiler/callConstructAssignment.ts(8,1): error TS2322: Type '() =>
|
|||
foo = bar; // error
|
||||
~~~
|
||||
!!! error TS2322: Type 'new () => any' is not assignable to type '() => void'.
|
||||
!!! error TS2322: Type 'new () => any' provides no match for the signature '(): void'
|
||||
bar = foo; // error
|
||||
~~~
|
||||
!!! error TS2322: Type '() => void' is not assignable to type 'new () => any'.
|
||||
!!! error TS2322: Type '() => void' is not assignable to type 'new () => any'.
|
||||
!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any'
|
|
@ -16,17 +16,17 @@ export var pi = Math.PI;
|
|||
export var y = x * i;
|
||||
|
||||
//// [concat.js]
|
||||
define("tests/cases/compiler/baz", ["require", "exports", "tests/cases/compiler/a/bar", "tests/cases/compiler/a/foo"], function (require, exports, bar_1, foo_1) {
|
||||
define("baz", ["require", "exports", "a/bar", "a/foo"], function (require, exports, bar_1, foo_1) {
|
||||
"use strict";
|
||||
exports.pi = Math.PI;
|
||||
exports.y = bar_1.x * foo_1.i;
|
||||
});
|
||||
define("tests/cases/compiler/a/foo", ["require", "exports", "tests/cases/compiler/baz"], function (require, exports, baz_1) {
|
||||
define("a/foo", ["require", "exports", "baz"], function (require, exports, baz_1) {
|
||||
"use strict";
|
||||
exports.i = Math.sqrt(-1);
|
||||
exports.z = baz_1.pi * baz_1.pi;
|
||||
});
|
||||
define("tests/cases/compiler/a/bar", ["require", "exports", "tests/cases/compiler/a/foo"], function (require, exports, foo_2) {
|
||||
define("a/bar", ["require", "exports", "a/foo"], function (require, exports, foo_2) {
|
||||
"use strict";
|
||||
exports.x = foo_2.z + foo_2.z;
|
||||
});
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
tests/cases/compiler/constructorAsType.ts(1,5): error TS2322: Type '() => { name: string; }' is not assignable to type 'new () => { name: string; }'.
|
||||
Type '() => { name: string; }' provides no match for the signature 'new (): { name: string; }'
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorAsType.ts (1 errors) ====
|
||||
var Person:new () => {name: string;} = function () {return {name:"joe"};};
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '() => { name: string; }' is not assignable to type 'new () => { name: string; }'.
|
||||
!!! error TS2322: Type '() => { name: string; }' provides no match for the signature 'new (): { name: string; }'
|
||||
|
||||
var Person2:{new() : {name:string;};};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ define(["require", "exports"], function (require, exports) {
|
|||
Foo = __decorate([
|
||||
decorator
|
||||
], Foo);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
|
@ -45,5 +46,6 @@ define(["require", "exports"], function (require, exports) {
|
|||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@ let Foo = class {
|
|||
Foo = __decorate([
|
||||
decorator
|
||||
], Foo);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
|
@ -42,4 +43,5 @@ let default_1 = class {
|
|||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
|
|
|
@ -35,6 +35,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|||
Foo = __decorate([
|
||||
decorator
|
||||
], Foo);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
|
@ -59,5 +60,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
|
|
@ -12,11 +12,13 @@ define(["require", "exports"], function (require, exports) {
|
|||
"use strict";
|
||||
class Foo {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = foo;
|
||||
});
|
||||
|
|
|
@ -11,8 +11,10 @@ export default function foo() {}
|
|||
"use strict";
|
||||
class Foo {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
function foo() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = foo;
|
||||
|
|
|
@ -19,6 +19,7 @@ export default function foo() {}
|
|||
"use strict";
|
||||
class Foo {
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
|
@ -32,5 +33,6 @@ export default function foo() {}
|
|||
})(function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = foo;
|
||||
});
|
||||
|
|
23
tests/baselines/reference/enumExportMergingES6.js
Normal file
23
tests/baselines/reference/enumExportMergingES6.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
//// [enumExportMergingES6.ts]
|
||||
export enum Animals {
|
||||
Cat = 1
|
||||
}
|
||||
export enum Animals {
|
||||
Dog = 2
|
||||
}
|
||||
export enum Animals {
|
||||
CatDog = Cat | Dog
|
||||
}
|
||||
|
||||
|
||||
//// [enumExportMergingES6.js]
|
||||
export var Animals;
|
||||
(function (Animals) {
|
||||
Animals[Animals["Cat"] = 1] = "Cat";
|
||||
})(Animals || (Animals = {}));
|
||||
(function (Animals) {
|
||||
Animals[Animals["Dog"] = 2] = "Dog";
|
||||
})(Animals || (Animals = {}));
|
||||
(function (Animals) {
|
||||
Animals[Animals["CatDog"] = 3] = "CatDog";
|
||||
})(Animals || (Animals = {}));
|
22
tests/baselines/reference/enumExportMergingES6.symbols
Normal file
22
tests/baselines/reference/enumExportMergingES6.symbols
Normal file
|
@ -0,0 +1,22 @@
|
|||
=== tests/cases/conformance/enums/enumExportMergingES6.ts ===
|
||||
export enum Animals {
|
||||
>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1))
|
||||
|
||||
Cat = 1
|
||||
>Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21))
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1))
|
||||
|
||||
Dog = 2
|
||||
>Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21))
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1))
|
||||
|
||||
CatDog = Cat | Dog
|
||||
>CatDog : Symbol(Animals.CatDog, Decl(enumExportMergingES6.ts, 6, 21))
|
||||
>Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21))
|
||||
>Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21))
|
||||
}
|
||||
|
25
tests/baselines/reference/enumExportMergingES6.types
Normal file
25
tests/baselines/reference/enumExportMergingES6.types
Normal file
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/conformance/enums/enumExportMergingES6.ts ===
|
||||
export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
Cat = 1
|
||||
>Cat : Animals
|
||||
>1 : number
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
Dog = 2
|
||||
>Dog : Animals
|
||||
>2 : number
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
CatDog = Cat | Dog
|
||||
>CatDog : Animals
|
||||
>Cat | Dog : number
|
||||
>Cat : Animals
|
||||
>Dog : Animals
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ var x1: number = m;
|
|||
exports.a = 10;
|
||||
exports.x = exports.a;
|
||||
exports.m = exports.a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = {};
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_1.js]
|
||||
"use strict";
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(2,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(3,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
tests/cases/compiler/client.ts(4,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(5,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(5,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
tests/cases/compiler/client.ts(6,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(7,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(7,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'.
|
||||
tests/cases/compiler/client.ts(7,37): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(9,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'.
|
||||
tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'.
|
||||
tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/server.ts (0 errors) ====
|
||||
|
@ -17,23 +23,29 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil
|
|||
var a = 10;
|
||||
export default a;
|
||||
|
||||
==== tests/cases/compiler/client.ts (12 errors) ====
|
||||
==== tests/cases/compiler/client.ts (18 errors) ====
|
||||
export import defaultBinding1, { } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = defaultBinding1;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding2, { a } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
export var x1: number = defaultBinding2;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding3, { a as b } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
export var x1: number = defaultBinding3;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding4, { x, a as y } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
|
@ -42,16 +54,22 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil
|
|||
~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'.
|
||||
export var x1: number = defaultBinding4;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding5, { x as z, } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'.
|
||||
export var x1: number = defaultBinding5;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding6, { m, } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'.
|
||||
export var x1: number = defaultBinding6;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(3,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(5,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(7,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/server.ts (0 errors) ====
|
||||
|
@ -13,7 +19,7 @@ tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot
|
|||
export var m = a;
|
||||
export default {};
|
||||
|
||||
==== tests/cases/compiler/client.ts (6 errors) ====
|
||||
==== tests/cases/compiler/client.ts (12 errors) ====
|
||||
export import defaultBinding1, { } from "server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
|
@ -21,21 +27,33 @@ tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot
|
|||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = a;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding3, { a as b } from "server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = b;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding4, { x, a as y } from "server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = x;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export var x1: number = y;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding5, { x as z, } from "server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = z;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
export import defaultBinding6, { m, } from "server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var x1: number = m;
|
||||
~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'x1'.
|
||||
|
|
@ -1,11 +1,21 @@
|
|||
tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(3,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(5,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(7,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(13,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(14,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(15,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(16,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(17,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(18,12): error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
tests/cases/compiler/client.ts(19,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(21,1): error TS1191: An import declaration cannot have modifiers.
|
||||
tests/cases/compiler/client.ts(25,1): error TS1191: An import declaration cannot have modifiers.
|
||||
|
@ -23,7 +33,7 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot
|
|||
export var z2 = 10;
|
||||
export var aaaa = 10;
|
||||
|
||||
==== tests/cases/compiler/client.ts (12 errors) ====
|
||||
==== tests/cases/compiler/client.ts (22 errors) ====
|
||||
export import { } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
|
@ -31,33 +41,53 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot
|
|||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = a;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { a as b } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = b;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { x, a as y } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = x;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export var xxxx = y;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { x as z, } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = z;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { m, } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = m;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { a1, x1 } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = a1;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export var xxxx = x1;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { a1 as a11, x1 as x11 } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
export var xxxx = a11;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export var xxxx = x11;
|
||||
~~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'xxxx'.
|
||||
export import { z1 } from "./server";
|
||||
~~~~~~
|
||||
!!! error TS1191: An import declaration cannot have modifiers.
|
||||
|
|
|
@ -58,7 +58,6 @@ export var M;
|
|||
// alias
|
||||
M.M_A = M_M;
|
||||
})(M || (M = {}));
|
||||
export var M;
|
||||
(function (M) {
|
||||
// Reexports
|
||||
export { M_V as v };
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
|
||||
|
@ -16,10 +18,14 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/c
|
|||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ====
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (2 errors) ====
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
|
||||
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export.
|
||||
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
|
||||
|
@ -16,10 +18,14 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/c
|
|||
var z = "z";
|
||||
export { x, y, z };
|
||||
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ====
|
||||
==== tests/cases/conformance/es6/modules/t4.ts (2 errors) ====
|
||||
export * from "./t1";
|
||||
export * from "./t2";
|
||||
export * from "./t3";
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
|
||||
|
||||
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
|
||||
import hello, { x, y, z, foo } from "./t4";
|
||||
|
|
|
@ -41,6 +41,7 @@ export { a, b, c, d, e1, e2, f1, f2 };
|
|||
|
||||
//// [t1.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = "hello";
|
||||
//// [t3.js]
|
||||
"use strict";
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
//// [extendConstructSignatureInInterface.ts]
|
||||
interface C {
|
||||
new(x: number): C;
|
||||
}
|
||||
|
||||
var CStatic: C;
|
||||
class E extends CStatic {
|
||||
}
|
||||
|
||||
var e: E = new E(1);
|
||||
|
||||
|
||||
//// [extendConstructSignatureInInterface.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 CStatic;
|
||||
var E = (function (_super) {
|
||||
__extends(E, _super);
|
||||
function E() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return E;
|
||||
})(CStatic);
|
||||
var e = new E(1);
|
|
@ -0,0 +1,23 @@
|
|||
=== tests/cases/compiler/extendConstructSignatureInInterface.ts ===
|
||||
interface C {
|
||||
>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0))
|
||||
|
||||
new(x: number): C;
|
||||
>x : Symbol(x, Decl(extendConstructSignatureInInterface.ts, 1, 8))
|
||||
>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0))
|
||||
}
|
||||
|
||||
var CStatic: C;
|
||||
>CStatic : Symbol(CStatic, Decl(extendConstructSignatureInInterface.ts, 4, 3))
|
||||
>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0))
|
||||
|
||||
class E extends CStatic {
|
||||
>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15))
|
||||
>CStatic : Symbol(CStatic, Decl(extendConstructSignatureInInterface.ts, 4, 3))
|
||||
}
|
||||
|
||||
var e: E = new E(1);
|
||||
>e : Symbol(e, Decl(extendConstructSignatureInInterface.ts, 8, 3))
|
||||
>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15))
|
||||
>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15))
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/compiler/extendConstructSignatureInInterface.ts ===
|
||||
interface C {
|
||||
>C : C
|
||||
|
||||
new(x: number): C;
|
||||
>x : number
|
||||
>C : C
|
||||
}
|
||||
|
||||
var CStatic: C;
|
||||
>CStatic : C
|
||||
>C : C
|
||||
|
||||
class E extends CStatic {
|
||||
>E : E
|
||||
>CStatic : C
|
||||
}
|
||||
|
||||
var e: E = new E(1);
|
||||
>e : E
|
||||
>E : E
|
||||
>new E(1) : E
|
||||
>E : typeof E
|
||||
>1 : number
|
||||
|
|
@ -10,7 +10,7 @@ function foo() {
|
|||
|
||||
|
||||
//// [a.js]
|
||||
define("tests/cases/compiler/a", ["require", "exports"], function (require, exports) {
|
||||
define("a", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var c = (function () {
|
||||
function c() {
|
||||
|
|
|
@ -3,15 +3,21 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
|
|||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(23,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'Function' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(24,15): error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string[]' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(25,15): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'typeof C' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(26,15): error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'new (x: string) => string' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(28,16): error TS2345: Argument of type '<U, V>(x: U, y: V) => U' is not assignable to parameter of type '(x: string) => string'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(29,16): error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'typeof C2' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(30,16): error TS2345: Argument of type 'new <T>(x: T) => T' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'new <T>(x: T) => T' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(34,16): error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type 'F2' provides no match for the signature '(x: string): string'
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(36,38): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
|
||||
Type '() => void' is not assignable to type '(x: string) => string'.
|
||||
|
@ -51,6 +57,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
|
|||
var r = foo2(new Function());
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'Function' provides no match for the signature '(x: string): string'
|
||||
var r2 = foo2((x: string[]) => x);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'.
|
||||
|
@ -59,9 +66,11 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
|
|||
var r6 = foo2(C);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'typeof C' provides no match for the signature '(x: string): string'
|
||||
var r7 = foo2(b);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'new (x: string) => string' provides no match for the signature '(x: string): string'
|
||||
var r8 = foo2(<U>(x: U) => x); // no error expected
|
||||
var r11 = foo2(<U, V>(x: U, y: V) => x);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -69,15 +78,18 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
|
|||
var r13 = foo2(C2);
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'typeof C2' provides no match for the signature '(x: string): string'
|
||||
var r14 = foo2(b2);
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'new <T>(x: T) => T' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'new <T>(x: T) => T' provides no match for the signature '(x: string): string'
|
||||
|
||||
interface F2 extends Function { foo: string; }
|
||||
var f2: F2;
|
||||
var r16 = foo2(f2);
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'.
|
||||
!!! error TS2345: Type 'F2' provides no match for the signature '(x: string): string'
|
||||
|
||||
function fff<T extends { (): void }, U extends T>(x: T, y: U) {
|
||||
~~~~~~~~~~~
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'.
|
||||
Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>'
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts (1 errors) ====
|
||||
|
@ -10,4 +11,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): erro
|
|||
} ()
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'.
|
||||
!!! error TS2322: Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>'
|
||||
}
|
32
tests/baselines/reference/genericSignatureIdentity.js
Normal file
32
tests/baselines/reference/genericSignatureIdentity.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
//// [genericSignatureIdentity.ts]
|
||||
// This test is here to remind us of our current limits of type identity checking.
|
||||
// Ideally all of the below declarations would be considered different (and thus errors)
|
||||
// but they aren't because we erase type parameters to type any and don't check that
|
||||
// constraints are identical.
|
||||
|
||||
var x: {
|
||||
<T extends Date>(x: T): T;
|
||||
};
|
||||
|
||||
var x: {
|
||||
<T extends number>(x: T): T;
|
||||
};
|
||||
|
||||
var x: {
|
||||
<T>(x: T): T;
|
||||
};
|
||||
|
||||
var x: {
|
||||
<T>(x: any): any;
|
||||
};
|
||||
|
||||
|
||||
//// [genericSignatureIdentity.js]
|
||||
// This test is here to remind us of our current limits of type identity checking.
|
||||
// Ideally all of the below declarations would be considered different (and thus errors)
|
||||
// but they aren't because we erase type parameters to type any and don't check that
|
||||
// constraints are identical.
|
||||
var x;
|
||||
var x;
|
||||
var x;
|
||||
var x;
|
49
tests/baselines/reference/genericSignatureIdentity.symbols
Normal file
49
tests/baselines/reference/genericSignatureIdentity.symbols
Normal file
|
@ -0,0 +1,49 @@
|
|||
=== tests/cases/compiler/genericSignatureIdentity.ts ===
|
||||
// This test is here to remind us of our current limits of type identity checking.
|
||||
// Ideally all of the below declarations would be considered different (and thus errors)
|
||||
// but they aren't because we erase type parameters to type any and don't check that
|
||||
// constraints are identical.
|
||||
|
||||
var x: {
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3))
|
||||
|
||||
<T extends Date>(x: T): T;
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5))
|
||||
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 6, 21))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5))
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3))
|
||||
|
||||
<T extends number>(x: T): T;
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5))
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 10, 23))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5))
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3))
|
||||
|
||||
<T>(x: T): T;
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5))
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 14, 8))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5))
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5))
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3))
|
||||
|
||||
<T>(x: any): any;
|
||||
>T : Symbol(T, Decl(genericSignatureIdentity.ts, 18, 5))
|
||||
>x : Symbol(x, Decl(genericSignatureIdentity.ts, 18, 8))
|
||||
|
||||
};
|
||||
|
49
tests/baselines/reference/genericSignatureIdentity.types
Normal file
49
tests/baselines/reference/genericSignatureIdentity.types
Normal file
|
@ -0,0 +1,49 @@
|
|||
=== tests/cases/compiler/genericSignatureIdentity.ts ===
|
||||
// This test is here to remind us of our current limits of type identity checking.
|
||||
// Ideally all of the below declarations would be considered different (and thus errors)
|
||||
// but they aren't because we erase type parameters to type any and don't check that
|
||||
// constraints are identical.
|
||||
|
||||
var x: {
|
||||
>x : <T extends Date>(x: T) => T
|
||||
|
||||
<T extends Date>(x: T): T;
|
||||
>T : T
|
||||
>Date : Date
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : <T extends Date>(x: T) => T
|
||||
|
||||
<T extends number>(x: T): T;
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : <T extends Date>(x: T) => T
|
||||
|
||||
<T>(x: T): T;
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
};
|
||||
|
||||
var x: {
|
||||
>x : <T extends Date>(x: T) => T
|
||||
|
||||
<T>(x: any): any;
|
||||
>T : T
|
||||
>x : any
|
||||
|
||||
};
|
||||
|
|
@ -14,17 +14,24 @@ tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected.
|
|||
tests/cases/compiler/intTypeCheck.ts(106,21): error TS2304: Cannot find name 'i1'.
|
||||
tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'.
|
||||
Type '{}' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(113,5): error TS2322: Type 'Object' is not assignable to type 'i2'.
|
||||
Type 'Object' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(114,17): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not assignable to type 'i2'.
|
||||
Type 'Base' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'.
|
||||
tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(120,22): error TS2304: Cannot find name 'i2'.
|
||||
tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'.
|
||||
Type '{}' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(127,5): error TS2322: Type 'Object' is not assignable to type 'i3'.
|
||||
Type 'Object' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(129,5): error TS2322: Type 'Base' is not assignable to type 'i3'.
|
||||
Type 'Base' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is not assignable to type 'i3'.
|
||||
Type '() => void' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'.
|
||||
tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'.
|
||||
|
@ -50,9 +57,12 @@ tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected.
|
|||
tests/cases/compiler/intTypeCheck.ts(162,22): error TS2304: Cannot find name 'i5'.
|
||||
tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'.
|
||||
Type '{}' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(169,5): error TS2322: Type 'Object' is not assignable to type 'i6'.
|
||||
Type 'Object' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(170,17): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
tests/cases/compiler/intTypeCheck.ts(171,5): error TS2322: Type 'Base' is not assignable to type 'i6'.
|
||||
Type 'Base' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is not assignable to type 'i6'.
|
||||
Type 'void' is not assignable to type 'number'.
|
||||
tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'.
|
||||
|
@ -60,9 +70,13 @@ tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected.
|
|||
tests/cases/compiler/intTypeCheck.ts(176,22): error TS2304: Cannot find name 'i6'.
|
||||
tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'.
|
||||
Type '{}' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(183,5): error TS2322: Type 'Object' is not assignable to type 'i7'.
|
||||
Type 'Object' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(185,17): error TS2352: Neither type 'Base' nor type 'i7' is assignable to the other.
|
||||
Type 'Base' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is not assignable to type 'i7'.
|
||||
Type '() => void' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'.
|
||||
tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'.
|
||||
|
@ -216,15 +230,18 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
|||
var obj12: i2 = {};
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'i2'.
|
||||
!!! error TS2322: Type '{}' provides no match for the signature '(): any'
|
||||
var obj13: i2 = new Object();
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'i2'.
|
||||
!!! error TS2322: Type 'Object' provides no match for the signature '(): any'
|
||||
var obj14: i2 = new obj11;
|
||||
~~~~~~~~~
|
||||
!!! error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
var obj15: i2 = new Base;
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Base' is not assignable to type 'i2'.
|
||||
!!! error TS2322: Type 'Base' provides no match for the signature '(): any'
|
||||
var obj16: i2 = null;
|
||||
var obj17: i2 = function ():any { return 0; };
|
||||
//var obj18: i2 = function foo() { };
|
||||
|
@ -246,17 +263,21 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
|||
var obj23: i3 = {};
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'i3'.
|
||||
!!! error TS2322: Type '{}' provides no match for the signature 'new (): any'
|
||||
var obj24: i3 = new Object();
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'i3'.
|
||||
!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any'
|
||||
var obj25: i3 = new obj22;
|
||||
var obj26: i3 = new Base;
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Base' is not assignable to type 'i3'.
|
||||
!!! error TS2322: Type 'Base' provides no match for the signature 'new (): any'
|
||||
var obj27: i3 = null;
|
||||
var obj28: i3 = function () { };
|
||||
~~~~~
|
||||
!!! error TS2322: Type '() => void' is not assignable to type 'i3'.
|
||||
!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any'
|
||||
//var obj29: i3 = function foo() { };
|
||||
var obj30: i3 = <i3> anyVar;
|
||||
var obj31: i3 = new <i3> anyVar;
|
||||
|
@ -338,15 +359,18 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
|||
var obj56: i6 = {};
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'i6'.
|
||||
!!! error TS2322: Type '{}' provides no match for the signature '(): any'
|
||||
var obj57: i6 = new Object();
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'i6'.
|
||||
!!! error TS2322: Type 'Object' provides no match for the signature '(): any'
|
||||
var obj58: i6 = new obj55;
|
||||
~~~~~~~~~
|
||||
!!! error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
var obj59: i6 = new Base;
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Base' is not assignable to type 'i6'.
|
||||
!!! error TS2322: Type 'Base' provides no match for the signature '(): any'
|
||||
var obj60: i6 = null;
|
||||
var obj61: i6 = function () { };
|
||||
~~~~~
|
||||
|
@ -371,17 +395,21 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
|||
var obj67: i7 = {};
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'i7'.
|
||||
!!! error TS2322: Type '{}' provides no match for the signature 'new (): any'
|
||||
var obj68: i7 = new Object();
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'i7'.
|
||||
!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any'
|
||||
var obj69: i7 = new obj66;
|
||||
var obj70: i7 = <i7>new Base;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2352: Neither type 'Base' nor type 'i7' is assignable to the other.
|
||||
!!! error TS2352: Type 'Base' provides no match for the signature 'new (): any'
|
||||
var obj71: i7 = null;
|
||||
var obj72: i7 = function () { };
|
||||
~~~~~
|
||||
!!! error TS2322: Type '() => void' is not assignable to type 'i7'.
|
||||
!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any'
|
||||
//var obj73: i7 = function foo() { };
|
||||
var obj74: i7 = <i7> anyVar;
|
||||
var obj75: i7 = new <i7> anyVar;
|
||||
|
|
|
@ -3,6 +3,7 @@ tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2420: Class 'C1'
|
|||
tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2420: Class 'C1' incorrectly implements interface 'I2'.
|
||||
Property 'iFn' is private in type 'C1' but not in type 'I2'.
|
||||
tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2322: Type '() => C2' is not assignable to type 'I4'.
|
||||
Type '() => C2' provides no match for the signature 'new (): I3'
|
||||
|
||||
|
||||
==== tests/cases/compiler/interfaceImplementation1.ts (3 errors) ====
|
||||
|
@ -48,6 +49,7 @@ tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2322: Type '() =
|
|||
var a:I4 = function(){
|
||||
~
|
||||
!!! error TS2322: Type '() => C2' is not assignable to type 'I4'.
|
||||
!!! error TS2322: Type '() => C2' provides no match for the signature 'new (): I3'
|
||||
return new C2();
|
||||
}
|
||||
new a();
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: '=' expected.
|
||||
tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1005: ',' expected.
|
||||
tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(7,1): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (3 errors) ====
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
|
||||
var let = 10;
|
||||
for (let of [1,2,3]) {}
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
|
||||
for (let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
|
||||
|
18
tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js
Normal file
18
tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//// [invalidLetInForOfAndForIn_ES5.ts]
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
|
||||
var let = 10;
|
||||
for (let of [1,2,3]) {}
|
||||
|
||||
for (let in [1,2,3]) {}
|
||||
|
||||
|
||||
|
||||
|
||||
//// [invalidLetInForOfAndForIn_ES5.js]
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
var let = 10;
|
||||
for (let of = [1, 2, 3], { }; ; )
|
||||
for ( in [1, 2, 3]) { }
|
|
@ -0,0 +1,22 @@
|
|||
tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: '=' expected.
|
||||
tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1005: ',' expected.
|
||||
tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(7,1): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (3 errors) ====
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
|
||||
var let = 10;
|
||||
for (let of [1,2,3]) {}
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
|
||||
for (let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
|
||||
|
18
tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js
Normal file
18
tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//// [invalidLetInForOfAndForIn_ES6.ts]
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
|
||||
var let = 10;
|
||||
for (let of [1,2,3]) {}
|
||||
|
||||
for (let in [1,2,3]) {}
|
||||
|
||||
|
||||
|
||||
|
||||
//// [invalidLetInForOfAndForIn_ES6.js]
|
||||
// This should be an error
|
||||
// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements
|
||||
var let = 10;
|
||||
for (let of = [1, 2, 3], { }; ; )
|
||||
for ( in [1, 2, 3]) { }
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/compiler/a.js(1,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/a.js(2,7): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (2 errors) ====
|
||||
var a = 10;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
class a {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
tests/cases/compiler/a.js(1,5): error TS2451: Cannot redeclare block-scoped variable 'C'.
|
||||
tests/cases/compiler/a.js(2,5): error TS2451: Cannot redeclare block-scoped variable 'C'.
|
||||
tests/cases/compiler/a.js(6,5): error TS7027: Unreachable code detected.
|
||||
tests/cases/compiler/a.js(11,9): error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (4 errors) ====
|
||||
let C = "sss";
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'C'.
|
||||
let C = 0; // Error: Cannot redeclare block-scoped variable 'C'.
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'C'.
|
||||
|
||||
function f() {
|
||||
return;
|
||||
return; // Error: Unreachable code detected.
|
||||
~~~~~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
}
|
||||
|
||||
function b() {
|
||||
"use strict";
|
||||
var arguments = 0; // Error: Invalid use of 'arguments' in strict mode.
|
||||
~~~~~~~~~
|
||||
!!! error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
=== tests/cases/compiler/a.js ===
|
||||
let C = "sss";
|
||||
>C : Symbol(C, Decl(a.js, 0, 3))
|
||||
|
||||
let C = 0; // Error: Cannot redeclare block-scoped variable 'C'.
|
||||
>C : Symbol(C, Decl(a.js, 1, 3))
|
||||
|
||||
function f() {
|
||||
>f : Symbol(f, Decl(a.js, 1, 10))
|
||||
|
||||
return;
|
||||
return; // Error: Unreachable code detected.
|
||||
}
|
||||
|
||||
function b() {
|
||||
>b : Symbol(b, Decl(a.js, 6, 1))
|
||||
|
||||
"use strict";
|
||||
var arguments = 0; // Error: Invalid use of 'arguments' in strict mode.
|
||||
>arguments : Symbol(arguments, Decl(a.js, 10, 7))
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
=== tests/cases/compiler/a.js ===
|
||||
let C = "sss";
|
||||
>C : string
|
||||
>"sss" : string
|
||||
|
||||
let C = 0; // Error: Cannot redeclare block-scoped variable 'C'.
|
||||
>C : number
|
||||
>0 : number
|
||||
|
||||
function f() {
|
||||
>f : () => void
|
||||
|
||||
return;
|
||||
return; // Error: Unreachable code detected.
|
||||
}
|
||||
|
||||
function b() {
|
||||
>b : () => void
|
||||
|
||||
"use strict";
|
||||
>"use strict" : string
|
||||
|
||||
var arguments = 0; // Error: Invalid use of 'arguments' in strict mode.
|
||||
>arguments : number
|
||||
>0 : number
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
tests/cases/compiler/a.js(1,22): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/compiler/a.js(3,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/compiler/a.js(3,1): error TS8003: 'export=' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.js(3,16): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (4 errors) ====
|
||||
export default class a {
|
||||
~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
}
|
||||
export default var a = 10;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS8003: 'export=' can only be used in a .ts file.
|
||||
~~~
|
||||
!!! error TS1109: Expression expected.
|
|
@ -0,0 +1,31 @@
|
|||
tests/cases/compiler/a.js(3,9): error TS7029: Fallthrough case in switch.
|
||||
tests/cases/compiler/a.js(16,5): error TS7027: Unreachable code detected.
|
||||
tests/cases/compiler/a.js(19,1): error TS7028: Unused label.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (3 errors) ====
|
||||
function foo(a, b) {
|
||||
switch (a) {
|
||||
case 10:
|
||||
~~~~
|
||||
!!! error TS7029: Fallthrough case in switch.
|
||||
if (b) {
|
||||
return b;
|
||||
}
|
||||
case 20:
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
function bar() {
|
||||
return x;
|
||||
function bar2() {
|
||||
}
|
||||
var x = 10; // error
|
||||
~~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
}
|
||||
|
||||
label1: var x2 = 10;
|
||||
~~~~~~
|
||||
!!! error TS7028: Unused label.
|
|
@ -0,0 +1,81 @@
|
|||
tests/cases/compiler/a.js(3,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/a.js(5,5): error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
|
||||
tests/cases/compiler/a.js(5,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/a.js(7,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
|
||||
tests/cases/compiler/a.js(8,8): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/compiler/a.js(10,10): error TS1100: Invalid use of 'eval' in strict mode.
|
||||
tests/cases/compiler/a.js(12,10): error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
tests/cases/compiler/a.js(15,1): error TS1101: 'with' statements are not allowed in strict mode.
|
||||
tests/cases/compiler/b.js(3,7): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode.
|
||||
tests/cases/compiler/b.js(6,13): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
|
||||
tests/cases/compiler/c.js(1,12): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/compiler/c.js(2,5): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
|
||||
tests/cases/compiler/d.js(2,9): error TS1121: Octal literals are not allowed in strict mode.
|
||||
tests/cases/compiler/d.js(2,11): error TS1005: ',' expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (8 errors) ====
|
||||
"use strict";
|
||||
var a = {
|
||||
a: "hello", // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
b: 10,
|
||||
a: 10 // error
|
||||
~
|
||||
!!! error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
};
|
||||
var let = 10; // error
|
||||
~~~
|
||||
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
|
||||
delete a; // error
|
||||
~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
try {
|
||||
} catch (eval) { // error
|
||||
~~~~
|
||||
!!! error TS1100: Invalid use of 'eval' in strict mode.
|
||||
}
|
||||
function arguments() { // error
|
||||
~~~~~~~~~
|
||||
!!! error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
}
|
||||
|
||||
with (a) {
|
||||
~~~~
|
||||
!!! error TS1101: 'with' statements are not allowed in strict mode.
|
||||
b = 10;
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.js (2 errors) ====
|
||||
// this is not in strict mode but class definitions are always in strict mode
|
||||
class c {
|
||||
a(eval) { //error
|
||||
~~~~
|
||||
!!! error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode.
|
||||
}
|
||||
method() {
|
||||
var let = 10; // error
|
||||
~~~
|
||||
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/c.js (2 errors) ====
|
||||
export var let = 10; // external modules are automatically in strict mode
|
||||
~~~
|
||||
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
var eval = function () {
|
||||
~~~~
|
||||
!!! error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
|
||||
};
|
||||
|
||||
==== tests/cases/compiler/d.js (2 errors) ====
|
||||
"use strict";
|
||||
var x = 009; // error
|
||||
~~
|
||||
!!! error TS1121: Octal literals are not allowed in strict mode.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
|
@ -1,9 +1,12 @@
|
|||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
tests/cases/compiler/a.js(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
|
||||
tests/cases/compiler/a.js(1,1): error TS8003: 'export=' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
==== tests/cases/compiler/a.js (2 errors) ====
|
||||
export = b;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS8003: 'export=' can only be used in a .ts file.
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/compiler/moduleA/a.js(2,17): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/b.ts' is not a module. Please contact the package author to update the package definition.
|
||||
|
||||
|
||||
==== tests/cases/compiler/moduleA/a.js (1 errors) ====
|
||||
|
||||
import {a} from "b";
|
||||
~~~
|
||||
!!! error TS2656: Exported external package typings file 'b.ts' is not a module. Please contact the package author to update the package definition.
|
||||
a++;
|
||||
import {c} from "c";
|
||||
c++;
|
||||
|
||||
==== tests/cases/compiler/node_modules/b.ts (0 errors) ====
|
||||
var a = 10;
|
||||
|
||||
==== tests/cases/compiler/node_modules/c.js (0 errors) ====
|
||||
exports.a = 10;
|
||||
c = 10;
|
||||
|
6
tests/baselines/reference/letAsIdentifier2.js
Normal file
6
tests/baselines/reference/letAsIdentifier2.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
//// [letAsIdentifier2.ts]
|
||||
|
||||
function let() {}
|
||||
|
||||
//// [letAsIdentifier2.js]
|
||||
function let() { }
|
5
tests/baselines/reference/letAsIdentifier2.symbols
Normal file
5
tests/baselines/reference/letAsIdentifier2.symbols
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/compiler/letAsIdentifier2.ts ===
|
||||
|
||||
function let() {}
|
||||
>let : Symbol(let, Decl(letAsIdentifier2.ts, 0, 0))
|
||||
|
5
tests/baselines/reference/letAsIdentifier2.types
Normal file
5
tests/baselines/reference/letAsIdentifier2.types
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/compiler/letAsIdentifier2.ts ===
|
||||
|
||||
function let() {}
|
||||
>let : () => void
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/compiler/letInConstDeclarations_ES5.ts(3,15): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInConstDeclarations_ES5.ts(6,19): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInConstDeclarations_ES5.ts (2 errors) ====
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
const x = 50, let = 5;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
const x = 10, let = 20;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
15
tests/baselines/reference/letInConstDeclarations_ES5.js
Normal file
15
tests/baselines/reference/letInConstDeclarations_ES5.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [letInConstDeclarations_ES5.ts]
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
const x = 50, let = 5;
|
||||
|
||||
{
|
||||
const x = 10, let = 20;
|
||||
}
|
||||
|
||||
//// [letInConstDeclarations_ES5.js]
|
||||
// All use of let in const declaration should be an error
|
||||
var x = 50, let = 5;
|
||||
{
|
||||
var x_1 = 10, let_1 = 20;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/compiler/letInConstDeclarations_ES6.ts(3,15): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInConstDeclarations_ES6.ts(6,19): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInConstDeclarations_ES6.ts (2 errors) ====
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
const x = 50, let = 5;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
const x = 10, let = 20;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
15
tests/baselines/reference/letInConstDeclarations_ES6.js
Normal file
15
tests/baselines/reference/letInConstDeclarations_ES6.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [letInConstDeclarations_ES6.ts]
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
const x = 50, let = 5;
|
||||
|
||||
{
|
||||
const x = 10, let = 20;
|
||||
}
|
||||
|
||||
//// [letInConstDeclarations_ES6.js]
|
||||
// All use of let in const declaration should be an error
|
||||
const x = 50, let = 5;
|
||||
{
|
||||
const x = 10, let = 20;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(3,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(5,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(7,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(9,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(12,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(14,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(16,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(18,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts (8 errors) ====
|
||||
|
||||
// Should be an error
|
||||
for (let let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
for (let let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
//// [letInLetConstDeclOfForOfAndForIn_ES5.ts]
|
||||
|
||||
// Should be an error
|
||||
for (let let of [1,2,3]) {}
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
|
||||
{
|
||||
for (let let of [1,2,3]) {}
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [letInLetConstDeclOfForOfAndForIn_ES5.js]
|
||||
// Should be an error
|
||||
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
|
||||
var let = _a[_i];
|
||||
}
|
||||
for (var _b = 0, _c = [1, 2, 3]; _b < _c.length; _b++) {
|
||||
var let = _c[_b];
|
||||
}
|
||||
for (var let in [1, 2, 3]) { }
|
||||
for (var let in [1, 2, 3]) { }
|
||||
{
|
||||
for (var _d = 0, _e = [1, 2, 3]; _d < _e.length; _d++) {
|
||||
var let = _e[_d];
|
||||
}
|
||||
for (var _f = 0, _g = [1, 2, 3]; _f < _g.length; _f++) {
|
||||
var let = _g[_f];
|
||||
}
|
||||
for (var let in [1, 2, 3]) { }
|
||||
for (var let in [1, 2, 3]) { }
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(3,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(5,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(7,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(9,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(12,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(14,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(16,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(18,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts (8 errors) ====
|
||||
|
||||
// Should be an error
|
||||
for (let let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
for (let let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//// [letInLetConstDeclOfForOfAndForIn_ES6.ts]
|
||||
|
||||
// Should be an error
|
||||
for (let let of [1,2,3]) {}
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
|
||||
{
|
||||
for (let let of [1,2,3]) {}
|
||||
|
||||
for (const let of [1,2,3]) {}
|
||||
|
||||
for (let let in [1,2,3]) {}
|
||||
|
||||
for (const let in [1,2,3]) {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [letInLetConstDeclOfForOfAndForIn_ES6.js]
|
||||
// Should be an error
|
||||
for (let let of [1, 2, 3]) { }
|
||||
for (const let of [1, 2, 3]) { }
|
||||
for (let let in [1, 2, 3]) { }
|
||||
for (const let in [1, 2, 3]) { }
|
||||
{
|
||||
for (let let of [1, 2, 3]) { }
|
||||
for (const let of [1, 2, 3]) { }
|
||||
for (let let in [1, 2, 3]) { }
|
||||
for (const let in [1, 2, 3]) { }
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/compiler/letInLetDeclarations_ES5.ts(3,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetDeclarations_ES5.ts(6,17): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInLetDeclarations_ES5.ts (2 errors) ====
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
let x = 50, let = 5;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
let x = 10, let = 20;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
15
tests/baselines/reference/letInLetDeclarations_ES5.js
Normal file
15
tests/baselines/reference/letInLetDeclarations_ES5.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [letInLetDeclarations_ES5.ts]
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
let x = 50, let = 5;
|
||||
|
||||
{
|
||||
let x = 10, let = 20;
|
||||
}
|
||||
|
||||
//// [letInLetDeclarations_ES5.js]
|
||||
// All use of let in const declaration should be an error
|
||||
var x = 50, let = 5;
|
||||
{
|
||||
var x_1 = 10, let_1 = 20;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/compiler/letInLetDeclarations_ES6.ts(3,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetDeclarations_ES6.ts(6,17): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInLetDeclarations_ES6.ts (2 errors) ====
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
let x = 50, let = 5;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
{
|
||||
let x = 10, let = 20;
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
15
tests/baselines/reference/letInLetDeclarations_ES6.js
Normal file
15
tests/baselines/reference/letInLetDeclarations_ES6.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [letInLetDeclarations_ES6.ts]
|
||||
|
||||
// All use of let in const declaration should be an error
|
||||
let x = 50, let = 5;
|
||||
|
||||
{
|
||||
let x = 10, let = 20;
|
||||
}
|
||||
|
||||
//// [letInLetDeclarations_ES6.js]
|
||||
// All use of let in const declaration should be an error
|
||||
let x = 50, let = 5;
|
||||
{
|
||||
let x = 10, let = 20;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
tests/cases/compiler/letInLetOrConstDeclarations.ts(2,9): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetOrConstDeclarations.ts(3,14): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/compiler/letInLetOrConstDeclarations.ts(6,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letInLetOrConstDeclarations.ts (3 errors) ====
|
||||
{
|
||||
let let = 1; // should error
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
for (let let in []) { } // should error
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
||||
{
|
||||
const let = 1; // should error
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
}
|
||||
{
|
||||
function let() { // should be ok
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
//// [letInLetOrConstDeclarations.ts]
|
||||
{
|
||||
let let = 1; // should error
|
||||
for (let let in []) { } // should error
|
||||
}
|
||||
{
|
||||
const let = 1; // should error
|
||||
}
|
||||
{
|
||||
function let() { // should be ok
|
||||
}
|
||||
}
|
||||
|
||||
//// [letInLetOrConstDeclarations.js]
|
||||
{
|
||||
let let = 1; // should error
|
||||
for (let let in []) { } // should error
|
||||
}
|
||||
{
|
||||
const let = 1; // should error
|
||||
}
|
||||
{
|
||||
function let() {
|
||||
}
|
||||
}
|
16
tests/baselines/reference/letInVarDeclOfForIn_ES5.js
Normal file
16
tests/baselines/reference/letInVarDeclOfForIn_ES5.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [letInVarDeclOfForIn_ES5.ts]
|
||||
|
||||
// should not be an error
|
||||
for (var let in [1,2,3]) {}
|
||||
|
||||
{
|
||||
for (var let in [1,2,3]) {}
|
||||
}
|
||||
|
||||
|
||||
//// [letInVarDeclOfForIn_ES5.js]
|
||||
// should not be an error
|
||||
for (var let in [1, 2, 3]) { }
|
||||
{
|
||||
for (var let in [1, 2, 3]) { }
|
||||
}
|
11
tests/baselines/reference/letInVarDeclOfForIn_ES5.symbols
Normal file
11
tests/baselines/reference/letInVarDeclOfForIn_ES5.symbols
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/letInVarDeclOfForIn_ES5.ts ===
|
||||
|
||||
// should not be an error
|
||||
for (var let in [1,2,3]) {}
|
||||
>let : Symbol(let, Decl(letInVarDeclOfForIn_ES5.ts, 2, 8), Decl(letInVarDeclOfForIn_ES5.ts, 5, 9))
|
||||
|
||||
{
|
||||
for (var let in [1,2,3]) {}
|
||||
>let : Symbol(let, Decl(letInVarDeclOfForIn_ES5.ts, 2, 8), Decl(letInVarDeclOfForIn_ES5.ts, 5, 9))
|
||||
}
|
||||
|
19
tests/baselines/reference/letInVarDeclOfForIn_ES5.types
Normal file
19
tests/baselines/reference/letInVarDeclOfForIn_ES5.types
Normal file
|
@ -0,0 +1,19 @@
|
|||
=== tests/cases/compiler/letInVarDeclOfForIn_ES5.ts ===
|
||||
|
||||
// should not be an error
|
||||
for (var let in [1,2,3]) {}
|
||||
>let : any
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
{
|
||||
for (var let in [1,2,3]) {}
|
||||
>let : any
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue