mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Merge branch 'master' into arozga/RemoveNavBarWhiteSpace
This commit is contained in:
commit
c9b490f234
@ -1007,7 +1007,7 @@ namespace ts {
|
||||
currentFlow = finishFlowLabel(preFinallyLabel);
|
||||
bind(node.finallyBlock);
|
||||
// if flow after finally is unreachable - keep it
|
||||
// otherwise check if flows after try and after catch are unreachable
|
||||
// otherwise check if flows after try and after catch are unreachable
|
||||
// if yes - convert current flow to unreachable
|
||||
// i.e.
|
||||
// try { return "1" } finally { console.log(1); }
|
||||
@ -2421,6 +2421,9 @@ namespace ts {
|
||||
case SyntaxKind.HeritageClause:
|
||||
return computeHeritageClause(<HeritageClause>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return computeCatchClause(<CatchClause>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return computeExpressionWithTypeArguments(<ExpressionWithTypeArguments>node, subtreeFlags);
|
||||
|
||||
@ -2650,6 +2653,17 @@ namespace ts {
|
||||
return transformFlags & ~TransformFlags.NodeExcludes;
|
||||
}
|
||||
|
||||
function computeCatchClause(node: CatchClause, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
|
||||
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
return transformFlags & ~TransformFlags.NodeExcludes;
|
||||
}
|
||||
|
||||
function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) {
|
||||
// An ExpressionWithTypeArguments is ES6 syntax, as it is used in the
|
||||
// extends clause of a class.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -599,7 +599,13 @@ namespace ts {
|
||||
i++;
|
||||
break;
|
||||
case "boolean":
|
||||
options[opt.name] = true;
|
||||
// boolean flag has optional value true, false, others
|
||||
let optValue = args[i];
|
||||
options[opt.name] = optValue !== "false";
|
||||
// consume next argument as boolean flag value
|
||||
if (optValue === "false" || optValue === "true") {
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case "string":
|
||||
options[opt.name] = args[i] || "";
|
||||
@ -906,6 +912,9 @@ namespace ts {
|
||||
if (hasProperty(json, "files")) {
|
||||
if (isArray(json["files"])) {
|
||||
fileNames = <string[]>json["files"];
|
||||
if (fileNames.length === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array"));
|
||||
@ -948,7 +957,18 @@ namespace ts {
|
||||
includeSpecs = ["**/*"];
|
||||
}
|
||||
|
||||
return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
|
||||
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
|
||||
errors.push(
|
||||
createCompilerDiagnostic(
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
configFileName || "tsconfig.json",
|
||||
JSON.stringify(includeSpecs || []),
|
||||
JSON.stringify(excludeSpecs || [])));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -603,10 +603,6 @@
|
||||
"category": "Error",
|
||||
"code": 1194
|
||||
},
|
||||
"Catch clause variable name must be an identifier.": {
|
||||
"category": "Error",
|
||||
"code": 1195
|
||||
},
|
||||
"Catch clause variable cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1196
|
||||
@ -3077,6 +3073,7 @@
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
|
||||
"Circularity detected while resolving configuration: {0}": {
|
||||
"category": "Error",
|
||||
"code": 18000
|
||||
@ -3085,6 +3082,15 @@
|
||||
"category": "Error",
|
||||
"code": 18001
|
||||
},
|
||||
"The 'files' list in config file '{0}' is empty.": {
|
||||
"category": "Error",
|
||||
"code": 18002
|
||||
},
|
||||
"No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 18003
|
||||
},
|
||||
|
||||
"Add missing 'super()' call.": {
|
||||
"category": "Message",
|
||||
"code": 90001
|
||||
|
||||
@ -1625,7 +1625,9 @@ namespace ts {
|
||||
// flag and setting a parent node.
|
||||
const react = createIdentifier(reactNamespace || "React");
|
||||
react.flags &= ~NodeFlags.Synthesized;
|
||||
react.parent = parent;
|
||||
// Set the parent that is in parse tree
|
||||
// this makes sure that parent chain is intact for checker to traverse complete scope tree
|
||||
react.parent = getParseTreeNode(parent);
|
||||
return react;
|
||||
}
|
||||
|
||||
|
||||
@ -5472,7 +5472,7 @@ namespace ts {
|
||||
|
||||
exportDeclaration.name = parseIdentifier();
|
||||
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
parseSemicolon();
|
||||
|
||||
return finishNode(exportDeclaration);
|
||||
}
|
||||
|
||||
@ -362,6 +362,9 @@ namespace ts {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return visitObjectLiteralExpression(<ObjectLiteralExpression>node);
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return visitCatchClause(<CatchClause>node);
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return visitShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
|
||||
|
||||
@ -2622,6 +2625,24 @@ namespace ts {
|
||||
return expression;
|
||||
}
|
||||
|
||||
function visitCatchClause(node: CatchClause): CatchClause {
|
||||
Debug.assert(isBindingPattern(node.variableDeclaration.name));
|
||||
|
||||
const temp = createTempVariable(undefined);
|
||||
const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration);
|
||||
|
||||
const vars = flattenVariableDestructuring(node.variableDeclaration, temp, visitor);
|
||||
const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags);
|
||||
const destructure = createVariableStatement(undefined, list);
|
||||
|
||||
return updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
|
||||
}
|
||||
|
||||
function addStatementToStartOfBlock(block: Block, statement: Statement): Block {
|
||||
const transformedStatements = visitNodes(block.statements, visitor, isStatement);
|
||||
return updateBlock(block, [statement].concat(transformedStatements));
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a
|
||||
* PropertyAssignment.
|
||||
|
||||
@ -2612,24 +2612,17 @@ namespace ts {
|
||||
Null = 1 << 12,
|
||||
Never = 1 << 13, // Never type
|
||||
TypeParameter = 1 << 14, // Type parameter
|
||||
Class = 1 << 15, // Class
|
||||
Interface = 1 << 16, // Interface
|
||||
Reference = 1 << 17, // Generic type reference
|
||||
Tuple = 1 << 18, // Synthesized generic tuple type
|
||||
Union = 1 << 19, // Union (T | U)
|
||||
Intersection = 1 << 20, // Intersection (T & U)
|
||||
Anonymous = 1 << 21, // Anonymous
|
||||
Instantiated = 1 << 22, // Instantiated anonymous type
|
||||
Object = 1 << 15, // Object type
|
||||
Union = 1 << 16, // Union (T | U)
|
||||
Intersection = 1 << 17, // Intersection (T & U)
|
||||
/* @internal */
|
||||
ObjectLiteral = 1 << 23, // Originates in an object literal
|
||||
FreshLiteral = 1 << 18, // Fresh literal type
|
||||
/* @internal */
|
||||
FreshLiteral = 1 << 24, // Fresh literal type
|
||||
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type
|
||||
/* @internal */
|
||||
ContainsWideningType = 1 << 25, // Type is or contains undefined or null widening type
|
||||
ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 1 << 26, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsAnyFunctionType = 1 << 27, // Type is or contains object literal type
|
||||
ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
@ -2646,15 +2639,14 @@ namespace ts {
|
||||
NumberLike = Number | NumberLiteral | Enum | EnumLiteral,
|
||||
BooleanLike = Boolean | BooleanLiteral,
|
||||
EnumLike = Enum | EnumLiteral,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
StructuredType = Object | Union | Intersection,
|
||||
StructuredOrTypeParameter = StructuredType | TypeParameter,
|
||||
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
// This *should* be every type other than null, undefined, void, and never
|
||||
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol,
|
||||
NotUnionOrUnit = Any | ESSymbol | ObjectType,
|
||||
NotUnionOrUnit = Any | ESSymbol | Object,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
|
||||
/* @internal */
|
||||
@ -2697,9 +2689,22 @@ namespace ts {
|
||||
baseType: EnumType & UnionType; // Base enum type
|
||||
}
|
||||
|
||||
export const enum ObjectFlags {
|
||||
Class = 1 << 0, // Class
|
||||
Interface = 1 << 1, // Interface
|
||||
Reference = 1 << 2, // Generic type reference
|
||||
Tuple = 1 << 3, // Synthesized generic tuple type
|
||||
Anonymous = 1 << 4, // Anonymous
|
||||
Instantiated = 1 << 5, // Instantiated anonymous type
|
||||
ObjectLiteral = 1 << 6, // Originates in an object literal
|
||||
EvolvingArray = 1 << 7, // Evolving array type
|
||||
ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties
|
||||
ClassOrInterface = Class | Interface
|
||||
}
|
||||
|
||||
// Object types (TypeFlags.ObjectType)
|
||||
export interface ObjectType extends Type {
|
||||
isObjectLiteralPatternWithComputedProperties?: boolean;
|
||||
objectFlags: ObjectFlags;
|
||||
}
|
||||
|
||||
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
|
||||
@ -2753,13 +2758,18 @@ namespace ts {
|
||||
|
||||
export interface IntersectionType extends UnionOrIntersectionType { }
|
||||
|
||||
export type StructuredType = ObjectType | UnionType | IntersectionType;
|
||||
|
||||
/* @internal */
|
||||
// An instantiated anonymous type has a target and a mapper
|
||||
export interface AnonymousType extends ObjectType {
|
||||
target?: AnonymousType; // Instantiation target
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
elementType?: Type; // Element expressions of evolving array type
|
||||
finalArrayType?: Type; // Final array type of evolving array type
|
||||
}
|
||||
|
||||
export interface EvolvingArrayType extends ObjectType {
|
||||
elementType: Type; // Element expressions of evolving array type
|
||||
finalArrayType?: Type; // Final array type of evolving array type
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@ -406,7 +406,12 @@ namespace ts {
|
||||
|
||||
export function isBlockOrCatchScoped(declaration: Declaration) {
|
||||
return (getCombinedNodeFlags(declaration) & NodeFlags.BlockScoped) !== 0 ||
|
||||
isCatchClauseVariableDeclaration(declaration);
|
||||
isCatchClauseVariableDeclarationOrBindingElement(declaration);
|
||||
}
|
||||
|
||||
export function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration) {
|
||||
const node = getRootDeclaration(declaration);
|
||||
return node.kind === SyntaxKind.VariableDeclaration && node.parent.kind === SyntaxKind.CatchClause;
|
||||
}
|
||||
|
||||
export function isAmbientModule(node: Node): boolean {
|
||||
@ -489,13 +494,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isCatchClauseVariableDeclaration(declaration: Declaration) {
|
||||
return declaration &&
|
||||
declaration.kind === SyntaxKind.VariableDeclaration &&
|
||||
declaration.parent &&
|
||||
declaration.parent.kind === SyntaxKind.CatchClause;
|
||||
}
|
||||
|
||||
// Return display name of an identifier
|
||||
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
||||
// text of the expression in the computed property.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="..\..\compiler\commandLineParser.ts" />
|
||||
|
||||
namespace ts {
|
||||
@ -338,5 +338,38 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse explicit boolean flag value", () => {
|
||||
assertParseResult(["--strictNullChecks", "false", "0.ts"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: ["0.ts"],
|
||||
options: {
|
||||
strictNullChecks: false,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse non boolean argument after boolean flag", () => {
|
||||
assertParseResult(["--noImplicitAny", "t", "0.ts"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: ["t", "0.ts"],
|
||||
options: {
|
||||
noImplicitAny: true,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse implicit boolean flag value", () => {
|
||||
assertParseResult(["--strictNullChecks"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: [],
|
||||
options: {
|
||||
strictNullChecks: true,
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
namespace ts {
|
||||
const caseInsensitiveBasePath = "c:/dev/";
|
||||
const caseInsensitiveTsconfigPath = "c:/dev/tsconfig.json";
|
||||
const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/a.d.ts",
|
||||
@ -88,6 +89,8 @@ namespace ts {
|
||||
"c:/dev/g.min.js/.g/g.ts"
|
||||
]);
|
||||
|
||||
const defaultExcludes = ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
describe("matchFiles", () => {
|
||||
describe("with literal file list", () => {
|
||||
it("without exclusions", () => {
|
||||
@ -189,11 +192,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -207,11 +213,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -551,13 +560,16 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -619,7 +631,7 @@ namespace ts {
|
||||
it("with common package folders and no exclusions", () => {
|
||||
const json = {
|
||||
include: [
|
||||
"**/a.ts"
|
||||
"**/a.ts"
|
||||
]
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
@ -701,13 +713,16 @@ namespace ts {
|
||||
options: {
|
||||
allowJs: false
|
||||
},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
"c:/dev/js": ts.WatchDirectoryFlags.None
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -828,11 +843,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))]
|
||||
,
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1030,12 +1048,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1051,11 +1071,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1071,12 +1094,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1122,12 +1147,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1142,12 +1169,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
@ -1195,7 +1224,7 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..")
|
||||
],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
@ -1320,11 +1349,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
|
||||
@ -28,6 +28,14 @@ namespace ts {
|
||||
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
|
||||
}
|
||||
|
||||
function assertParseFileDiagnostics(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedDiagnosticCode: number) {
|
||||
const json = JSON.parse(jsonText);
|
||||
const host: ParseConfigHost = new Utils.MockParseConfigHost(basePath, true, allFileList);
|
||||
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
|
||||
assert.isTrue(parsed.errors.length >= 0);
|
||||
assert.isTrue(parsed.errors.filter(e => e.code === expectedDiagnosticCode).length > 0, `Expected error code ${expectedDiagnosticCode} to be in ${JSON.stringify(parsed.errors)}`);
|
||||
}
|
||||
|
||||
it("returns empty config for file with only whitespaces", () => {
|
||||
assertParseResult("", { config : {} });
|
||||
assertParseResult(" ", { config : {} });
|
||||
@ -202,5 +210,64 @@ namespace ts {
|
||||
assert.isTrue(diagnostics.length === 2);
|
||||
assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult));
|
||||
});
|
||||
|
||||
it("generates errors for empty files list", () => {
|
||||
const content = `{
|
||||
"files": []
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
|
||||
});
|
||||
|
||||
it("generates errors for directory with no .ts files", () => {
|
||||
const content = `{
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.js"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for empty directory", () => {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
}
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
[],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for empty include", () => {
|
||||
const content = `{
|
||||
"include": []
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for includes with outDir", () => {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"outDir": "./"
|
||||
},
|
||||
"include": ["**/*"]
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -347,6 +347,7 @@ namespace ts {
|
||||
class TypeObject implements Type {
|
||||
checker: TypeChecker;
|
||||
flags: TypeFlags;
|
||||
objectFlags?: ObjectFlags;
|
||||
id: number;
|
||||
symbol: Symbol;
|
||||
constructor(checker: TypeChecker, flags: TypeFlags) {
|
||||
@ -381,7 +382,7 @@ namespace ts {
|
||||
return this.checker.getIndexTypeOfType(this, IndexKind.Number);
|
||||
}
|
||||
getBaseTypes(): ObjectType[] {
|
||||
return this.flags & (TypeFlags.Class | TypeFlags.Interface)
|
||||
return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)
|
||||
? this.checker.getBaseTypes(<InterfaceType><Type>this)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ namespace ts.SymbolDisplay {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
if (!(type.flags & TypeFlags.Anonymous) && type.symbol) {
|
||||
if (!(type.flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous) && type.symbol) {
|
||||
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
}
|
||||
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
|
||||
|
||||
21
tests/baselines/reference/ambientRequireFunction.js
Normal file
21
tests/baselines/reference/ambientRequireFunction.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/ambientRequireFunction.ts] ////
|
||||
|
||||
//// [node.d.ts]
|
||||
|
||||
|
||||
declare function require(moduleName: string): any;
|
||||
|
||||
declare module "fs" {
|
||||
export function readFileSync(s: string): string;
|
||||
}
|
||||
|
||||
//// [app.js]
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
|
||||
//// [app.js]
|
||||
/// <reference path="node.d.ts"/>
|
||||
var fs = require("fs");
|
||||
var text = fs.readFileSync("/a/b/c");
|
||||
27
tests/baselines/reference/ambientRequireFunction.symbols
Normal file
27
tests/baselines/reference/ambientRequireFunction.symbols
Normal file
@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/app.js ===
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : Symbol(fs, Decl(app.js, 2, 5))
|
||||
>require : Symbol(require, Decl(node.d.ts, 0, 0))
|
||||
>"fs" : Symbol("fs", Decl(node.d.ts, 2, 50))
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : Symbol(text, Decl(app.js, 3, 5))
|
||||
>fs.readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21))
|
||||
>fs : Symbol(fs, Decl(app.js, 2, 5))
|
||||
>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21))
|
||||
|
||||
=== tests/cases/compiler/node.d.ts ===
|
||||
|
||||
|
||||
declare function require(moduleName: string): any;
|
||||
>require : Symbol(require, Decl(node.d.ts, 0, 0))
|
||||
>moduleName : Symbol(moduleName, Decl(node.d.ts, 2, 25))
|
||||
|
||||
declare module "fs" {
|
||||
export function readFileSync(s: string): string;
|
||||
>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21))
|
||||
>s : Symbol(s, Decl(node.d.ts, 5, 33))
|
||||
}
|
||||
|
||||
30
tests/baselines/reference/ambientRequireFunction.types
Normal file
30
tests/baselines/reference/ambientRequireFunction.types
Normal file
@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/app.js ===
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : typeof "fs"
|
||||
>require("fs") : typeof "fs"
|
||||
>require : (moduleName: string) => any
|
||||
>"fs" : "fs"
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : string
|
||||
>fs.readFileSync("/a/b/c") : string
|
||||
>fs.readFileSync : (s: string) => string
|
||||
>fs : typeof "fs"
|
||||
>readFileSync : (s: string) => string
|
||||
>"/a/b/c" : "/a/b/c"
|
||||
|
||||
=== tests/cases/compiler/node.d.ts ===
|
||||
|
||||
|
||||
declare function require(moduleName: string): any;
|
||||
>require : (moduleName: string) => any
|
||||
>moduleName : string
|
||||
|
||||
declare module "fs" {
|
||||
export function readFileSync(s: string): string;
|
||||
>readFileSync : (s: string) => string
|
||||
>s : string
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
tests/cases/compiler/catchClauseWithBindingPattern1.ts(3,8): error TS1195: Catch clause variable name must be an identifier.
|
||||
|
||||
|
||||
==== tests/cases/compiler/catchClauseWithBindingPattern1.ts (1 errors) ====
|
||||
try {
|
||||
}
|
||||
catch ({a}) {
|
||||
~
|
||||
!!! error TS1195: Catch clause variable name must be an identifier.
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
//// [catchClauseWithBindingPattern1.ts]
|
||||
try {
|
||||
}
|
||||
catch ({a}) {
|
||||
}
|
||||
|
||||
//// [catchClauseWithBindingPattern1.js]
|
||||
try {
|
||||
}
|
||||
catch (a = (void 0).a) {
|
||||
}
|
||||
59
tests/baselines/reference/destructuringCatch.js
Normal file
59
tests/baselines/reference/destructuringCatch.js
Normal file
@ -0,0 +1,59 @@
|
||||
//// [destructuringCatch.ts]
|
||||
|
||||
try {
|
||||
throw [0, 1];
|
||||
}
|
||||
catch ([a, b]) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
try {
|
||||
throw { a: 0, b: 1 };
|
||||
}
|
||||
catch ({a, b}) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
try {
|
||||
throw [{ x: [0], z: 1 }];
|
||||
}
|
||||
catch ([{x: [y], z}]) {
|
||||
y + z;
|
||||
}
|
||||
|
||||
// Test of comment ranges. A fix to GH#11755 should update this.
|
||||
try {
|
||||
}
|
||||
catch (/*Test comment ranges*/[/*a*/a]) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// [destructuringCatch.js]
|
||||
try {
|
||||
throw [0, 1];
|
||||
}
|
||||
catch (_a) {
|
||||
var a = _a[0], b = _a[1];
|
||||
a + b;
|
||||
}
|
||||
try {
|
||||
throw { a: 0, b: 1 };
|
||||
}
|
||||
catch (_b) {
|
||||
var a = _b.a, b = _b.b;
|
||||
a + b;
|
||||
}
|
||||
try {
|
||||
throw [{ x: [0], z: 1 }];
|
||||
}
|
||||
catch (_c) {
|
||||
var _d = _c[0], y = _d.x[0], z = _d.z;
|
||||
y + z;
|
||||
}
|
||||
// Test of comment ranges. A fix to GH#11755 should update this.
|
||||
try {
|
||||
}
|
||||
catch (_e) {
|
||||
var /*a*/ a = _e[0];
|
||||
}
|
||||
51
tests/baselines/reference/destructuringCatch.symbols
Normal file
51
tests/baselines/reference/destructuringCatch.symbols
Normal file
@ -0,0 +1,51 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringCatch.ts ===
|
||||
|
||||
try {
|
||||
throw [0, 1];
|
||||
}
|
||||
catch ([a, b]) {
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 4, 8))
|
||||
>b : Symbol(b, Decl(destructuringCatch.ts, 4, 10))
|
||||
|
||||
a + b;
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 4, 8))
|
||||
>b : Symbol(b, Decl(destructuringCatch.ts, 4, 10))
|
||||
}
|
||||
|
||||
try {
|
||||
throw { a: 0, b: 1 };
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 9, 11))
|
||||
>b : Symbol(b, Decl(destructuringCatch.ts, 9, 17))
|
||||
}
|
||||
catch ({a, b}) {
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 11, 8))
|
||||
>b : Symbol(b, Decl(destructuringCatch.ts, 11, 10))
|
||||
|
||||
a + b;
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 11, 8))
|
||||
>b : Symbol(b, Decl(destructuringCatch.ts, 11, 10))
|
||||
}
|
||||
|
||||
try {
|
||||
throw [{ x: [0], z: 1 }];
|
||||
>x : Symbol(x, Decl(destructuringCatch.ts, 16, 12))
|
||||
>z : Symbol(z, Decl(destructuringCatch.ts, 16, 20))
|
||||
}
|
||||
catch ([{x: [y], z}]) {
|
||||
>x : Symbol(x)
|
||||
>y : Symbol(y, Decl(destructuringCatch.ts, 18, 13))
|
||||
>z : Symbol(z, Decl(destructuringCatch.ts, 18, 16))
|
||||
|
||||
y + z;
|
||||
>y : Symbol(y, Decl(destructuringCatch.ts, 18, 13))
|
||||
>z : Symbol(z, Decl(destructuringCatch.ts, 18, 16))
|
||||
}
|
||||
|
||||
// Test of comment ranges. A fix to GH#11755 should update this.
|
||||
try {
|
||||
}
|
||||
catch (/*Test comment ranges*/[/*a*/a]) {
|
||||
>a : Symbol(a, Decl(destructuringCatch.ts, 25, 31))
|
||||
|
||||
}
|
||||
|
||||
65
tests/baselines/reference/destructuringCatch.types
Normal file
65
tests/baselines/reference/destructuringCatch.types
Normal file
@ -0,0 +1,65 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringCatch.ts ===
|
||||
|
||||
try {
|
||||
throw [0, 1];
|
||||
>[0, 1] : number[]
|
||||
>0 : 0
|
||||
>1 : 1
|
||||
}
|
||||
catch ([a, b]) {
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
a + b;
|
||||
>a + b : any
|
||||
>a : any
|
||||
>b : any
|
||||
}
|
||||
|
||||
try {
|
||||
throw { a: 0, b: 1 };
|
||||
>{ a: 0, b: 1 } : { a: number; b: number; }
|
||||
>a : number
|
||||
>0 : 0
|
||||
>b : number
|
||||
>1 : 1
|
||||
}
|
||||
catch ({a, b}) {
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
a + b;
|
||||
>a + b : any
|
||||
>a : any
|
||||
>b : any
|
||||
}
|
||||
|
||||
try {
|
||||
throw [{ x: [0], z: 1 }];
|
||||
>[{ x: [0], z: 1 }] : { x: number[]; z: number; }[]
|
||||
>{ x: [0], z: 1 } : { x: number[]; z: number; }
|
||||
>x : number[]
|
||||
>[0] : number[]
|
||||
>0 : 0
|
||||
>z : number
|
||||
>1 : 1
|
||||
}
|
||||
catch ([{x: [y], z}]) {
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
|
||||
y + z;
|
||||
>y + z : any
|
||||
>y : any
|
||||
>z : any
|
||||
}
|
||||
|
||||
// Test of comment ranges. A fix to GH#11755 should update this.
|
||||
try {
|
||||
}
|
||||
catch (/*Test comment ranges*/[/*a*/a]) {
|
||||
>a : any
|
||||
|
||||
}
|
||||
|
||||
9
tests/baselines/reference/exportAsNamespace.d.symbols
Normal file
9
tests/baselines/reference/exportAsNamespace.d.symbols
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/exportAsNamespace.d.ts ===
|
||||
// issue: https://github.com/Microsoft/TypeScript/issues/11545
|
||||
|
||||
export var X;
|
||||
>X : Symbol(X, Decl(exportAsNamespace.d.ts, 2, 10))
|
||||
|
||||
export as namespace N
|
||||
>N : Symbol(N, Decl(exportAsNamespace.d.ts, 2, 13))
|
||||
|
||||
9
tests/baselines/reference/exportAsNamespace.d.types
Normal file
9
tests/baselines/reference/exportAsNamespace.d.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/exportAsNamespace.d.ts ===
|
||||
// issue: https://github.com/Microsoft/TypeScript/issues/11545
|
||||
|
||||
export var X;
|
||||
>X : any
|
||||
|
||||
export as namespace N
|
||||
>N : typeof N
|
||||
|
||||
81
tests/baselines/reference/jsxEmitWithAttributes.js
Normal file
81
tests/baselines/reference/jsxEmitWithAttributes.js
Normal file
@ -0,0 +1,81 @@
|
||||
//// [tests/cases/compiler/jsxEmitWithAttributes.ts] ////
|
||||
|
||||
//// [Element.ts]
|
||||
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//// [Element.js]
|
||||
"use strict";
|
||||
var Element;
|
||||
(function (Element) {
|
||||
function isElement(el) {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
Element.isElement = isElement;
|
||||
function createElement(args) {
|
||||
return {};
|
||||
}
|
||||
Element.createElement = createElement;
|
||||
})(Element = exports.Element || (exports.Element = {}));
|
||||
exports.createElement = Element.createElement;
|
||||
function toCamelCase(text) {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
const Element_1 = require("./Element");
|
||||
let c;
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
Element_1.Element.createElement("meta", { content: "helloworld" }),
|
||||
Element_1.Element.createElement("meta", { content: c.a.b })
|
||||
];
|
||||
}
|
||||
}
|
||||
119
tests/baselines/reference/jsxEmitWithAttributes.symbols
Normal file
119
tests/baselines/reference/jsxEmitWithAttributes.symbols
Normal file
@ -0,0 +1,119 @@
|
||||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
|
||||
interface Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Element.name, Decl(Element.ts, 2, 23))
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : Symbol(Element.isIntrinsic, Decl(Element.ts, 3, 21))
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : Symbol(Element.isCustomElement, Decl(Element.ts, 4, 29))
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : Symbol(Element.toString, Decl(Element.ts, 5, 33))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 6, 17))
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : Symbol(Element.bindDOM, Decl(Element.ts, 6, 44))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 7, 16))
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : Symbol(Element.resetComponent, Decl(Element.ts, 7, 43))
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : Symbol(Element.instantiateComponents, Decl(Element.ts, 8, 31))
|
||||
>renderId : Symbol(renderId, Decl(Element.ts, 9, 30))
|
||||
|
||||
props: any;
|
||||
>props : Symbol(Element.props, Decl(Element.ts, 9, 57))
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : Symbol(isElement, Decl(Element.ts, 13, 26))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>JSX : Symbol(JSX, Decl(Element.ts, 0, 0))
|
||||
>Element : Symbol(JSX.Element, Decl(Element.ts, 1, 23))
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el : Symbol(el, Decl(Element.ts, 14, 30))
|
||||
>undefined : Symbol(undefined)
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 16, 5))
|
||||
>args : Symbol(args, Decl(Element.ts, 18, 34))
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : Symbol(createElement, Decl(Element.ts, 25, 10))
|
||||
>Element.createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
>Element : Symbol(Element, Decl(Element.ts, 12, 1))
|
||||
>createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5))
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : Symbol(toCamelCase, Decl(Element.ts, 25, 49))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>text.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
>text : Symbol(text, Decl(Element.ts, 27, 21))
|
||||
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : Symbol(Element, Decl(test.tsx, 0, 8))
|
||||
|
||||
let c: {
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
|
||||
a?: {
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
|
||||
b: string
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(test.tsx, 6, 2))
|
||||
|
||||
view() {
|
||||
>view : Symbol(A.view, Decl(test.tsx, 8, 9))
|
||||
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
>meta : Symbol(unknown)
|
||||
>content : Symbol(unknown)
|
||||
>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>c.a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>c : Symbol(c, Decl(test.tsx, 2, 3))
|
||||
>a : Symbol(a, Decl(test.tsx, 2, 8))
|
||||
>b : Symbol(b, Decl(test.tsx, 3, 6))
|
||||
>meta : Symbol(unknown)
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
134
tests/baselines/reference/jsxEmitWithAttributes.types
Normal file
134
tests/baselines/reference/jsxEmitWithAttributes.types
Normal file
@ -0,0 +1,134 @@
|
||||
=== tests/cases/compiler/Element.ts ===
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : any
|
||||
|
||||
interface Element {
|
||||
>Element : Element
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
isIntrinsic: boolean;
|
||||
>isIntrinsic : boolean
|
||||
|
||||
isCustomElement: boolean;
|
||||
>isCustomElement : boolean
|
||||
|
||||
toString(renderId?: number): string;
|
||||
>toString : (renderId?: number) => string
|
||||
>renderId : number
|
||||
|
||||
bindDOM(renderId?: number): number;
|
||||
>bindDOM : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
resetComponent(): void;
|
||||
>resetComponent : () => void
|
||||
|
||||
instantiateComponents(renderId?: number): number;
|
||||
>instantiateComponents : (renderId?: number) => number
|
||||
>renderId : number
|
||||
|
||||
props: any;
|
||||
>props : any
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
>Element : typeof Element
|
||||
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
>isElement : (el: any) => el is JSX.Element
|
||||
>el : any
|
||||
>el : any
|
||||
>JSX : any
|
||||
>Element : JSX.Element
|
||||
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
>el.markAsChildOfRootElement !== undefined : boolean
|
||||
>el.markAsChildOfRootElement : any
|
||||
>el : any
|
||||
>markAsChildOfRootElement : any
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
>createElement : (args: any[]) => {}
|
||||
>args : any[]
|
||||
|
||||
return {
|
||||
>{ } : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
>createElement : (args: any[]) => {}
|
||||
>Element.createElement : (args: any[]) => {}
|
||||
>Element : typeof Element
|
||||
>createElement : (args: any[]) => {}
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
>toCamelCase : (text: string) => string
|
||||
>text : string
|
||||
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
>text[0].toLowerCase() + text.substring(1) : string
|
||||
>text[0].toLowerCase() : string
|
||||
>text[0].toLowerCase : () => string
|
||||
>text[0] : string
|
||||
>text : string
|
||||
>0 : 0
|
||||
>toLowerCase : () => string
|
||||
>text.substring(1) : string
|
||||
>text.substring : (start: number, end?: number) => string
|
||||
>text : string
|
||||
>substring : (start: number, end?: number) => string
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import { Element} from './Element';
|
||||
>Element : typeof Element
|
||||
|
||||
let c: {
|
||||
>c : { a?: { b: string; }; }
|
||||
|
||||
a?: {
|
||||
>a : { b: string; }
|
||||
|
||||
b: string
|
||||
>b : string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
view() {
|
||||
>view : () => any[]
|
||||
|
||||
return [
|
||||
>[ <meta content="helloworld"></meta>, <meta content={c.a!.b}></meta> ] : any[]
|
||||
|
||||
<meta content="helloworld"></meta>,
|
||||
><meta content="helloworld"></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>meta : any
|
||||
|
||||
<meta content={c.a!.b}></meta>
|
||||
><meta content={c.a!.b}></meta> : any
|
||||
>meta : any
|
||||
>content : any
|
||||
>c.a!.b : string
|
||||
>c.a! : { b: string; }
|
||||
>c.a : { b: string; }
|
||||
>c : { a?: { b: string; }; }
|
||||
>a : { b: string; }
|
||||
>b : string
|
||||
>meta : any
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
15
tests/baselines/reference/localRequireFunction.js
Normal file
15
tests/baselines/reference/localRequireFunction.js
Normal file
@ -0,0 +1,15 @@
|
||||
//// [app.js]
|
||||
|
||||
function require(a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
const fs = require("fs");
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
|
||||
//// [app.js]
|
||||
function require(a) {
|
||||
return a;
|
||||
}
|
||||
var fs = require("fs");
|
||||
var text = fs.readFileSync("/a/b/c");
|
||||
18
tests/baselines/reference/localRequireFunction.symbols
Normal file
18
tests/baselines/reference/localRequireFunction.symbols
Normal file
@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/app.js ===
|
||||
|
||||
function require(a) {
|
||||
>require : Symbol(require, Decl(app.js, 0, 0))
|
||||
>a : Symbol(a, Decl(app.js, 1, 17))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(app.js, 1, 17))
|
||||
}
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : Symbol(fs, Decl(app.js, 5, 5))
|
||||
>require : Symbol(require, Decl(app.js, 0, 0))
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : Symbol(text, Decl(app.js, 6, 5))
|
||||
>fs : Symbol(fs, Decl(app.js, 5, 5))
|
||||
|
||||
24
tests/baselines/reference/localRequireFunction.types
Normal file
24
tests/baselines/reference/localRequireFunction.types
Normal file
@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/app.js ===
|
||||
|
||||
function require(a) {
|
||||
>require : (a: any) => any
|
||||
>a : any
|
||||
|
||||
return a;
|
||||
>a : any
|
||||
}
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : any
|
||||
>require("fs") : any
|
||||
>require : (a: any) => any
|
||||
>"fs" : "fs"
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : any
|
||||
>fs.readFileSync("/a/b/c") : any
|
||||
>fs.readFileSync : any
|
||||
>fs : any
|
||||
>readFileSync : any
|
||||
>"/a/b/c" : "/a/b/c"
|
||||
|
||||
14
tests/baselines/reference/nounusedTypeParameterConstraint.js
Normal file
14
tests/baselines/reference/nounusedTypeParameterConstraint.js
Normal file
@ -0,0 +1,14 @@
|
||||
//// [tests/cases/compiler/nounusedTypeParameterConstraint.ts] ////
|
||||
|
||||
//// [bar.ts]
|
||||
|
||||
export interface IEventSourcedEntity { }
|
||||
|
||||
//// [test.ts]
|
||||
import { IEventSourcedEntity } from "./bar";
|
||||
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
|
||||
|
||||
//// [bar.js]
|
||||
"use strict";
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
|
||||
export interface IEventSourcedEntity { }
|
||||
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(bar.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/test.ts ===
|
||||
import { IEventSourcedEntity } from "./bar";
|
||||
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
|
||||
|
||||
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
|
||||
>DomainEntityConstructor : Symbol(DomainEntityConstructor, Decl(test.ts, 0, 44))
|
||||
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))
|
||||
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
|
||||
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
|
||||
export interface IEventSourcedEntity { }
|
||||
>IEventSourcedEntity : IEventSourcedEntity
|
||||
|
||||
=== tests/cases/compiler/test.ts ===
|
||||
import { IEventSourcedEntity } from "./bar";
|
||||
>IEventSourcedEntity : any
|
||||
|
||||
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
|
||||
>DomainEntityConstructor : new () => TEntity
|
||||
>TEntity : TEntity
|
||||
>IEventSourcedEntity : IEventSourcedEntity
|
||||
>TEntity : TEntity
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/redeclareParameterInCatchBlock.ts(5,11): error TS2492: Cannot redeclare identifier 'e' in catch clause
|
||||
tests/cases/compiler/redeclareParameterInCatchBlock.ts(11,9): error TS2492: Cannot redeclare identifier 'e' in catch clause
|
||||
tests/cases/compiler/redeclareParameterInCatchBlock.ts(17,15): error TS2492: Cannot redeclare identifier 'b' in catch clause
|
||||
tests/cases/compiler/redeclareParameterInCatchBlock.ts(22,15): error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
tests/cases/compiler/redeclareParameterInCatchBlock.ts(22,21): error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/redeclareParameterInCatchBlock.ts (2 errors) ====
|
||||
==== tests/cases/compiler/redeclareParameterInCatchBlock.ts (5 errors) ====
|
||||
|
||||
try {
|
||||
|
||||
@ -22,10 +25,27 @@ tests/cases/compiler/redeclareParameterInCatchBlock.ts(11,9): error TS2492: Cann
|
||||
|
||||
try {
|
||||
|
||||
} catch ([a, b]) {
|
||||
const [c, b] = [0, 1];
|
||||
~
|
||||
!!! error TS2492: Cannot redeclare identifier 'b' in catch clause
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch ({ a: x, b: x }) {
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
function test() {
|
||||
let e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,12 +14,23 @@ try {
|
||||
|
||||
try {
|
||||
|
||||
} catch ([a, b]) {
|
||||
const [c, b] = [0, 1];
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch ({ a: x, b: x }) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
function test() {
|
||||
let e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [redeclareParameterInCatchBlock.js]
|
||||
@ -35,6 +46,15 @@ catch (e) {
|
||||
}
|
||||
try {
|
||||
}
|
||||
catch ([a, b]) {
|
||||
const [c, b] = [0, 1];
|
||||
}
|
||||
try {
|
||||
}
|
||||
catch ({ a: x, b: x }) {
|
||||
}
|
||||
try {
|
||||
}
|
||||
catch (e) {
|
||||
function test() {
|
||||
let e;
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
tests/cases/compiler/typeAliasDeclarationEmit.ts(4,37): error TS2314: Generic type 'callback' requires 1 type argument(s).
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeAliasDeclarationEmit.ts (1 errors) ====
|
||||
|
||||
export type callback<T> = () => T;
|
||||
|
||||
export type CallbackArray<T extends callback> = () => T;
|
||||
~~~~~~~~
|
||||
!!! error TS2314: Generic type 'callback' requires 1 type argument(s).
|
||||
@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but never used.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedDestructuringParameters.ts (2 errors) ====
|
||||
const f = ([a]) => { };
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
f([1]);
|
||||
const f2 = ({a}) => { };
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
f2({ a: 10 });
|
||||
const f3 = ([_]) => { };
|
||||
f3([10]);
|
||||
21
tests/baselines/reference/unusedDestructuringParameters.js
Normal file
21
tests/baselines/reference/unusedDestructuringParameters.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [unusedDestructuringParameters.ts]
|
||||
const f = ([a]) => { };
|
||||
f([1]);
|
||||
const f2 = ({a}) => { };
|
||||
f2({ a: 10 });
|
||||
const f3 = ([_]) => { };
|
||||
f3([10]);
|
||||
|
||||
//// [unusedDestructuringParameters.js]
|
||||
var f = function (_a) {
|
||||
var a = _a[0];
|
||||
};
|
||||
f([1]);
|
||||
var f2 = function (_a) {
|
||||
var a = _a.a;
|
||||
};
|
||||
f2({ a: 10 });
|
||||
var f3 = function (_a) {
|
||||
var _ = _a[0];
|
||||
};
|
||||
f3([10]);
|
||||
@ -0,0 +1,18 @@
|
||||
tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(7,9): error TS6133: '_' is declared but never used.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts (1 errors) ====
|
||||
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
|
||||
namespace M {
|
||||
let _;
|
||||
~
|
||||
!!! error TS6133: '_' is declared but never used.
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
//// [unusedLocalsStartingWithUnderscore.ts]
|
||||
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
|
||||
namespace M {
|
||||
let _;
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
}
|
||||
|
||||
|
||||
//// [unusedLocalsStartingWithUnderscore.js]
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var _ = _a[_i];
|
||||
}
|
||||
for (var _ in []) { }
|
||||
var M;
|
||||
(function (M) {
|
||||
var _;
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var _1 = _a[_i];
|
||||
}
|
||||
for (var _2 in []) { }
|
||||
})(M || (M = {}));
|
||||
@ -2,15 +2,11 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(2,12): error TS6133: 'a'
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(2,19): error TS6133: 'c' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(2,27): error TS6133: 'd' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(2,29): error TS6133: 'e___' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(6,14): error TS6133: '_a' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(6,18): error TS6133: '___b' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(9,14): error TS6133: '_a' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(9,19): error TS6133: '___b' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(12,16): error TS6133: 'arg' is declared but never used.
|
||||
tests/cases/compiler/unusedParametersWithUnderscore.ts(18,13): error TS6133: 'arg' is declared but never used.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedParametersWithUnderscore.ts (10 errors) ====
|
||||
==== tests/cases/compiler/unusedParametersWithUnderscore.ts (6 errors) ====
|
||||
|
||||
function f(a, _b, c, ___, d,e___, _f) {
|
||||
~
|
||||
@ -25,17 +21,9 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(18,13): error TS6133: 'ar
|
||||
|
||||
|
||||
function f2({_a, __b}) {
|
||||
~~
|
||||
!!! error TS6133: '_a' is declared but never used.
|
||||
~~~
|
||||
!!! error TS6133: '___b' is declared but never used.
|
||||
}
|
||||
|
||||
function f3([_a, ,__b]) {
|
||||
~~
|
||||
!!! error TS6133: '_a' is declared but never used.
|
||||
~~~
|
||||
!!! error TS6133: '___b' is declared but never used.
|
||||
}
|
||||
|
||||
function f4(...arg) {
|
||||
|
||||
17
tests/cases/compiler/ambientRequireFunction.ts
Normal file
17
tests/cases/compiler/ambientRequireFunction.ts
Normal file
@ -0,0 +1,17 @@
|
||||
// @module: commonjs
|
||||
// @allowJs: true
|
||||
// @outDir: ./out/
|
||||
|
||||
// @filename: node.d.ts
|
||||
|
||||
declare function require(moduleName: string): any;
|
||||
|
||||
declare module "fs" {
|
||||
export function readFileSync(s: string): string;
|
||||
}
|
||||
|
||||
// @filename: app.js
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
@ -1,4 +0,0 @@
|
||||
try {
|
||||
}
|
||||
catch ({a}) {
|
||||
}
|
||||
4
tests/cases/compiler/exportAsNamespace.d.ts
vendored
Normal file
4
tests/cases/compiler/exportAsNamespace.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
// issue: https://github.com/Microsoft/TypeScript/issues/11545
|
||||
|
||||
export var X;
|
||||
export as namespace N
|
||||
53
tests/cases/compiler/jsxEmitWithAttributes.ts
Normal file
53
tests/cases/compiler/jsxEmitWithAttributes.ts
Normal file
@ -0,0 +1,53 @@
|
||||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@reactNamespace: Element
|
||||
|
||||
// @filename: Element.ts
|
||||
declare namespace JSX {
|
||||
interface Element {
|
||||
name: string;
|
||||
isIntrinsic: boolean;
|
||||
isCustomElement: boolean;
|
||||
toString(renderId?: number): string;
|
||||
bindDOM(renderId?: number): number;
|
||||
resetComponent(): void;
|
||||
instantiateComponents(renderId?: number): number;
|
||||
props: any;
|
||||
}
|
||||
}
|
||||
export namespace Element {
|
||||
export function isElement(el: any): el is JSX.Element {
|
||||
return el.markAsChildOfRootElement !== undefined;
|
||||
}
|
||||
|
||||
export function createElement(args: any[]) {
|
||||
|
||||
return {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let createElement = Element.createElement;
|
||||
|
||||
function toCamelCase(text: string): string {
|
||||
return text[0].toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
// @filename: test.tsx
|
||||
import { Element} from './Element';
|
||||
|
||||
let c: {
|
||||
a?: {
|
||||
b: string
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
view() {
|
||||
return [
|
||||
<meta content="helloworld"></meta>,
|
||||
<meta content={c.a!.b}></meta>
|
||||
];
|
||||
}
|
||||
}
|
||||
11
tests/cases/compiler/localRequireFunction.ts
Normal file
11
tests/cases/compiler/localRequireFunction.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @module: commonjs
|
||||
// @allowJs: true
|
||||
// @outDir: ./out/
|
||||
|
||||
// @filename: app.js
|
||||
function require(a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
const fs = require("fs");
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
8
tests/cases/compiler/nounusedTypeParameterConstraint.ts
Normal file
8
tests/cases/compiler/nounusedTypeParameterConstraint.ts
Normal file
@ -0,0 +1,8 @@
|
||||
//@noUnusedLocals:true
|
||||
|
||||
//@filename: bar.ts
|
||||
export interface IEventSourcedEntity { }
|
||||
|
||||
//@filename: test.ts
|
||||
import { IEventSourcedEntity } from "./bar";
|
||||
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
|
||||
@ -14,9 +14,20 @@ try {
|
||||
|
||||
try {
|
||||
|
||||
} catch ([a, b]) {
|
||||
const [c, b] = [0, 1];
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch ({ a: x, b: x }) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
function test() {
|
||||
let e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
tests/cases/compiler/unusedDestructuringParameters.ts
Normal file
7
tests/cases/compiler/unusedDestructuringParameters.ts
Normal file
@ -0,0 +1,7 @@
|
||||
//@noUnusedParameters: true
|
||||
const f = ([a]) => { };
|
||||
f([1]);
|
||||
const f2 = ({a}) => { };
|
||||
f2({ a: 10 });
|
||||
const f3 = ([_]) => { };
|
||||
f3([10]);
|
||||
13
tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts
Normal file
13
tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts
Normal file
@ -0,0 +1,13 @@
|
||||
//@noUnusedLocals:true
|
||||
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
|
||||
namespace M {
|
||||
let _;
|
||||
for (const _ of []) { }
|
||||
|
||||
for (const _ in []) { }
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
// @noImplicitAny: true
|
||||
|
||||
try {
|
||||
throw [0, 1];
|
||||
}
|
||||
catch ([a, b]) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
try {
|
||||
throw { a: 0, b: 1 };
|
||||
}
|
||||
catch ({a, b}) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
try {
|
||||
throw [{ x: [0], z: 1 }];
|
||||
}
|
||||
catch ([{x: [y], z}]) {
|
||||
y + z;
|
||||
}
|
||||
|
||||
// Test of comment ranges. A fix to GH#11755 should update this.
|
||||
try {
|
||||
}
|
||||
catch (/*Test comment ranges*/[/*a*/a]) {
|
||||
|
||||
}
|
||||
@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) {
|
||||
// fs.rmdirSync won't delete directories with files in it
|
||||
function deleteFolderRecursive(dirPath: string) {
|
||||
if (fs.existsSync(dirPath)) {
|
||||
fs.readdirSync(dirPath).forEach((file, index) => {
|
||||
fs.readdirSync(dirPath).forEach((file) => {
|
||||
const curPath = path.join(path, file);
|
||||
if (fs.statSync(curPath).isDirectory()) { // recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) {
|
||||
}
|
||||
};
|
||||
|
||||
function writeFile(path: string, data: any, opts: { recursive: boolean }) {
|
||||
function writeFile(path: string, data: any) {
|
||||
ensureDirectoriesExist(getDirectoryPath(path));
|
||||
fs.writeFileSync(path, data);
|
||||
}
|
||||
@ -208,7 +208,7 @@ enum RequestType {
|
||||
Unknown
|
||||
}
|
||||
|
||||
function getRequestOperation(req: http.ServerRequest, filename: string) {
|
||||
function getRequestOperation(req: http.ServerRequest) {
|
||||
if (req.method === "GET" && req.url.indexOf("?") === -1) {
|
||||
if (req.url.indexOf(".") !== -1) return RequestType.GetFile;
|
||||
else return RequestType.GetDir;
|
||||
@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
|
||||
break;
|
||||
case RequestType.WriteFile:
|
||||
processPost(req, res, (data) => {
|
||||
writeFile(reqPath, data, { recursive: true });
|
||||
writeFile(reqPath, data);
|
||||
});
|
||||
send(ResponseCode.Success, res, undefined);
|
||||
break;
|
||||
@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => {
|
||||
log(`${req.method} ${req.url}`);
|
||||
const uri = url.parse(req.url).pathname;
|
||||
const reqPath = path.join(process.cwd(), uri);
|
||||
const operation = getRequestOperation(req, reqPath);
|
||||
const operation = getRequestOperation(req);
|
||||
handleRequestOperation(req, res, operation, reqPath);
|
||||
}).listen(port);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user