Merge branch 'master' into 6229-known-length-tuples

This commit is contained in:
Tycho Grouwstra
2017-08-24 17:24:08 +08:00
82 changed files with 25700 additions and 7731 deletions
+14 -4
View File
@@ -463,10 +463,11 @@ gulp.task(serverFile, /*help*/ false, [servicesFile, typingsInstallerJs, cancell
.pipe(gulp.dest("src/server"));
});
const typesMapJson = path.join(builtLocalDirectory, "typesMap.json");
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => {
gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (done) => {
const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src()
.pipe(sourcemaps.init())
@@ -485,6 +486,15 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile], (done) => {
]);
});
gulp.task(typesMapJson, /*help*/ false, [], () => {
return gulp.src("src/server/typesMap.json")
.pipe(insert.transform((contents, file) => {
JSON.parse(contents);
return contents;
}))
.pipe(gulp.dest(builtLocalDirectory));
});
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
@@ -968,7 +978,7 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts");
const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js");
gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
const settings: tsc.Settings = getCompilerSettings({
outFile: instrumenterJsPath,
module: "commonjs",
target: "es5",
lib: [
"es6",
@@ -980,8 +990,8 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
.pipe(newer(instrumenterJsPath))
.pipe(sourcemaps.init())
.pipe(tsc(settings))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."));
.pipe(sourcemaps.write(builtLocalDirectory))
.pipe(gulp.dest(builtLocalDirectory));
});
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
+16 -3
View File
@@ -88,6 +88,8 @@ var watchGuardSources = filesFromConfig(path.join(serverDirectory, "watchGuard/t
var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json"))
var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json"));
var typesMapOutputPath = path.join(builtLocalDirectory, 'typesMap.json');
var harnessCoreSources = [
"harness.ts",
"virtualFileSystem.ts",
@@ -140,6 +142,7 @@ var harnessSources = harnessCoreSources.concat([
"transform.ts",
"customTransforms.ts",
"programMissingFiles.ts",
"symbolWalker.ts",
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
@@ -423,6 +426,7 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var typesMapJson = path.join(builtLocalDirectory, "typesMap.json");
file(buildProtocolTs);
@@ -587,6 +591,16 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
file(typesMapOutputPath, function() {
var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json'));
// Validate that it's valid JSON
try {
JSON.parse(content);
} catch (e) {
console.log("Parse error in typesMap.json: " + e);
}
fs.writeFileSync(typesMapOutputPath, content);
});
compileFile(
tsserverLibraryFile,
languageServiceLibrarySources,
@@ -609,7 +623,7 @@ compileFile(
// Local target to build the language service server library
desc("Builds language service server library");
task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]);
task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile, typesMapOutputPath]);
desc("Emit the start of the build fold");
task("build-fold-start", [], function () {
@@ -638,7 +652,6 @@ task("release", function () {
// Set the default task to "local"
task("default", ["local"]);
// Cleans the built directory
desc("Cleans the compiler output, declare files, and tests");
task("clean", function () {
@@ -1086,7 +1099,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () {
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"] });
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"], noOutFile: true, outDir: builtLocalDirectory });
desc("Builds an instrumented tsc.js");
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () {
+2
View File
@@ -69,3 +69,5 @@ function createCancellationToken(args) {
}
}
module.exports = createCancellationToken;
//# sourceMappingURL=cancellationToken.js.map
+5 -5
View File
@@ -236,7 +236,7 @@ interface ObjectConstructor {
* Returns the names of the enumerable properties and methods of an object.
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
keys(o: any): string[];
keys(o: {}): string[];
}
/**
@@ -1000,12 +1000,12 @@ interface ReadonlyArray<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
@@ -1119,12 +1119,12 @@ interface Array<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
+1 -1
View File
@@ -130,7 +130,7 @@ interface Map<K, V> {
readonly [Symbol.toStringTag]: "Map";
}
interface WeakMap<K extends object, V>{
interface WeakMap<K extends object, V> {
readonly [Symbol.toStringTag]: "WeakMap";
}
+1824
View File
File diff suppressed because it is too large Load Diff
+1824
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -236,7 +236,7 @@ interface ObjectConstructor {
* Returns the names of the enumerable properties and methods of an object.
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
keys(o: any): string[];
keys(o: {}): string[];
}
/**
@@ -1000,12 +1000,12 @@ interface ReadonlyArray<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
@@ -1119,12 +1119,12 @@ interface Array<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
+6 -6
View File
@@ -236,7 +236,7 @@ interface ObjectConstructor {
* Returns the names of the enumerable properties and methods of an object.
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
keys(o: any): string[];
keys(o: {}): string[];
}
/**
@@ -1000,12 +1000,12 @@ interface ReadonlyArray<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
@@ -1119,12 +1119,12 @@ interface Array<T> {
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[][]): T[];
concat(...items: ReadonlyArray<T>[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: (T | T[])[]): T[];
concat(...items: (T | ReadonlyArray<T>)[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
@@ -5689,7 +5689,7 @@ interface Map<K, V> {
readonly [Symbol.toStringTag]: "Map";
}
interface WeakMap<K extends object, V>{
interface WeakMap<K extends object, V> {
readonly [Symbol.toStringTag]: "WeakMap";
}
+1824
View File
File diff suppressed because it is too large Load Diff
+2648 -755
View File
File diff suppressed because it is too large Load Diff
+3014 -1451
View File
File diff suppressed because it is too large Load Diff
+136 -179
View File
@@ -50,7 +50,7 @@ declare namespace ts {
pos: number;
end: number;
}
enum SyntaxKind {
const enum SyntaxKind {
Unknown = 0,
EndOfFileToken = 1,
SingleLineCommentTrivia = 2,
@@ -374,7 +374,7 @@ declare namespace ts {
FirstJSDocTagNode = 276,
LastJSDocTagNode = 285,
}
enum NodeFlags {
const enum NodeFlags {
None = 0,
Let = 1,
Const = 2,
@@ -402,7 +402,7 @@ declare namespace ts {
ContextFlags = 96256,
TypeExcludesFlags = 20480,
}
enum ModifierFlags {
const enum ModifierFlags {
None = 0,
Export = 1,
Ambient = 2,
@@ -422,7 +422,7 @@ declare namespace ts {
TypeScriptModifier = 2270,
ExportDefault = 513,
}
enum JsxFlags {
const enum JsxFlags {
None = 0,
IntrinsicNamedElement = 1,
IntrinsicIndexedElement = 2,
@@ -1175,7 +1175,7 @@ declare namespace ts {
interface CatchClause extends Node {
kind: SyntaxKind.CatchClause;
parent?: TryStatement;
variableDeclaration: VariableDeclaration;
variableDeclaration?: VariableDeclaration;
block: Block;
}
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
@@ -1432,7 +1432,7 @@ declare namespace ts {
jsDocTypeTag?: JSDocTypeTag;
isArrayType?: boolean;
}
enum FlowFlags {
const enum FlowFlags {
Unreachable = 1,
Start = 2,
BranchLabel = 4,
@@ -1452,38 +1452,39 @@ declare namespace ts {
interface FlowLock {
locked?: boolean;
}
interface AfterFinallyFlow extends FlowNode, FlowLock {
interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
interface PreFinallyFlow extends FlowNode {
interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
interface FlowNode {
type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
interface FlowStart extends FlowNode {
interface FlowStart extends FlowNodeBase {
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
}
interface FlowLabel extends FlowNode {
interface FlowLabel extends FlowNodeBase {
antecedents: FlowNode[];
}
interface FlowAssignment extends FlowNode {
interface FlowAssignment extends FlowNodeBase {
node: Expression | VariableDeclaration | BindingElement;
antecedent: FlowNode;
}
interface FlowCondition extends FlowNode {
interface FlowCondition extends FlowNodeBase {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
interface FlowSwitchClause extends FlowNodeBase {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNode {
interface FlowArrayMutation extends FlowNodeBase {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
@@ -1607,6 +1608,7 @@ declare namespace ts {
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
@@ -1684,7 +1686,7 @@ declare namespace ts {
reportInaccessibleThisError(): void;
reportPrivateInBaseOfClassExpression(propertyName: string): void;
}
enum TypeFormatFlags {
const enum TypeFormatFlags {
None = 0,
WriteArrayAsGenericType = 1,
UseTypeOfFunction = 4,
@@ -1696,18 +1698,18 @@ declare namespace ts {
UseFullyQualifiedType = 256,
InFirstTypeArgument = 512,
InTypeAlias = 1024,
UseTypeAliasValue = 2048,
SuppressAnyReturnType = 4096,
AddUndefined = 8192,
WriteClassExpressionAsTypeLiteral = 16384,
InArrayType = 32768,
UseAliasDefinedOutsideCurrentScope = 65536,
}
enum SymbolFormatFlags {
const enum SymbolFormatFlags {
None = 0,
WriteTypeParametersOrArguments = 1,
UseOnlyExternalAliasing = 2,
}
enum TypePredicateKind {
const enum TypePredicateKind {
This = 0,
Identifier = 1,
}
@@ -1724,7 +1726,7 @@ declare namespace ts {
parameterIndex: number;
}
type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
enum SymbolFlags {
const enum SymbolFlags {
None = 0,
FunctionScopedVariable = 1,
BlockScopedVariable = 2,
@@ -1794,7 +1796,7 @@ declare namespace ts {
exports?: SymbolTable;
globalExports?: SymbolTable;
}
enum InternalSymbolName {
const enum InternalSymbolName {
Call = "__call",
Constructor = "__constructor",
New = "__new",
@@ -1832,7 +1834,7 @@ declare namespace ts {
clear(): void;
}
type SymbolTable = UnderscoreEscapedMap<Symbol>;
enum TypeFlags {
const enum TypeFlags {
Any = 1,
String = 2,
Number = 4,
@@ -1889,7 +1891,7 @@ declare namespace ts {
}
interface EnumType extends Type {
}
enum ObjectFlags {
const enum ObjectFlags {
Class = 1,
Interface = 2,
Reference = 4,
@@ -1951,7 +1953,7 @@ declare namespace ts {
interface IndexType extends Type {
type: TypeVariable | UnionOrIntersectionType;
}
enum SignatureKind {
const enum SignatureKind {
Call = 0,
Construct = 1,
}
@@ -1960,7 +1962,7 @@ declare namespace ts {
typeParameters?: TypeParameter[];
parameters: Symbol[];
}
enum IndexKind {
const enum IndexKind {
String = 0,
Number = 1,
}
@@ -1969,7 +1971,7 @@ declare namespace ts {
isReadonly: boolean;
declaration?: SignatureDeclaration;
}
enum InferencePriority {
const enum InferencePriority {
NakedTypeVariable = 1,
MappedType = 2,
ReturnType = 4,
@@ -1982,11 +1984,17 @@ declare namespace ts {
topLevel: boolean;
isFixed: boolean;
}
enum InferenceFlags {
const enum InferenceFlags {
InferUnionTypes = 1,
NoDefault = 2,
AnyDefault = 4,
}
const enum Ternary {
False = 0,
Maybe = 1,
True = -1,
}
type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary;
interface JsFileExtensionInfo {
extension: string;
isMixedContent: boolean;
@@ -2073,6 +2081,7 @@ declare namespace ts {
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
jsxFactory?: string;
@@ -2118,13 +2127,13 @@ declare namespace ts {
ES2015 = 5,
ESNext = 6,
}
enum JsxEmit {
const enum JsxEmit {
None = 0,
Preserve = 1,
React = 2,
ReactNative = 3,
}
enum NewLineKind {
const enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1,
}
@@ -2132,7 +2141,7 @@ declare namespace ts {
line: number;
character: number;
}
enum ScriptKind {
const enum ScriptKind {
Unknown = 0,
JS = 1,
JSX = 2,
@@ -2141,7 +2150,7 @@ declare namespace ts {
External = 5,
JSON = 6,
}
enum ScriptTarget {
const enum ScriptTarget {
ES3 = 0,
ES5 = 1,
ES2015 = 2,
@@ -2150,7 +2159,7 @@ declare namespace ts {
ESNext = 5,
Latest = 5,
}
enum LanguageVariant {
const enum LanguageVariant {
Standard = 0,
JSX = 1,
}
@@ -2163,7 +2172,7 @@ declare namespace ts {
wildcardDirectories?: MapLike<WatchDirectoryFlags>;
compileOnSave?: boolean;
}
enum WatchDirectoryFlags {
const enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
}
@@ -2186,8 +2195,13 @@ declare namespace ts {
}
interface ResolvedModuleFull extends ResolvedModule {
extension: Extension;
packageId?: PackageId;
}
enum Extension {
interface PackageId {
name: string;
version: string;
}
const enum Extension {
Ts = ".ts",
Tsx = ".tsx",
Dts = ".d.ts",
@@ -2229,7 +2243,7 @@ declare namespace ts {
text: string;
skipTrivia?: (pos: number) => number;
}
enum EmitFlags {
const enum EmitFlags {
SingleLine = 1,
AdviseOnEmitNode = 2,
NoSubstitution = 4,
@@ -2265,7 +2279,7 @@ declare namespace ts {
readonly text: string;
readonly priority?: number;
}
enum EmitHint {
const enum EmitHint {
SourceFile = 0,
Expression = 1,
IdentifierName = 2,
@@ -2326,7 +2340,7 @@ declare namespace ts {
}
}
declare namespace ts {
const versionMajorMinor = "2.5";
const versionMajorMinor = "2.6";
const version: string;
}
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
@@ -2402,6 +2416,8 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray<TextChangeRange>): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: Node): boolean;
function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
function isEmptyBindingElement(node: BindingElement): boolean;
function getCombinedModifierFlags(node: Node): ModifierFlags;
function getCombinedNodeFlags(node: Node): NodeFlags;
function validateLocaleAndSetLanguage(locale: string, sys: {
@@ -2959,8 +2975,8 @@ declare namespace ts {
function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray<Statement>): DefaultClause;
function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function updateHeritageClause(node: HeritageClause, types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause;
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment;
function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment;
@@ -3197,6 +3213,7 @@ declare namespace ts {
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined;
@@ -3288,7 +3305,7 @@ declare namespace ts {
fileName: string;
highlightSpans: HighlightSpan[];
}
enum HighlightSpanKind {
const enum HighlightSpanKind {
none = "none",
definition = "definition",
reference = "reference",
@@ -3483,7 +3500,7 @@ declare namespace ts {
outputFiles: OutputFile[];
emitSkipped: boolean;
}
enum OutputFileType {
const enum OutputFileType {
JavaScript = 0,
SourceMap = 1,
Declaration = 2,
@@ -3493,7 +3510,7 @@ declare namespace ts {
writeByteOrderMark: boolean;
text: string;
}
enum EndOfLineState {
const enum EndOfLineState {
None = 0,
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
@@ -3525,7 +3542,7 @@ declare namespace ts {
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
}
enum ScriptElementKind {
const enum ScriptElementKind {
unknown = "",
warning = "warning",
keyword = "keyword",
@@ -3560,7 +3577,7 @@ declare namespace ts {
externalModuleName = "external module name",
jsxAttribute = "JSX attribute",
}
enum ScriptElementKindModifier {
const enum ScriptElementKindModifier {
none = "",
publicMemberModifier = "public",
privateMemberModifier = "private",
@@ -3570,7 +3587,7 @@ declare namespace ts {
staticModifier = "static",
abstractModifier = "abstract",
}
enum ClassificationTypeNames {
const enum ClassificationTypeNames {
comment = "comment",
identifier = "identifier",
keyword = "keyword",
@@ -3595,7 +3612,7 @@ declare namespace ts {
jsxText = "jsx text",
jsxAttributeStringLiteralValue = "jsx attribute string literal value",
}
enum ClassificationType {
const enum ClassificationType {
comment = 1,
identifier = 2,
keyword = 3,
@@ -3687,7 +3704,10 @@ declare namespace ts.server {
error: undefined;
} | {
module: undefined;
error: {};
error: {
stack?: string;
message?: string;
};
};
interface ServerHost extends System {
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
@@ -3770,6 +3790,7 @@ declare namespace ts.server {
const LogFile = "--logFile";
const EnableTelemetry = "--enableTelemetry";
const TypingSafeListLocation = "--typingSafeListLocation";
const TypesMapLocation = "--typesMapLocation";
const NpmLocation = "--npmLocation";
}
function hasArgument(argumentName: string): boolean;
@@ -3838,9 +3859,6 @@ declare namespace ts.server {
function isInferredProjectName(name: string): boolean;
function makeInferredProjectName(counter: number): string;
function createSortedArray<T>(): SortedArray<T>;
function toSortedArray(arr: string[]): SortedArray<string>;
function toSortedArray<T>(arr: T[], comparer: Comparer<T>): SortedArray<T>;
function enumerateInsertsAndDeletes<T>(newItems: SortedReadonlyArray<T>, oldItems: SortedReadonlyArray<T>, inserted: (newItem: T) => void, deleted: (oldItem: T) => void, compare?: Comparer<T>): void;
class ThrottledOperations {
private readonly host;
private pendingTimeouts;
@@ -3857,13 +3875,12 @@ declare namespace ts.server {
scheduleCollect(): void;
private static run(self);
}
function insertSorted<T>(array: SortedArray<T>, insert: T, compare: Comparer<T>): void;
function removeSorted<T>(array: SortedArray<T>, remove: T, compare: Comparer<T>): void;
}
declare namespace ts.server.protocol {
enum CommandTypes {
const enum CommandTypes {
Brace = "brace",
BraceCompletion = "braceCompletion",
GetSpanOfEnclosingComment = "getSpanOfEnclosingComment",
Change = "change",
Close = "close",
Completions = "completions",
@@ -3951,6 +3968,13 @@ declare namespace ts.server.protocol {
interface TodoCommentsResponse extends Response {
body?: TodoComment[];
}
interface SpanOfEnclosingCommentRequest extends FileLocationRequest {
command: CommandTypes.GetSpanOfEnclosingComment;
arguments: SpanOfEnclosingCommentRequestArgs;
}
interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs {
onlyMultiLine: boolean;
}
interface IndentationRequest extends FileLocationRequest {
command: CommandTypes.Indentation;
arguments: IndentationRequestArgs;
@@ -4168,7 +4192,7 @@ declare namespace ts.server.protocol {
}
interface RenameResponseBody {
info: RenameInfo;
locs: SpanGroup[];
locs: ReadonlyArray<SpanGroup>;
}
interface RenameResponse extends Response {
body?: RenameResponseBody;
@@ -4248,6 +4272,7 @@ declare namespace ts.server.protocol {
}
interface SetCompilerOptionsForInferredProjectsArgs {
options: ExternalProjectCompilerOptions;
projectRootPath?: string;
}
interface SetCompilerOptionsForInferredProjectsResponse extends Response {
}
@@ -4603,7 +4628,7 @@ declare namespace ts.server.protocol {
interface NavTreeResponse extends Response {
body?: NavigationTree;
}
enum IndentStyle {
const enum IndentStyle {
None = "None",
Block = "Block",
Smart = "Smart",
@@ -4681,6 +4706,7 @@ declare namespace ts.server.protocol {
paths?: MapLike<string[]>;
plugins?: PluginImport[];
preserveConstEnums?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
removeComments?: boolean;
@@ -4700,13 +4726,13 @@ declare namespace ts.server.protocol {
typeRoots?: string[];
[option: string]: CompilerOptionsValue | undefined;
}
enum JsxEmit {
const enum JsxEmit {
None = "None",
Preserve = "Preserve",
ReactNative = "ReactNative",
React = "React",
}
enum ModuleKind {
const enum ModuleKind {
None = "None",
CommonJS = "CommonJS",
AMD = "AMD",
@@ -4714,20 +4740,24 @@ declare namespace ts.server.protocol {
System = "System",
ES6 = "ES6",
ES2015 = "ES2015",
ESNext = "ESNext",
}
enum ModuleResolutionKind {
const enum ModuleResolutionKind {
Classic = "Classic",
Node = "Node",
}
enum NewLineKind {
const enum NewLineKind {
Crlf = "Crlf",
Lf = "Lf",
}
enum ScriptTarget {
const enum ScriptTarget {
ES3 = "ES3",
ES5 = "ES5",
ES6 = "ES6",
ES2015 = "ES2015",
ES2016 = "ES2016",
ES2017 = "ES2017",
ESNext = "ESNext",
}
}
declare namespace ts.server {
@@ -4750,6 +4780,7 @@ declare namespace ts.server {
host: ServerHost;
cancellationToken: ServerCancellationToken;
useSingleInferredProject: boolean;
useInferredProjectPerProjectRoot: boolean;
typingsInstaller: ITypingsInstaller;
byteLength: (buf: string, encoding?: string) => number;
hrtime: (start?: number[]) => number[];
@@ -4757,8 +4788,8 @@ declare namespace ts.server {
canUseEvents: boolean;
eventHandler?: ProjectServiceEventHandler;
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
globalPlugins?: ReadonlyArray<string>;
pluginProbeLocations?: ReadonlyArray<string>;
allowLocalPluginLoads?: boolean;
}
class Session implements EventSender {
@@ -4780,13 +4811,13 @@ declare namespace ts.server {
private defaultEventHandler(event);
logError(err: Error, cmd: string): void;
send(msg: protocol.Message): void;
configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: Diagnostic[]): void;
configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ReadonlyArray<Diagnostic>): void;
event<T>(info: T, eventName: string): void;
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
private semanticCheck(file, project);
private syntacticCheck(file, project);
private updateProjectStructure(seq, matchSeq, ms?);
private updateErrorCheck(next, checkList, seq, matchSeq, ms?, followMs?, requireOpen?);
private updateProjectStructure();
private updateErrorCheck(next, checkList, ms, requireOpen?);
private cleanProjects(caption, projects);
private cleanup();
private getEncodedSemanticClassifications(args);
@@ -4820,6 +4851,7 @@ declare namespace ts.server {
private getOutliningSpans(args);
private getTodoComments(args);
private getDocCommentTemplate(args);
private getSpanOfEnclosingComment(args);
private getIndentation(args);
private getBreakpointStatement(args);
private getNameOrDottedNameSpan(args);
@@ -4878,38 +4910,10 @@ declare namespace ts.server {
}
}
declare namespace ts.server {
interface LineCollection {
charCount(): number;
lineCount(): number;
isLeaf(): this is LineLeaf;
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void;
}
interface AbsolutePositionAndLineText {
absolutePosition: number;
lineText: string | undefined;
}
enum CharRangeSection {
PreStart = 0,
Start = 1,
Entire = 2,
Mid = 3,
End = 4,
PostEnd = 5,
}
interface ILineIndexWalker {
goSubtree: boolean;
done: boolean;
leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void;
pre?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void;
post?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void;
}
class TextChange {
pos: number;
deleteLen: number;
insertedText: string;
constructor(pos: number, deleteLen: number, insertedText?: string);
getTextChangeRange(): TextChangeRange;
}
class ScriptVersionCache {
private changes;
private readonly versions;
@@ -4921,79 +4925,17 @@ declare namespace ts.server {
private versionToIndex(version);
private currentVersionToIndex();
edit(pos: number, deleteLen: number, insertedText?: string): void;
latest(): LineIndexSnapshot;
latestVersion(): number;
reload(script: string): void;
getSnapshot(): LineIndexSnapshot;
getSnapshot(): IScriptSnapshot;
private _getSnapshot();
getSnapshotVersion(): number;
getLineInfo(line: number): AbsolutePositionAndLineText;
lineOffsetToPosition(line: number, column: number): number;
positionToLineOffset(position: number): protocol.Location;
lineToTextSpan(line: number): TextSpan;
getTextChangesBetweenVersions(oldVersion: number, newVersion: number): TextChangeRange;
static fromString(script: string): ScriptVersionCache;
}
class LineIndexSnapshot implements IScriptSnapshot {
readonly version: number;
readonly cache: ScriptVersionCache;
readonly index: LineIndex;
readonly changesSincePreviousVersion: ReadonlyArray<TextChange>;
constructor(version: number, cache: ScriptVersionCache, index: LineIndex, changesSincePreviousVersion?: ReadonlyArray<TextChange>);
getText(rangeStart: number, rangeEnd: number): string;
getLength(): number;
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
}
class LineIndex {
root: LineNode;
checkEdits: boolean;
absolutePositionOfStartOfLine(oneBasedLine: number): number;
positionToLineOffset(position: number): protocol.Location;
private positionToColumnAndLineText(position);
lineNumberToInfo(oneBasedLine: number): AbsolutePositionAndLineText;
load(lines: string[]): void;
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void;
getText(rangeStart: number, rangeLength: number): string;
getLength(): number;
every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number): boolean;
edit(pos: number, deleteLength: number, newText?: string): LineIndex;
private static buildTreeFromBottom(nodes);
static linesFromText(text: string): {
lines: string[];
lineMap: number[];
};
}
class LineNode implements LineCollection {
private readonly children;
totalChars: number;
totalLines: number;
constructor(children?: LineCollection[]);
isLeaf(): boolean;
updateCounts(): void;
private execWalk(rangeStart, rangeLength, walkFns, childIndex, nodeType);
private skipChild(relativeStart, relativeLength, childIndex, walkFns, nodeType);
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void;
charOffsetToLineInfo(lineNumberAccumulator: number, relativePosition: number): {
oneBasedLine: number;
zeroBasedColumn: number;
lineText: string | undefined;
};
lineNumberToInfo(relativeOneBasedLine: number, positionAccumulator: number): {
position: number;
leaf: LineLeaf | undefined;
};
private childFromLineNumber(relativeOneBasedLine, positionAccumulator);
private childFromCharOffset(lineNumberAccumulator, relativePosition);
private splitAfter(childIndex);
remove(child: LineCollection): void;
private findChildIndex(child);
insertAt(child: LineCollection, nodes: LineCollection[]): LineNode[];
add(collection: LineCollection): void;
charCount(): number;
lineCount(): number;
}
class LineLeaf implements LineCollection {
text: string;
constructor(text: string);
isLeaf(): boolean;
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void;
charCount(): number;
lineCount(): number;
}
}
declare namespace ts.server {
class ScriptInfo {
@@ -5174,7 +5116,7 @@ declare namespace ts.server {
private projectStructureVersion;
private projectStateVersion;
private typingFiles;
protected projectErrors: Diagnostic[];
protected projectErrors: ReadonlyArray<Diagnostic>;
typesVersion: number;
isNonTsProject(): boolean;
isJsOnlyProject(): boolean;
@@ -5182,8 +5124,8 @@ declare namespace ts.server {
static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {};
constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean);
private setInternalCompilerOptionsForEmittingJsFiles();
getGlobalProjectErrors(): Diagnostic[];
getAllProjectErrors(): Diagnostic[];
getGlobalProjectErrors(): ReadonlyArray<Diagnostic>;
getAllProjectErrors(): ReadonlyArray<Diagnostic>;
getLanguageService(ensureSynchronized?: boolean): LanguageService;
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[];
getProjectVersion(): string;
@@ -5203,6 +5145,7 @@ declare namespace ts.server {
getRootScriptInfos(): ScriptInfo[];
getScriptInfos(): ScriptInfo[];
getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput;
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean): NormalizedPath[];
hasConfigFile(configFilePath: NormalizedPath): boolean;
getAllEmittableFiles(): string[];
@@ -5228,12 +5171,13 @@ declare namespace ts.server {
protected removeRoot(info: ScriptInfo): void;
}
class InferredProject extends Project {
readonly projectRootPath: string | undefined;
private static readonly newName;
private _isJsInferredProject;
toggleJsInferredProject(isJsInferredProject: boolean): void;
setCompilerOptions(options?: CompilerOptions): void;
directoriesWatchedForTsconfig: string[];
constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions);
constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, projectRootPath?: string);
addRoot(info: ScriptInfo): void;
removeRoot(info: ScriptInfo): void;
getProjectRootPath(): string;
@@ -5257,7 +5201,7 @@ declare namespace ts.server {
private enablePlugin(pluginConfigEntry, searchPaths);
private enableProxy(pluginModuleFactory, configEntry);
getProjectRootPath(): string;
setProjectErrors(projectErrors: Diagnostic[]): void;
setProjectErrors(projectErrors: ReadonlyArray<Diagnostic>): void;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
getTypeAcquisition(): TypeAcquisition;
getExternalFiles(): SortedReadonlyArray<string>;
@@ -5275,11 +5219,13 @@ declare namespace ts.server {
externalProjectName: string;
compileOnSaveEnabled: boolean;
private readonly projectFilePath;
excludedFiles: ReadonlyArray<NormalizedPath>;
private typeAcquisition;
constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string);
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
getProjectRootPath(): string;
getTypeAcquisition(): TypeAcquisition;
setProjectErrors(projectErrors: Diagnostic[]): void;
setProjectErrors(projectErrors: ReadonlyArray<Diagnostic>): void;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
}
}
@@ -5301,7 +5247,7 @@ declare namespace ts.server {
data: {
triggerFile: string;
configFileName: string;
diagnostics: Diagnostic[];
diagnostics: ReadonlyArray<Diagnostic>;
};
}
interface ProjectLanguageServiceStateEvent {
@@ -5353,11 +5299,15 @@ declare namespace ts.server {
types?: string[];
};
}
interface TypesMapFile {
typesMap: SafeList;
simpleMap: string[];
}
function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings;
function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin;
function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind;
function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX;
function combineProjectOutput<T>(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[];
function combineProjectOutput<T>(projects: ReadonlyArray<Project>, action: (project: Project) => ReadonlyArray<T>, comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[];
interface HostConfiguration {
formatCodeOptions: FormatCodeSettings;
hostInfo: string;
@@ -5365,19 +5315,21 @@ declare namespace ts.server {
}
interface OpenConfiguredProjectResult {
configFileName?: NormalizedPath;
configFileErrors?: Diagnostic[];
configFileErrors?: ReadonlyArray<Diagnostic>;
}
interface ProjectServiceOptions {
host: ServerHost;
logger: Logger;
cancellationToken: HostCancellationToken;
useSingleInferredProject: boolean;
useInferredProjectPerProjectRoot: boolean;
typingsInstaller: ITypingsInstaller;
eventHandler?: ProjectServiceEventHandler;
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
globalPlugins?: ReadonlyArray<string>;
pluginProbeLocations?: ReadonlyArray<string>;
allowLocalPluginLoads?: boolean;
typesMapLocation?: string;
}
class ProjectService {
readonly typingsCache: TypingsCache;
@@ -5389,7 +5341,7 @@ declare namespace ts.server {
readonly configuredProjects: ConfiguredProject[];
readonly openFiles: ScriptInfo[];
private compilerOptionsForInferredProjects;
private compileOnSaveForInferredProjects;
private compilerOptionsForInferredProjectsPerProjectRoot;
private readonly projectToSizeMap;
private readonly directoryWatchers;
private readonly throttledOperations;
@@ -5402,19 +5354,22 @@ declare namespace ts.server {
readonly logger: Logger;
readonly cancellationToken: HostCancellationToken;
readonly useSingleInferredProject: boolean;
readonly useInferredProjectPerProjectRoot: boolean;
readonly typingsInstaller: ITypingsInstaller;
readonly throttleWaitMilliseconds?: number;
private readonly eventHandler?;
readonly globalPlugins: ReadonlyArray<string>;
readonly pluginProbeLocations: ReadonlyArray<string>;
readonly allowLocalPluginLoads: boolean;
readonly typesMapLocation: string | undefined;
private readonly seenProjects;
constructor(opts: ProjectServiceOptions);
ensureInferredProjectsUpToDate_TestOnly(): void;
getCompilerOptionsForInferredProjects(): CompilerOptions;
onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void;
private loadTypesMap();
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void;
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void;
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void;
stopWatchingDirectory(directory: string): void;
findProject(projectName: string): Project;
getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project;
@@ -5431,7 +5386,7 @@ declare namespace ts.server {
private onConfigFileAddedForInferredProject(fileName);
private getCanonicalFileName(fileName);
private removeProject(project);
private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles);
private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles, projectRootPath?);
private closeOpenFile(info);
private deleteOrphanScriptInfoNotInAnyProject();
private openOrUpdateConfiguredProjectForFile(fileName, projectRootPath?);
@@ -5450,7 +5405,10 @@ declare namespace ts.server {
private openConfigFile(configFileName, clientFileName?);
private updateNonInferredProject<T>(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors);
private updateConfiguredProject(project);
createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject;
private getOrCreateInferredProjectForProjectRootPathIfEnabled(root, projectRootPath);
private getOrCreateSingleInferredProjectIfEnabled();
private createInferredProject(isSingleInferredProject?, projectRootPath?);
createInferredProjectWithRootFileIfNecessary(root: ScriptInfo, projectRootPath?: string): InferredProject;
getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo;
getScriptInfo(uncheckedFileName: string): ScriptInfo;
watchClosedScriptInfo(info: ScriptInfo): void;
@@ -5471,8 +5429,7 @@ declare namespace ts.server {
private static readonly filenameEscapeRegexp;
private static escapeFilenameForRegex(filename);
resetSafeList(): void;
loadSafeList(fileName: string): void;
applySafeList(proj: protocol.ExternalProject): void;
applySafeList(proj: protocol.ExternalProject): NormalizedPath[];
openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void;
}
}
+3341 -1804
View File
File diff suppressed because it is too large Load Diff
+65 -20
View File
@@ -1210,7 +1210,7 @@ declare namespace ts {
interface CatchClause extends Node {
kind: SyntaxKind.CatchClause;
parent?: TryStatement;
variableDeclaration: VariableDeclaration;
variableDeclaration?: VariableDeclaration;
block: Block;
}
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
@@ -1496,38 +1496,39 @@ declare namespace ts {
interface FlowLock {
locked?: boolean;
}
interface AfterFinallyFlow extends FlowNode, FlowLock {
interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
interface PreFinallyFlow extends FlowNode {
interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
interface FlowNode {
type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
interface FlowStart extends FlowNode {
interface FlowStart extends FlowNodeBase {
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
}
interface FlowLabel extends FlowNode {
interface FlowLabel extends FlowNodeBase {
antecedents: FlowNode[];
}
interface FlowAssignment extends FlowNode {
interface FlowAssignment extends FlowNodeBase {
node: Expression | VariableDeclaration | BindingElement;
antecedent: FlowNode;
}
interface FlowCondition extends FlowNode {
interface FlowCondition extends FlowNodeBase {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
interface FlowSwitchClause extends FlowNodeBase {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNode {
interface FlowArrayMutation extends FlowNodeBase {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
@@ -1696,6 +1697,15 @@ declare namespace ts {
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
/**
* If a symbol is a local symbol with an associated exported symbol, returns the exported symbol.
* Otherwise returns its input.
* For example, at `export type T = number;`:
* - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
* - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
* - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol.
*/
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
@@ -1790,11 +1800,11 @@ declare namespace ts {
UseFullyQualifiedType = 256,
InFirstTypeArgument = 512,
InTypeAlias = 1024,
UseTypeAliasValue = 2048,
SuppressAnyReturnType = 4096,
AddUndefined = 8192,
WriteClassExpressionAsTypeLiteral = 16384,
InArrayType = 32768,
UseAliasDefinedOutsideCurrentScope = 65536,
}
enum SymbolFormatFlags {
None = 0,
@@ -2056,6 +2066,7 @@ declare namespace ts {
interface TypeVariable extends Type {
}
interface TypeParameter extends TypeVariable {
/** Retrieve using getConstraintFromTypeParameter */
constraint: Type;
default?: Type;
}
@@ -2103,6 +2114,21 @@ declare namespace ts {
NoDefault = 2,
AnyDefault = 4,
}
/**
* Ternary values are defined such that
* x & y is False if either x or y is False.
* x & y is Maybe if either x or y is Maybe, but neither x or y is False.
* x & y is True if both x and y are True.
* x | y is False if both x and y are False.
* x | y is Maybe if either x or y is Maybe, but neither x or y is True.
* x | y is True if either x or y is True.
*/
enum Ternary {
False = 0,
Maybe = 1,
True = -1,
}
type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary;
interface JsFileExtensionInfo {
extension: string;
isMixedContent: boolean;
@@ -2195,6 +2221,7 @@ declare namespace ts {
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
jsxFactory?: string;
@@ -2300,6 +2327,10 @@ declare namespace ts {
readFile(fileName: string): string | undefined;
trace?(s: string): void;
directoryExists?(directoryName: string): boolean;
/**
* Resolve a symbolic link.
* @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options
*/
realpath?(path: string): string;
getCurrentDirectory?(): string;
getDirectories?(path: string): string[];
@@ -2314,17 +2345,13 @@ declare namespace ts {
interface ResolvedModule {
/** Path of the file the module was resolved to. */
resolvedFileName: string;
/**
* Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module:
* - be a .d.ts file
* - use top level imports\exports
* - don't use tripleslash references
*/
/** True if `resolvedFileName` comes from `node_modules`. */
isExternalLibraryImport?: boolean;
}
/**
* ResolvedModule with an explicitly provided `extension` property.
* Prefer this over `ResolvedModule`.
* If changing this, remember to change `moduleResolutionIsEqualTo`.
*/
interface ResolvedModuleFull extends ResolvedModule {
/**
@@ -2332,6 +2359,21 @@ declare namespace ts {
* This is optional for backwards-compatibility, but will be added if not provided.
*/
extension: Extension;
packageId?: PackageId;
}
/**
* Unique identifier with a package name and version.
* If changing this, remember to change `packageIdIsEqual`.
*/
interface PackageId {
/**
* Name of the package.
* Should not include `@types`.
* If accessing a non-index file, this should include its name e.g. "foo/bar".
*/
name: string;
/** Version of the package, e.g. "1.2.3" */
version: string;
}
enum Extension {
Ts = ".ts",
@@ -2593,7 +2635,7 @@ declare namespace ts {
}
}
declare namespace ts {
const versionMajorMinor = "2.5";
const versionMajorMinor = "2.6";
/** The version of the TypeScript compiler release */
const version: string;
}
@@ -2741,6 +2783,8 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray<TextChangeRange>): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: Node): boolean;
function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
function isEmptyBindingElement(node: BindingElement): boolean;
function getCombinedModifierFlags(node: Node): ModifierFlags;
function getCombinedNodeFlags(node: Node): NodeFlags;
/**
@@ -3310,8 +3354,8 @@ declare namespace ts {
function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray<Statement>): DefaultClause;
function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function updateHeritageClause(node: HeritageClause, types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause;
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment;
function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment;
@@ -3773,6 +3817,7 @@ declare namespace ts {
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined;
+3070 -1394
View File
File diff suppressed because it is too large Load Diff
+65 -20
View File
@@ -1210,7 +1210,7 @@ declare namespace ts {
interface CatchClause extends Node {
kind: SyntaxKind.CatchClause;
parent?: TryStatement;
variableDeclaration: VariableDeclaration;
variableDeclaration?: VariableDeclaration;
block: Block;
}
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
@@ -1496,38 +1496,39 @@ declare namespace ts {
interface FlowLock {
locked?: boolean;
}
interface AfterFinallyFlow extends FlowNode, FlowLock {
interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
interface PreFinallyFlow extends FlowNode {
interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
interface FlowNode {
type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
interface FlowStart extends FlowNode {
interface FlowStart extends FlowNodeBase {
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
}
interface FlowLabel extends FlowNode {
interface FlowLabel extends FlowNodeBase {
antecedents: FlowNode[];
}
interface FlowAssignment extends FlowNode {
interface FlowAssignment extends FlowNodeBase {
node: Expression | VariableDeclaration | BindingElement;
antecedent: FlowNode;
}
interface FlowCondition extends FlowNode {
interface FlowCondition extends FlowNodeBase {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
interface FlowSwitchClause extends FlowNodeBase {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNode {
interface FlowArrayMutation extends FlowNodeBase {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
@@ -1696,6 +1697,15 @@ declare namespace ts {
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
/**
* If a symbol is a local symbol with an associated exported symbol, returns the exported symbol.
* Otherwise returns its input.
* For example, at `export type T = number;`:
* - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
* - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
* - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol.
*/
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
@@ -1790,11 +1800,11 @@ declare namespace ts {
UseFullyQualifiedType = 256,
InFirstTypeArgument = 512,
InTypeAlias = 1024,
UseTypeAliasValue = 2048,
SuppressAnyReturnType = 4096,
AddUndefined = 8192,
WriteClassExpressionAsTypeLiteral = 16384,
InArrayType = 32768,
UseAliasDefinedOutsideCurrentScope = 65536,
}
enum SymbolFormatFlags {
None = 0,
@@ -2056,6 +2066,7 @@ declare namespace ts {
interface TypeVariable extends Type {
}
interface TypeParameter extends TypeVariable {
/** Retrieve using getConstraintFromTypeParameter */
constraint: Type;
default?: Type;
}
@@ -2103,6 +2114,21 @@ declare namespace ts {
NoDefault = 2,
AnyDefault = 4,
}
/**
* Ternary values are defined such that
* x & y is False if either x or y is False.
* x & y is Maybe if either x or y is Maybe, but neither x or y is False.
* x & y is True if both x and y are True.
* x | y is False if both x and y are False.
* x | y is Maybe if either x or y is Maybe, but neither x or y is True.
* x | y is True if either x or y is True.
*/
enum Ternary {
False = 0,
Maybe = 1,
True = -1,
}
type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary;
interface JsFileExtensionInfo {
extension: string;
isMixedContent: boolean;
@@ -2195,6 +2221,7 @@ declare namespace ts {
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
preserveSymlinks?: boolean;
project?: string;
reactNamespace?: string;
jsxFactory?: string;
@@ -2300,6 +2327,10 @@ declare namespace ts {
readFile(fileName: string): string | undefined;
trace?(s: string): void;
directoryExists?(directoryName: string): boolean;
/**
* Resolve a symbolic link.
* @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options
*/
realpath?(path: string): string;
getCurrentDirectory?(): string;
getDirectories?(path: string): string[];
@@ -2314,17 +2345,13 @@ declare namespace ts {
interface ResolvedModule {
/** Path of the file the module was resolved to. */
resolvedFileName: string;
/**
* Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module:
* - be a .d.ts file
* - use top level imports\exports
* - don't use tripleslash references
*/
/** True if `resolvedFileName` comes from `node_modules`. */
isExternalLibraryImport?: boolean;
}
/**
* ResolvedModule with an explicitly provided `extension` property.
* Prefer this over `ResolvedModule`.
* If changing this, remember to change `moduleResolutionIsEqualTo`.
*/
interface ResolvedModuleFull extends ResolvedModule {
/**
@@ -2332,6 +2359,21 @@ declare namespace ts {
* This is optional for backwards-compatibility, but will be added if not provided.
*/
extension: Extension;
packageId?: PackageId;
}
/**
* Unique identifier with a package name and version.
* If changing this, remember to change `packageIdIsEqual`.
*/
interface PackageId {
/**
* Name of the package.
* Should not include `@types`.
* If accessing a non-index file, this should include its name e.g. "foo/bar".
*/
name: string;
/** Version of the package, e.g. "1.2.3" */
version: string;
}
enum Extension {
Ts = ".ts",
@@ -2593,7 +2635,7 @@ declare namespace ts {
}
}
declare namespace ts {
const versionMajorMinor = "2.5";
const versionMajorMinor = "2.6";
/** The version of the TypeScript compiler release */
const version: string;
}
@@ -2741,6 +2783,8 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray<TextChangeRange>): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: Node): boolean;
function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
function isEmptyBindingElement(node: BindingElement): boolean;
function getCombinedModifierFlags(node: Node): ModifierFlags;
function getCombinedNodeFlags(node: Node): NodeFlags;
/**
@@ -3310,8 +3354,8 @@ declare namespace ts {
function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray<Statement>): DefaultClause;
function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function updateHeritageClause(node: HeritageClause, types: ReadonlyArray<ExpressionWithTypeArguments>): HeritageClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause;
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause;
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment;
function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment;
@@ -3773,6 +3817,7 @@ declare namespace ts {
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined;
+3070 -1394
View File
File diff suppressed because it is too large Load Diff
+1492 -323
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -17,6 +17,6 @@ nodeVersions.each { nodeVer ->
}
Utilities.standardJobSetup(newJob, project, true, "*/${branch}")
Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020')
Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', '20161020')
Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}")
}
+3
View File
@@ -93,5 +93,8 @@
"fs": false,
"os": false,
"path": false
},
"dependencies": {
"browser-resolve": "^1.11.2"
}
}
+92 -13
View File
@@ -1,5 +1,6 @@
/// <reference path="moduleNameResolver.ts"/>
/// <reference path="binder.ts"/>
/// <reference path="symbolWalker.ts" />
/* @internal */
namespace ts {
@@ -205,6 +206,7 @@ namespace ts {
getEmitResolver,
getExportsOfModule: getExportsOfModuleAsArray,
getExportsAndPropertiesOfModule,
getSymbolWalker: createGetSymbolWalker(getRestTypeOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier),
getAmbientModules,
getAllAttributesTypeFromJsxOpeningLikeElement: node => {
node = getParseTreeNode(node, isJsxOpeningLikeElement);
@@ -795,12 +797,17 @@ namespace ts {
// 2. inside a function
// 3. inside an instance property initializer, a reference to a non-instance property
// 4. inside a static property initializer, a reference to a static method in the same class
// 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ)
// or if usage is in a type context:
// 1. inside a type query (typeof in type position)
if (usage.parent.kind === SyntaxKind.ExportSpecifier) {
if (usage.parent.kind === SyntaxKind.ExportSpecifier || (usage.parent.kind === SyntaxKind.ExportAssignment && (usage.parent as ExportAssignment).isExportEquals)) {
// export specifiers do not use the variable, they only make it available for use
return true;
}
// When resolving symbols for exports, the `usage` location passed in can be the export site directly
if (usage.kind === SyntaxKind.ExportAssignment && (usage as ExportAssignment).isExportEquals) {
return true;
}
const container = getEnclosingBlockScopeContainer(declaration);
return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container);
@@ -1017,7 +1024,18 @@ namespace ts {
}
}
break;
case SyntaxKind.ExpressionWithTypeArguments:
// The type parameters of a class are not in scope in the base class expression.
if (lastLocation === (<ExpressionWithTypeArguments>location).expression && (<HeritageClause>location.parent).token === SyntaxKind.ExtendsKeyword) {
const container = location.parent.parent;
if (isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & SymbolFlags.Type))) {
if (nameNotFoundMessage) {
error(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
}
return undefined;
}
}
break;
// It is not legal to reference a class's own type parameters from a computed property name that
// belongs to the class. For example:
//
@@ -8801,8 +8819,7 @@ namespace ts {
return true;
}
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
const related = relation.get(id);
const related = relation.get(getRelationKey(source, target, relation));
if (related !== undefined) {
return related === RelationComparisonResult.Succeeded;
}
@@ -9073,11 +9090,26 @@ namespace ts {
else {
// use the property's value declaration if the property is assigned inside the literal itself
const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations);
let suggestion;
if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration)) {
errorNode = prop.valueDeclaration;
const propDeclaration = prop.valueDeclaration as ObjectLiteralElementLike;
Debug.assertNode(propDeclaration, isObjectLiteralElementLike);
errorNode = propDeclaration;
if (isIdentifier(propDeclaration.name)) {
suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target);
}
}
if (suggestion !== undefined) {
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2,
symbolToString(prop), typeToString(target), unescapeLeadingUnderscores(suggestion));
}
else {
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
symbolToString(prop), typeToString(target));
}
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
symbolToString(prop), typeToString(target));
}
}
return true;
@@ -9203,7 +9235,7 @@ namespace ts {
if (overflow) {
return Ternary.False;
}
const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
const id = getRelationKey(source, target, relation);
const related = relation.get(id);
if (related !== undefined) {
if (reportErrors && related === RelationComparisonResult.Failed) {
@@ -9768,6 +9800,53 @@ namespace ts {
}
}
function isUnconstrainedTypeParameter(type: Type) {
return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(<TypeParameter>type);
}
function isTypeReferenceWithGenericArguments(type: Type) {
return getObjectFlags(type) & ObjectFlags.Reference && some((<TypeReference>type).typeArguments, isUnconstrainedTypeParameter);
}
/**
* getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
* where A.id=111 and number.id=12
*/
function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) {
let result = "" + type.target.id;
for (const t of type.typeArguments) {
if (isUnconstrainedTypeParameter(t)) {
let index = indexOf(typeParameters, t);
if (index < 0) {
index = typeParameters.length;
typeParameters.push(t);
}
result += "=" + index;
}
else {
result += "-" + t.id;
}
}
return result;
}
/**
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
* For other cases, the types ids are used.
*/
function getRelationKey(source: Type, target: Type, relation: Map<RelationComparisonResult>) {
if (relation === identityRelation && source.id > target.id) {
const temp = source;
source = target;
target = temp;
}
if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
const typeParameters: Type[] = [];
return getTypeReferenceId(<TypeReference>source, typeParameters) + "," + getTypeReferenceId(<TypeReference>target, typeParameters);
}
return source.id + "," + target.id;
}
// Invoke the callback for each underlying property symbol of the given symbol and return the first
// value that isn't undefined.
function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T {
@@ -13112,12 +13191,12 @@ namespace ts {
if (isJsxAttribute(node.parent)) {
// JSX expression is in JSX attribute
return getTypeOfPropertyOfType(attributesType, node.parent.name.escapedText);
return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText);
}
else if (node.parent.kind === SyntaxKind.JsxElement) {
// JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty)
const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType;
return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType;
}
else {
// JSX expression is in JSX spread attribute
@@ -13135,7 +13214,7 @@ namespace ts {
if (!attributesType || isTypeAny(attributesType)) {
return undefined;
}
return getTypeOfPropertyOfType(attributesType, attribute.name.escapedText);
return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
}
else {
return attributesType;
@@ -14682,8 +14761,8 @@ namespace ts {
}
}
const suggestion = getSuggestionForNonexistentProperty(propNode, containingType);
if (suggestion) {
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion);
if (suggestion !== undefined) {
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), unescapeLeadingUnderscores(suggestion));
}
else {
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
+1 -1
View File
@@ -1359,7 +1359,7 @@ namespace ts {
};
}
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: string[]): DiagnosticMessageChain;
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
let text = getLocaleSpecificMessage(message);
+8
View File
@@ -1912,6 +1912,14 @@
"category": "Error",
"code": 2560
},
"Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?": {
"category": "Error",
"code": 2561
},
"Base class expressions cannot reference class type parameters.": {
"category": "Error",
"code": 2562
},
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600
+1
View File
@@ -2721,6 +2721,7 @@ namespace ts {
case SyntaxKind.FalseKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.AsteriskToken:
case SyntaxKind.QuestionToken:
return true;
case SyntaxKind.MinusToken:
return lookAhead(nextTokenIsNumericLiteral);
+191
View File
@@ -0,0 +1,191 @@
/** @internal */
namespace ts {
export function createGetSymbolWalker(
getRestTypeOfSignature: (sig: Signature) => Type,
getReturnTypeOfSignature: (sig: Signature) => Type,
getBaseTypes: (type: Type) => Type[],
resolveStructuredTypeMembers: (type: ObjectType) => ResolvedType,
getTypeOfSymbol: (sym: Symbol) => Type,
getResolvedSymbol: (node: Node) => Symbol,
getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type,
getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type,
getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier) {
return getSymbolWalker;
function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker {
const visitedTypes = createMap<Type>(); // Key is id as string
const visitedSymbols = createMap<Symbol>(); // Key is id as string
return {
walkType: type => {
visitedTypes.clear();
visitedSymbols.clear();
visitType(type);
return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) };
},
walkSymbol: symbol => {
visitedTypes.clear();
visitedSymbols.clear();
visitSymbol(symbol);
return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) };
},
};
function visitType(type: Type): void {
if (!type) {
return;
}
const typeIdString = type.id.toString();
if (visitedTypes.has(typeIdString)) {
return;
}
visitedTypes.set(typeIdString, type);
// Reuse visitSymbol to visit the type's symbol,
// but be sure to bail on recuring into the type if accept declines the symbol.
const shouldBail = visitSymbol(type.symbol);
if (shouldBail) return;
// Visit the type's related types, if any
if (type.flags & TypeFlags.Object) {
const objectType = type as ObjectType;
const objectFlags = objectType.objectFlags;
if (objectFlags & ObjectFlags.Reference) {
visitTypeReference(type as TypeReference);
}
if (objectFlags & ObjectFlags.Mapped) {
visitMappedType(type as MappedType);
}
if (objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)) {
visitInterfaceType(type as InterfaceType);
}
if (objectFlags & (ObjectFlags.Tuple | ObjectFlags.Anonymous)) {
visitObjectType(objectType);
}
}
if (type.flags & TypeFlags.TypeParameter) {
visitTypeParameter(type as TypeParameter);
}
if (type.flags & TypeFlags.UnionOrIntersection) {
visitUnionOrIntersectionType(type as UnionOrIntersectionType);
}
if (type.flags & TypeFlags.Index) {
visitIndexType(type as IndexType);
}
if (type.flags & TypeFlags.IndexedAccess) {
visitIndexedAccessType(type as IndexedAccessType);
}
}
function visitTypeList(types: Type[]): void {
if (!types) {
return;
}
for (let i = 0; i < types.length; i++) {
visitType(types[i]);
}
}
function visitTypeReference(type: TypeReference): void {
visitType(type.target);
visitTypeList(type.typeArguments);
}
function visitTypeParameter(type: TypeParameter): void {
visitType(getConstraintFromTypeParameter(type));
}
function visitUnionOrIntersectionType(type: UnionOrIntersectionType): void {
visitTypeList(type.types);
}
function visitIndexType(type: IndexType): void {
visitType(type.type);
}
function visitIndexedAccessType(type: IndexedAccessType): void {
visitType(type.objectType);
visitType(type.indexType);
visitType(type.constraint);
}
function visitMappedType(type: MappedType): void {
visitType(type.typeParameter);
visitType(type.constraintType);
visitType(type.templateType);
visitType(type.modifiersType);
}
function visitSignature(signature: Signature): void {
if (signature.typePredicate) {
visitType(signature.typePredicate.type);
}
visitTypeList(signature.typeParameters);
for (const parameter of signature.parameters){
visitSymbol(parameter);
}
visitType(getRestTypeOfSignature(signature));
visitType(getReturnTypeOfSignature(signature));
}
function visitInterfaceType(interfaceT: InterfaceType): void {
visitObjectType(interfaceT);
visitTypeList(interfaceT.typeParameters);
visitTypeList(getBaseTypes(interfaceT));
visitType(interfaceT.thisType);
}
function visitObjectType(type: ObjectType): void {
const stringIndexType = getIndexTypeOfStructuredType(type, IndexKind.String);
visitType(stringIndexType);
const numberIndexType = getIndexTypeOfStructuredType(type, IndexKind.Number);
visitType(numberIndexType);
// The two checks above *should* have already resolved the type (if needed), so this should be cached
const resolved = resolveStructuredTypeMembers(type);
for (const signature of resolved.callSignatures) {
visitSignature(signature);
}
for (const signature of resolved.constructSignatures) {
visitSignature(signature);
}
for (const p of resolved.properties) {
visitSymbol(p);
}
}
function visitSymbol(symbol: Symbol): boolean {
if (!symbol) {
return;
}
const symbolIdString = getSymbolId(symbol).toString();
if (visitedSymbols.has(symbolIdString)) {
return;
}
visitedSymbols.set(symbolIdString, symbol);
if (!accept(symbol)) {
return true;
}
const t = getTypeOfSymbol(symbol);
visitType(t); // Should handle members on classes and such
if (symbol.flags & SymbolFlags.HasExports) {
symbol.exports.forEach(visitSymbol);
}
forEach(symbol.declarations, d => {
// Type queries are too far resolved when we just visit the symbol's type
// (their type resolved directly to the member deeply referenced)
// So to get the intervening symbols, we need to check if there's a type
// query node on any of the symbol's declarations and get symbols there
if ((d as any).type && (d as any).type.kind === SyntaxKind.TypeQuery) {
const query = (d as any).type as TypeQueryNode;
const entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
visitSymbol(entity);
}
});
}
}
}
}
+3 -3
View File
@@ -158,8 +158,8 @@ namespace ts {
return visitEachChild(node, visitor, context);
}
function chunkObjectLiteralElements(elements: ReadonlyArray<ObjectLiteralElement>): Expression[] {
let chunkObject: (ShorthandPropertyAssignment | PropertyAssignment)[];
function chunkObjectLiteralElements(elements: ReadonlyArray<ObjectLiteralElementLike>): Expression[] {
let chunkObject: ObjectLiteralElementLike[];
const objects: Expression[] = [];
for (const e of elements) {
if (e.kind === SyntaxKind.SpreadAssignment) {
@@ -179,7 +179,7 @@ namespace ts {
chunkObject.push(createPropertyAssignment(p.name, visitNode(p.initializer, visitor, isExpression)));
}
else {
chunkObject.push(e as ShorthandPropertyAssignment);
chunkObject.push(visitNode(e, visitor, isObjectLiteralElementLike));
}
}
}
+46 -36
View File
@@ -1639,8 +1639,13 @@ namespace ts {
function transformAndEmitContinueStatement(node: ContinueStatement): void {
const label = findContinueTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined);
Debug.assert(label > 0, "Expected continue statment to point to a valid Label.");
emitBreak(label, /*location*/ node);
if (label > 0) {
emitBreak(label, /*location*/ node);
}
else {
// invalid continue without a containing loop. Leave the node as is, per #17875.
emitStatement(node);
}
}
function visitContinueStatement(node: ContinueStatement): Statement {
@@ -1656,8 +1661,13 @@ namespace ts {
function transformAndEmitBreakStatement(node: BreakStatement): void {
const label = findBreakTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined);
Debug.assert(label > 0, "Expected break statment to point to a valid Label.");
emitBreak(label, /*location*/ node);
if (label > 0) {
emitBreak(label, /*location*/ node);
}
else {
// invalid break without a containing loop, switch, or labeled statement. Leave the node as is, per #17875.
emitStatement(node);
}
}
function visitBreakStatement(node: BreakStatement): Statement {
@@ -2351,27 +2361,27 @@ namespace ts {
* @param labelText An optional name of a containing labeled statement.
*/
function findBreakTarget(labelText?: string): Label {
Debug.assert(blocks !== undefined);
if (labelText) {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
return block.breakLabel;
if (blockStack) {
if (labelText) {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
return block.breakLabel;
}
else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
return block.breakLabel;
}
}
else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
return block.breakLabel;
}
else {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledBreak(block)) {
return block.breakLabel;
}
}
}
}
else {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledBreak(block)) {
return block.breakLabel;
}
}
}
return 0;
}
@@ -2381,24 +2391,24 @@ namespace ts {
* @param labelText An optional name of a containing labeled statement.
*/
function findContinueTarget(labelText?: string): Label {
Debug.assert(blocks !== undefined);
if (labelText) {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
return block.continueLabel;
if (blockStack) {
if (labelText) {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
return block.continueLabel;
}
}
}
else {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledContinue(block)) {
return block.continueLabel;
}
}
}
}
else {
for (let i = blockStack.length - 1; i >= 0; i--) {
const block = blockStack[i];
if (supportsUnlabeledContinue(block)) {
return block.continueLabel;
}
}
}
return 0;
}
+1
View File
@@ -14,6 +14,7 @@
"parser.ts",
"utilities.ts",
"binder.ts",
"symbolWalker.ts",
"checker.ts",
"factory.ts",
"visitor.ts",
+13 -2
View File
@@ -2431,7 +2431,7 @@ namespace ts {
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
/**
* Gets a type checker that can be used to semantically analyze source fils in the program.
* Gets a type checker that can be used to semantically analyze source files in the program.
*/
getTypeChecker(): TypeChecker;
@@ -2451,7 +2451,7 @@ namespace ts {
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective>;
/* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean;
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
// For testing purposes only.
/* @internal */ structureIsReused?: StructureIsReused;
@@ -2625,6 +2625,8 @@ namespace ts {
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined;
/* @internal */ getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker;
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
@@ -2669,6 +2671,14 @@ namespace ts {
InTypeAlias = 1 << 23, // Writing type in type alias declaration
}
/* @internal */
export interface SymbolWalker {
/** Note: Return values are not ordered. */
walkType(root: Type): { visitedTypes: ReadonlyArray<Type>, visitedSymbols: ReadonlyArray<Symbol> };
/** Note: Return values are not ordered. */
walkSymbol(root: Symbol): { visitedTypes: ReadonlyArray<Type>, visitedSymbols: ReadonlyArray<Symbol> };
}
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;
@@ -3367,6 +3377,7 @@ namespace ts {
// Type parameters (TypeFlags.TypeParameter)
export interface TypeParameter extends TypeVariable {
/** Retrieve using getConstraintFromTypeParameter */
constraint: Type; // Constraint
default?: Type;
/* @internal */
+5 -3
View File
@@ -1,5 +1,5 @@
const fs: any = require("fs");
const path: any = require("path");
import fs = require("fs");
import path = require("path");
function instrumentForRecording(fn: string, tscPath: string) {
instrument(tscPath, `
@@ -38,7 +38,9 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode = "") {
const index2 = index1 + invocationLine.length;
const newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + "\r\n";
fs.writeFile(tscPath, newContent);
fs.writeFile(tscPath, newContent, err => {
if (err) throw err;
});
});
});
});
+2
View File
@@ -21,6 +21,7 @@
"../compiler/parser.ts",
"../compiler/utilities.ts",
"../compiler/binder.ts",
"../compiler/symbolWalker.ts",
"../compiler/checker.ts",
"../compiler/factory.ts",
"../compiler/visitor.ts",
@@ -103,6 +104,7 @@
"./unittests/services/preProcessFile.ts",
"./unittests/services/patternMatcher.ts",
"./unittests/session.ts",
"./unittests/symbolWalker.ts",
"./unittests/versionCache.ts",
"./unittests/convertToBase64.ts",
"./unittests/transpile.ts",
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="..\harness.ts" />
namespace ts {
describe("Symbol Walker", () => {
function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker) => void) {
it(description, () => {
let {result} = Harness.Compiler.compileFiles([{
unitName: "main.ts",
content: source
}], [], {}, {}, "/");
let file = result.program.getSourceFile("main.ts");
let checker = result.program.getTypeChecker();
verifier(file, checker);
result = undefined;
file = undefined;
checker = undefined;
});
}
test("can be created", `
interface Bar {
x: number;
y: number;
history: Bar[];
}
export default function foo(a: number, b: Bar): void {}`, (file, checker) => {
let foundCount = 0;
let stdLibRefSymbols = 0;
const expectedSymbols = ["default", "a", "b", "Bar", "x", "y", "history"];
const walker = checker.getSymbolWalker(symbol => {
const isStdLibSymbol = forEach(symbol.declarations, d => {
return getSourceFileOfNode(d).hasNoDefaultLib;
});
if (isStdLibSymbol) {
stdLibRefSymbols++;
return false; // Don't traverse into the stdlib. That's unnecessary for this test.
}
assert.equal(symbol.name, expectedSymbols[foundCount]);
foundCount++;
return true;
});
const symbols = checker.getExportsOfModule(file.symbol);
for (const symbol of symbols) {
walker.walkSymbol(symbol);
}
assert.equal(foundCount, expectedSymbols.length);
assert.equal(stdLibRefSymbols, 1); // Expect 1 stdlib entry symbol - the implicit Array referenced by Bar.history
});
});
}
+24 -10
View File
@@ -18,14 +18,28 @@ namespace ts.projectSystem {
})
};
const customSafeList = {
path: <Path>"/typeMapList.json",
content: JSON.stringify({
"quack": {
"match": "/duckquack-(\\d+)\\.min\\.js",
"types": ["duck-types"]
export const customTypesMap = {
path: <Path>"/typesMap.json",
content: `{
"typesMap": {
"jquery": {
"match": "jquery(-(\\\\.?\\\\d+)+)?(\\\\.intellisense)?(\\\\.min)?\\\\.js$",
"types": ["jquery"]
},
"quack": {
"match": "/duckquack-(\\\\d+)\\\\.min\\\\.js",
"types": ["duck-types"]
}
},
})
"simpleMap": {
"Bacon": "baconjs",
"bliss": "blissfuljs",
"commander": "commander",
"cordova": "cordova",
"react": "react",
"lodash": "lodash"
}
}`
};
export interface PostExecAction {
@@ -59,7 +73,7 @@ namespace ts.projectSystem {
installTypingHost: server.ServerHost,
readonly typesRegistry = createMap<void>(),
log?: TI.Log) {
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log);
super(installTypingHost, globalTypingsCacheLocation, safeList.path, customTypesMap.path, throttleLimit, log);
}
protected postExecActions: PostExecAction[] = [];
@@ -229,6 +243,7 @@ namespace ts.projectSystem {
useSingleInferredProject,
useInferredProjectPerProjectRoot: false,
typingsInstaller,
typesMapLocation: customTypesMap.path,
eventHandler,
...opts
});
@@ -1491,9 +1506,8 @@ namespace ts.projectSystem {
path: "/lib/duckquack-3.min.js",
content: "whoa do @@ not parse me ok thanks!!!"
};
const host = createServerHost([customSafeList, file1, office]);
const host = createServerHost([file1, office, customTypesMap]);
const projectService = createProjectService(host);
projectService.loadSafeList(customSafeList.path);
try {
projectService.openExternalProject({ projectFileName: "project", options: {}, rootFiles: toExternalFiles([file1.path, office.path]) });
const proj = projectService.externalProjects[0];
+4 -4
View File
@@ -322,7 +322,7 @@ namespace ts.projectSystem {
content: "declare const lodash: { x: number }"
};
const host = createServerHost([file1, file2, file3]);
const host = createServerHost([file1, file2, file3, customTypesMap]);
const installer = new (class extends Installer {
constructor() {
super(host, { typesRegistry: createTypesRegistry("lodash", "react") });
@@ -445,7 +445,7 @@ namespace ts.projectSystem {
content: "declare const moment: { x: number }"
};
const host = createServerHost([file1, file2, file3, packageJson]);
const host = createServerHost([file1, file2, file3, packageJson, customTypesMap]);
const installer = new (class extends Installer {
constructor() {
super(host, { typesRegistry: createTypesRegistry("jquery", "commander", "moment", "express") });
@@ -521,7 +521,7 @@ namespace ts.projectSystem {
};
const typingFiles = [commander, express, jquery, moment, lodash];
const host = createServerHost([lodashJs, commanderJs, file3, packageJson]);
const host = createServerHost([lodashJs, commanderJs, file3, packageJson, customTypesMap]);
const installer = new (class extends Installer {
constructor() {
super(host, { throttleLimit: 3, typesRegistry: createTypesRegistry("commander", "express", "jquery", "moment", "lodash") });
@@ -600,7 +600,7 @@ namespace ts.projectSystem {
typings: typingsName("gulp")
};
const host = createServerHost([lodashJs, commanderJs, file3]);
const host = createServerHost([lodashJs, commanderJs, file3, customTypesMap]);
const installer = new (class extends Installer {
constructor() {
super(host, { throttleLimit: 1, typesRegistry: createTypesRegistry("commander", "jquery", "lodash", "cordova", "gulp", "grunt") });
+170 -109
View File
@@ -4,11 +4,11 @@
/////////////////////////////
interface Account {
displayName?: string;
id?: string;
displayName: string;
id: string;
imageURL?: string;
name?: string;
rpDisplayName?: string;
rpDisplayName: string;
}
interface Algorithm {
@@ -35,11 +35,11 @@ interface CacheQueryOptions {
}
interface ClientData {
challenge?: string;
challenge: string;
extensions?: WebAuthnExtensions;
hashAlg?: string | Algorithm;
origin?: string;
rpId?: string;
hashAlg: string | Algorithm;
origin: string;
rpId: string;
tokenBinding?: string;
}
@@ -87,9 +87,9 @@ interface CustomEventInit extends EventInit {
}
interface DeviceAccelerationDict {
x?: number;
y?: number;
z?: number;
x?: number | null;
y?: number | null;
z?: number | null;
}
interface DeviceLightEventInit extends EventInit {
@@ -97,30 +97,30 @@ interface DeviceLightEventInit extends EventInit {
}
interface DeviceMotionEventInit extends EventInit {
acceleration?: DeviceAccelerationDict;
accelerationIncludingGravity?: DeviceAccelerationDict;
interval?: number;
rotationRate?: DeviceRotationRateDict;
acceleration?: DeviceAccelerationDict | null;
accelerationIncludingGravity?: DeviceAccelerationDict | null;
interval?: number | null;
rotationRate?: DeviceRotationRateDict | null;
}
interface DeviceOrientationEventInit extends EventInit {
absolute?: boolean;
alpha?: number;
beta?: number;
gamma?: number;
alpha?: number | null;
beta?: number | null;
gamma?: number | null;
}
interface DeviceRotationRateDict {
alpha?: number;
beta?: number;
gamma?: number;
alpha?: number | null;
beta?: number | null;
gamma?: number | null;
}
interface DOMRectInit {
height?: any;
width?: any;
x?: any;
y?: any;
height?: number;
width?: number;
x?: number;
y?: number;
}
interface DoubleRange {
@@ -161,15 +161,15 @@ interface EventModifierInit extends UIEventInit {
}
interface ExceptionInformation {
domain?: string;
domain?: string | null;
}
interface FocusEventInit extends UIEventInit {
relatedTarget?: EventTarget;
relatedTarget?: EventTarget | null;
}
interface FocusNavigationEventInit extends EventInit {
navigationReason?: string;
navigationReason?: string | null;
originHeight?: number;
originLeft?: number;
originTop?: number;
@@ -184,7 +184,7 @@ interface FocusNavigationOrigin {
}
interface GamepadEventInit extends EventInit {
gamepad?: Gamepad;
gamepad?: Gamepad | null;
}
interface GetNotificationOptions {
@@ -192,8 +192,8 @@ interface GetNotificationOptions {
}
interface HashChangeEventInit extends EventInit {
newURL?: string;
oldURL?: string;
newURL?: string | null;
oldURL?: string | null;
}
interface IDBIndexParameters {
@@ -203,19 +203,20 @@ interface IDBIndexParameters {
interface IDBObjectStoreParameters {
autoIncrement?: boolean;
keyPath?: IDBKeyPath;
keyPath?: IDBKeyPath | null;
}
interface IntersectionObserverEntryInit {
boundingClientRect?: DOMRectInit;
intersectionRect?: DOMRectInit;
rootBounds?: DOMRectInit;
target?: Element;
time?: number;
isIntersecting: boolean;
boundingClientRect: DOMRectInit;
intersectionRect: DOMRectInit;
rootBounds: DOMRectInit;
target: Element;
time: number;
}
interface IntersectionObserverInit {
root?: Element;
root?: Element | null;
rootMargin?: string;
threshold?: number | number[];
}
@@ -237,12 +238,12 @@ interface LongRange {
}
interface MediaEncryptedEventInit extends EventInit {
initData?: ArrayBuffer;
initData?: ArrayBuffer | null;
initDataType?: string;
}
interface MediaKeyMessageEventInit extends EventInit {
message?: ArrayBuffer;
message?: ArrayBuffer | null;
messageType?: MediaKeyMessageType;
}
@@ -265,7 +266,7 @@ interface MediaStreamConstraints {
}
interface MediaStreamErrorEventInit extends EventInit {
error?: MediaStreamError;
error?: MediaStreamError | null;
}
interface MediaStreamEventInit extends EventInit {
@@ -273,7 +274,7 @@ interface MediaStreamEventInit extends EventInit {
}
interface MediaStreamTrackEventInit extends EventInit {
track?: MediaStreamTrack;
track?: MediaStreamTrack | null;
}
interface MediaTrackCapabilities {
@@ -350,7 +351,7 @@ interface MouseEventInit extends EventModifierInit {
buttons?: number;
clientX?: number;
clientY?: number;
relatedTarget?: EventTarget;
relatedTarget?: EventTarget | null;
screenX?: number;
screenY?: number;
}
@@ -358,8 +359,8 @@ interface MouseEventInit extends EventModifierInit {
interface MSAccountInfo {
accountImageUri?: string;
accountName?: string;
rpDisplayName?: string;
userDisplayName?: string;
rpDisplayName: string;
userDisplayName: string;
userId?: string;
}
@@ -442,7 +443,7 @@ interface MSCredentialParameters {
interface MSCredentialSpec {
id?: string;
type?: MSCredentialType;
type: MSCredentialType;
}
interface MSDelay {
@@ -652,8 +653,8 @@ interface MsZoomToOptions {
contentX?: number;
contentY?: number;
scaleFactor?: number;
viewportX?: string;
viewportY?: string;
viewportX?: string | null;
viewportY?: string | null;
}
interface MutationObserverInit {
@@ -679,9 +680,9 @@ interface ObjectURLOptions {
}
interface PaymentCurrencyAmount {
currency?: string;
currency: string;
currencySystem?: string;
value?: string;
value: string;
}
interface PaymentDetails {
@@ -695,19 +696,19 @@ interface PaymentDetails {
interface PaymentDetailsModifier {
additionalDisplayItems?: PaymentItem[];
data?: any;
supportedMethods?: string[];
supportedMethods: string[];
total?: PaymentItem;
}
interface PaymentItem {
amount?: PaymentCurrencyAmount;
label?: string;
amount: PaymentCurrencyAmount;
label: string;
pending?: boolean;
}
interface PaymentMethodData {
data?: any;
supportedMethods?: string[];
supportedMethods: string[];
}
interface PaymentOptions {
@@ -722,9 +723,9 @@ interface PaymentRequestUpdateEventInit extends EventInit {
}
interface PaymentShippingOption {
amount?: PaymentCurrencyAmount;
id?: string;
label?: string;
amount: PaymentCurrencyAmount;
id: string;
label: string;
selected?: boolean;
}
@@ -772,7 +773,7 @@ interface RequestInit {
body?: any;
cache?: RequestCache;
credentials?: RequestCredentials;
headers?: any;
headers?: Headers | string[][];
integrity?: string;
keepalive?: boolean;
method?: string;
@@ -784,7 +785,7 @@ interface RequestInit {
}
interface ResponseInit {
headers?: any;
headers?: Headers | string[][];
status?: number;
statusText?: string;
}
@@ -869,15 +870,15 @@ interface RTCIceGatherOptions {
}
interface RTCIceParameters {
iceLite?: boolean;
iceLite?: boolean | null;
password?: string;
usernameFragment?: string;
}
interface RTCIceServer {
credential?: string;
credential?: string | null;
urls?: any;
username?: string;
username?: string | null;
}
interface RTCInboundRTPStreamStats extends RTCRTPStreamStats {
@@ -1087,9 +1088,9 @@ interface RTCTransportStats extends RTCStats {
}
interface ScopedCredentialDescriptor {
id?: any;
id: any;
transports?: Transport[];
type?: ScopedCredentialType;
type: ScopedCredentialType;
}
interface ScopedCredentialOptions {
@@ -1100,29 +1101,29 @@ interface ScopedCredentialOptions {
}
interface ScopedCredentialParameters {
algorithm?: string | Algorithm;
type?: ScopedCredentialType;
algorithm: string | Algorithm;
type: ScopedCredentialType;
}
interface ServiceWorkerMessageEventInit extends EventInit {
data?: any;
lastEventId?: string;
origin?: string;
ports?: MessagePort[];
source?: ServiceWorker | MessagePort;
ports?: MessagePort[] | null;
source?: ServiceWorker | MessagePort | null;
}
interface SpeechSynthesisEventInit extends EventInit {
charIndex?: number;
elapsedTime?: number;
name?: string;
utterance?: SpeechSynthesisUtterance;
utterance?: SpeechSynthesisUtterance | null;
}
interface StoreExceptionsInformation extends ExceptionInformation {
detailURI?: string;
explanationString?: string;
siteName?: string;
detailURI?: string | null;
explanationString?: string | null;
siteName?: string | null;
}
interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation {
@@ -1130,7 +1131,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat
}
interface TrackEventInit extends EventInit {
track?: VideoTrack | AudioTrack | TextTrack;
track?: VideoTrack | AudioTrack | TextTrack | null;
}
interface TransitionEventInit extends EventInit {
@@ -1140,7 +1141,7 @@ interface TransitionEventInit extends EventInit {
interface UIEventInit extends EventInit {
detail?: number;
view?: Window;
view?: Window | null;
}
interface WebAuthnExtensions {
@@ -1520,9 +1521,9 @@ interface Cache {
add(request: RequestInfo): Promise<void>;
addAll(requests: RequestInfo[]): Promise<void>;
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
keys(request?: RequestInfo, options?: CacheQueryOptions): any;
keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<Request[]>;
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
matchAll(request?: RequestInfo, options?: CacheQueryOptions): any;
matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<Response[]>;
put(request: RequestInfo, response: Response): Promise<void>;
}
@@ -1534,7 +1535,7 @@ declare var Cache: {
interface CacheStorage {
delete(cacheName: string): Promise<boolean>;
has(cacheName: string): Promise<boolean>;
keys(): any;
keys(): Promise<string[]>;
match(request: RequestInfo, options?: CacheQueryOptions): Promise<any>;
open(cacheName: string): Promise<Cache>;
}
@@ -2639,7 +2640,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
*/
readonly compatMode: string;
cookie: string;
readonly currentScript: HTMLScriptElement | SVGScriptElement;
readonly currentScript: HTMLScriptElement | SVGScriptElement | null;
readonly defaultView: Window;
/**
* Sets or gets a value that indicates whether the document can be edited.
@@ -3378,7 +3379,7 @@ interface DOMException {
declare var DOMException: {
prototype: DOMException;
new(): DOMException;
new(message?: string, name?: string): DOMException;
readonly ABORT_ERR: number;
readonly DATA_CLONE_ERR: number;
readonly DOMSTRING_SIZE_ERR: number;
@@ -3884,7 +3885,7 @@ interface Headers {
declare var Headers: {
prototype: Headers;
new(init?: any): Headers;
new(init?: Headers | string[][]): Headers;
};
interface History {
@@ -4044,7 +4045,7 @@ interface HTMLAppletElement extends HTMLElement {
* Sets or retrieves a character string that can be used to implement your own declare functionality for the object.
*/
declare: boolean;
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the height of the object.
*/
@@ -4282,7 +4283,7 @@ interface HTMLButtonElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Overrides the action attribute (where the data on a form is sent) on the parent form element.
*/
@@ -4715,7 +4716,7 @@ interface HTMLFieldSetElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
name: string;
/**
* Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting.
@@ -5294,7 +5295,7 @@ interface HTMLInputElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Overrides the action attribute (where the data on a form is sent) on the parent form element.
*/
@@ -5461,7 +5462,7 @@ interface HTMLLabelElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the object to which the given label object is assigned.
*/
@@ -5483,7 +5484,7 @@ interface HTMLLegendElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
@@ -5917,7 +5918,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the height of the object.
*/
@@ -6016,7 +6017,7 @@ interface HTMLOptGroupElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the ordinal position of an option in a list box.
*/
@@ -6055,7 +6056,7 @@ interface HTMLOptionElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the ordinal position of an option in a list box.
*/
@@ -6099,7 +6100,7 @@ declare var HTMLOptionsCollection: {
interface HTMLOutputElement extends HTMLElement {
defaultValue: string;
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
readonly htmlFor: DOMSettableTokenList;
name: string;
readonly type: string;
@@ -6188,7 +6189,7 @@ interface HTMLProgressElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Defines the maximum, or "done" value for a progress element.
*/
@@ -6274,7 +6275,7 @@ interface HTMLSelectElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the number of objects in a collection.
*/
@@ -6745,7 +6746,7 @@ interface HTMLTextAreaElement extends HTMLElement {
/**
* Retrieves a reference to the form that the object is embedded in.
*/
readonly form: HTMLFormElement;
readonly form: HTMLFormElement | null;
/**
* Sets or retrieves the maximum number of characters that the user can enter in a text control.
*/
@@ -7211,6 +7212,7 @@ interface IntersectionObserverEntry {
readonly rootBounds: ClientRect;
readonly target: Element;
readonly time: number;
readonly isIntersecting: boolean;
}
declare var IntersectionObserverEntry: {
@@ -7312,7 +7314,7 @@ interface MediaDevicesEventMap {
interface MediaDevices extends EventTarget {
ondevicechange: (this: MediaDevices, ev: Event) => any;
enumerateDevices(): any;
enumerateDevices(): Promise<MediaDeviceInfo[]>;
getSupportedConstraints(): MediaTrackSupportedConstraints;
getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
addEventListener<K extends keyof MediaDevicesEventMap>(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void;
@@ -9058,6 +9060,7 @@ interface Response extends Object, Body {
readonly statusText: string;
readonly type: ResponseType;
readonly url: string;
readonly redirected: boolean;
clone(): Response;
}
@@ -9512,7 +9515,7 @@ interface ServiceWorkerContainer extends EventTarget {
onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any;
readonly ready: Promise<ServiceWorkerRegistration>;
getRegistration(clientURL?: USVString): Promise<any>;
getRegistrations(): any;
getRegistrations(): Promise<ServiceWorkerRegistration[]>;
register(scriptURL: USVString, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
addEventListener<K extends keyof ServiceWorkerContainerEventMap>(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
@@ -9548,7 +9551,7 @@ interface ServiceWorkerRegistration extends EventTarget {
readonly scope: USVString;
readonly sync: SyncManager;
readonly waiting: ServiceWorker | null;
getNotifications(filter?: GetNotificationOptions): any;
getNotifications(filter?: GetNotificationOptions): Promise<Notification[]>;
showNotification(title: string, options?: NotificationOptions): Promise<void>;
unregister(): Promise<boolean>;
update(): Promise<void>;
@@ -11573,7 +11576,7 @@ declare var SVGZoomEvent: {
};
interface SyncManager {
getTags(): any;
getTags(): Promise<string[]>;
register(tag: string): Promise<void>;
}
@@ -11881,6 +11884,7 @@ interface ValidityState {
readonly typeMismatch: boolean;
readonly valid: boolean;
readonly valueMissing: boolean;
readonly tooShort: boolean;
}
declare var ValidityState: {
@@ -13742,13 +13746,13 @@ interface NavigatorUserMedia {
interface NodeSelector {
querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null;
querySelector(selectors: string): Element | null;
querySelector<E extends Element = Element>(selectors: string): E | null;
querySelectorAll<K extends keyof ElementListTagNameMap>(selectors: K): ElementListTagNameMap[K];
querySelectorAll(selectors: string): NodeListOf<Element>;
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
}
interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
getRandomValues<T extends Int8Array | Uint8ClampedArray | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array>(array: T): T;
}
interface SVGAnimatedPoints {
@@ -13823,17 +13827,37 @@ interface XMLHttpRequestEventTargetEventMap {
}
interface XMLHttpRequestEventTarget {
onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any;
onload: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
onabort: (this: XMLHttpRequest, ev: Event) => any;
onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any;
onload: (this: XMLHttpRequest, ev: Event) => any;
onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any;
onloadstart: (this: XMLHttpRequest, ev: Event) => any;
onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any;
ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any;
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface BroadcastChannel extends EventTarget {
readonly name: string;
onmessage: (ev: MessageEvent) => any;
onmessageerror: (ev: MessageEvent) => any;
close(): void;
postMessage(message: any): void;
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var BroadcastChannel: {
prototype: BroadcastChannel;
new(name: string): BroadcastChannel;
};
interface BroadcastChannelEventMap {
message: MessageEvent;
messageerror: MessageEvent;
}
interface ErrorEventInit {
message?: string;
filename?: string;
@@ -13924,8 +13948,7 @@ interface BlobPropertyBag {
endings?: string;
}
interface FilePropertyBag {
type?: string;
interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number;
}
@@ -14201,6 +14224,44 @@ interface TouchEventInit extends EventModifierInit {
changedTouches?: Touch[];
}
interface HTMLDialogElement extends HTMLElement {
open: boolean;
returnValue: string;
close(returnValue?: string): void;
show(): void;
showModal(): void;
}
declare var HTMLDialogElement: {
prototype: HTMLDialogElement;
new(): HTMLDialogElement;
};
interface HTMLMainElement extends HTMLElement {
}
declare var HTMLMainElement: {
prototype: HTMLMainElement;
new(): HTMLMainElement;
};
interface HTMLDetailsElement extends HTMLElement {
open: boolean;
}
declare var HTMLDetailsElement: {
prototype: HTMLDetailsElement;
new(): HTMLDetailsElement;
};
interface HTMLSummaryElement extends HTMLElement {
}
declare var HTMLSummaryElement: {
prototype: HTMLSummaryElement;
new(): HTMLSummaryElement;
};
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface DecodeErrorCallback {
@@ -14690,7 +14751,7 @@ type GLsizeiptr = number;
type GLubyte = number;
type GLuint = number;
type GLushort = number;
type HeadersInit = any;
type HeadersInit = Headers | string[][];
type IDBKeyPath = string;
type KeyFormat = string;
type KeyType = string;
+46 -26
View File
@@ -37,7 +37,7 @@ interface IDBIndexParameters {
interface IDBObjectStoreParameters {
autoIncrement?: boolean;
keyPath?: IDBKeyPath;
keyPath?: IDBKeyPath | null;
}
interface KeyAlgorithm {
@@ -74,7 +74,7 @@ interface RequestInit {
body?: any;
cache?: RequestCache;
credentials?: RequestCredentials;
headers?: any;
headers?: Headers | string[][];
integrity?: string;
keepalive?: boolean;
method?: string;
@@ -86,7 +86,7 @@ interface RequestInit {
}
interface ResponseInit {
headers?: any;
headers?: Headers | string[][];
status?: number;
statusText?: string;
}
@@ -103,18 +103,18 @@ interface ExtendableMessageEventInit extends ExtendableEventInit {
data?: any;
origin?: string;
lastEventId?: string;
source?: Client | ServiceWorker | MessagePort;
ports?: MessagePort[];
source?: Client | ServiceWorker | MessagePort | null;
ports?: MessagePort[] | null;
}
interface FetchEventInit extends ExtendableEventInit {
request?: Request;
clientId?: string;
request: Request;
clientId?: string | null;
isReload?: boolean;
}
interface NotificationEventInit extends ExtendableEventInit {
notification?: Notification;
notification: Notification;
action?: string;
}
@@ -123,7 +123,7 @@ interface PushEventInit extends ExtendableEventInit {
}
interface SyncEventInit extends ExtendableEventInit {
tag?: string;
tag: string;
lastChance?: boolean;
}
@@ -175,9 +175,9 @@ interface Cache {
add(request: RequestInfo): Promise<void>;
addAll(requests: RequestInfo[]): Promise<void>;
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
keys(request?: RequestInfo, options?: CacheQueryOptions): any;
keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<Request[]>;
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
matchAll(request?: RequestInfo, options?: CacheQueryOptions): any;
matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<Response[]>;
put(request: RequestInfo, response: Response): Promise<void>;
}
@@ -189,7 +189,7 @@ declare var Cache: {
interface CacheStorage {
delete(cacheName: string): Promise<boolean>;
has(cacheName: string): Promise<boolean>;
keys(): any;
keys(): Promise<string[]>;
match(request: RequestInfo, options?: CacheQueryOptions): Promise<any>;
open(cacheName: string): Promise<Cache>;
}
@@ -314,7 +314,7 @@ interface DOMException {
declare var DOMException: {
prototype: DOMException;
new(): DOMException;
new(message?: string, name?: string): DOMException;
readonly ABORT_ERR: number;
readonly DATA_CLONE_ERR: number;
readonly DOMSTRING_SIZE_ERR: number;
@@ -470,7 +470,7 @@ interface Headers {
declare var Headers: {
prototype: Headers;
new(init?: any): Headers;
new(init?: Headers | string[][]): Headers;
};
interface IDBCursor {
@@ -960,6 +960,7 @@ interface Response extends Object, Body {
readonly statusText: string;
readonly type: ResponseType;
readonly url: string;
readonly redirected: boolean;
clone(): Response;
}
@@ -1000,7 +1001,7 @@ interface ServiceWorkerRegistration extends EventTarget {
readonly scope: USVString;
readonly sync: SyncManager;
readonly waiting: ServiceWorker | null;
getNotifications(filter?: GetNotificationOptions): any;
getNotifications(filter?: GetNotificationOptions): Promise<Notification[]>;
showNotification(title: string, options?: NotificationOptions): Promise<void>;
unregister(): Promise<boolean>;
update(): Promise<void>;
@@ -1014,7 +1015,7 @@ declare var ServiceWorkerRegistration: {
};
interface SyncManager {
getTags(): any;
getTags(): Promise<string[]>;
register(tag: string): Promise<void>;
}
@@ -1248,13 +1249,13 @@ interface XMLHttpRequestEventTargetEventMap {
}
interface XMLHttpRequestEventTarget {
onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any;
onload: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any;
onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
onabort: (this: XMLHttpRequest, ev: Event) => any;
onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any;
onload: (this: XMLHttpRequest, ev: Event) => any;
onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any;
onloadstart: (this: XMLHttpRequest, ev: Event) => any;
onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any;
ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any;
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
@@ -1274,7 +1275,7 @@ declare var Client: {
interface Clients {
claim(): Promise<void>;
get(id: string): Promise<any>;
matchAll(options?: ClientQueryOptions): any;
matchAll(options?: ClientQueryOptions): Promise<Client[]>;
openWindow(url: USVString): Promise<WindowClient>;
}
@@ -1499,6 +1500,26 @@ interface WorkerUtils extends Object, WindowBase64 {
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
interface BroadcastChannel extends EventTarget {
readonly name: string;
onmessage: (ev: MessageEvent) => any;
onmessageerror: (ev: MessageEvent) => any;
close(): void;
postMessage(message: any): void;
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var BroadcastChannel: {
prototype: BroadcastChannel;
new(name: string): BroadcastChannel;
};
interface BroadcastChannelEventMap {
message: MessageEvent;
messageerror: MessageEvent;
}
interface ErrorEventInit {
message?: string;
filename?: string;
@@ -1562,8 +1583,7 @@ interface BlobPropertyBag {
endings?: string;
}
interface FilePropertyBag {
type?: string;
interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number;
}
+51 -15
View File
@@ -109,6 +109,11 @@ namespace ts.server {
"smart": IndentStyle.Smart
});
export interface TypesMapFile {
typesMap: SafeList;
simpleMap: string[];
}
/**
* How to understand this block:
* * The 'match' property is a regexp that matches a filename.
@@ -330,6 +335,7 @@ namespace ts.server {
globalPlugins?: ReadonlyArray<string>;
pluginProbeLocations?: ReadonlyArray<string>;
allowLocalPluginLoads?: boolean;
typesMapLocation?: string;
}
export class ProjectService {
@@ -391,6 +397,7 @@ namespace ts.server {
public readonly globalPlugins: ReadonlyArray<string>;
public readonly pluginProbeLocations: ReadonlyArray<string>;
public readonly allowLocalPluginLoads: boolean;
public readonly typesMapLocation: string | undefined;
/** Tracks projects that we have already sent telemetry for. */
private readonly seenProjects = createMap<true>();
@@ -407,6 +414,7 @@ namespace ts.server {
this.globalPlugins = opts.globalPlugins || emptyArray;
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads;
this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation;
Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService");
@@ -414,6 +422,10 @@ namespace ts.server {
this.directoryWatchers = new DirectoryWatchers(this);
this.throttledOperations = new ThrottledOperations(this.host);
if (opts.typesMapLocation) {
this.loadTypesMap();
}
this.typingsInstaller.attach(this);
this.typingsCache = new TypingsCache(this.typingsInstaller);
@@ -451,6 +463,27 @@ namespace ts.server {
this.eventHandler(event);
}
private loadTypesMap() {
try {
const fileContent = this.host.readFile(this.typesMapLocation);
if (fileContent === undefined) {
this.logger.info(`Provided types map file "${this.typesMapLocation}" doesn't exist`);
return;
}
const raw: TypesMapFile = JSON.parse(fileContent);
// Parse the regexps
for (const k of Object.keys(raw.typesMap)) {
raw.typesMap[k].match = new RegExp(raw.typesMap[k].match as {} as string, "i");
}
// raw is now fixed and ready
this.safelist = raw.typesMap;
}
catch (e) {
this.logger.info(`Error loading types map: ${e}`);
this.safelist = defaultTypeSafeList;
}
}
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void {
const project = this.findProject(response.projectName);
if (!project) {
@@ -1712,23 +1745,14 @@ namespace ts.server {
this.safelist = defaultTypeSafeList;
}
loadSafeList(fileName: string): void {
const raw: SafeList = JSON.parse(this.host.readFile(fileName, "utf-8"));
// Parse the regexps
for (const k of Object.keys(raw)) {
raw[k].match = new RegExp(raw[k].match as {} as string, "i");
}
// raw is now fixed and ready
this.safelist = raw;
}
applySafeList(proj: protocol.ExternalProject): void {
applySafeList(proj: protocol.ExternalProject): NormalizedPath[] {
const { rootFiles, typeAcquisition } = proj;
const types = (typeAcquisition && typeAcquisition.include) || [];
const excludeRules: string[] = [];
const normalizedNames = rootFiles.map(f => normalizeSlashes(f.fileName));
const normalizedNames = rootFiles.map(f => normalizeSlashes(f.fileName)) as NormalizedPath[];
const excludedFiles: NormalizedPath[] = [];
for (const name of Object.keys(this.safelist)) {
const rule = this.safelist[name];
@@ -1787,7 +1811,17 @@ namespace ts.server {
}
const excludeRegexes = excludeRules.map(e => new RegExp(e, "i"));
proj.rootFiles = proj.rootFiles.filter((_file, index) => !excludeRegexes.some(re => re.test(normalizedNames[index])));
const filesToKeep: ts.server.protocol.ExternalFile[] = [];
for (let i = 0; i < proj.rootFiles.length; i++) {
if (excludeRegexes.some(re => re.test(normalizedNames[i]))) {
excludedFiles.push(normalizedNames[i]);
}
else {
filesToKeep.push(proj.rootFiles[i]);
}
}
proj.rootFiles = filesToKeep;
return excludedFiles;
}
openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects = false): void {
@@ -1798,7 +1832,7 @@ namespace ts.server {
proj.typeAcquisition = typeAcquisition;
}
this.applySafeList(proj);
const excludedFiles = this.applySafeList(proj);
let tsConfigFiles: NormalizedPath[];
const rootFiles: protocol.ExternalFile[] = [];
@@ -1822,6 +1856,7 @@ namespace ts.server {
const externalProject = this.findExternalProjectByProjectName(proj.projectFileName);
let exisingConfigFiles: string[];
if (externalProject) {
externalProject.excludedFiles = excludedFiles;
if (!tsConfigFiles) {
const compilerOptions = convertCompilerOptions(proj.options);
if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) {
@@ -1891,7 +1926,8 @@ namespace ts.server {
else {
// no config files - remove the item from the collection
this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition);
const newProj = this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition);
newProj.excludedFiles = excludedFiles;
}
if (!suppressRefreshOfInferredProjects) {
this.refreshInferredProjects();
+10
View File
@@ -376,6 +376,10 @@ namespace ts.server {
return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles);
}
getExcludedFiles(): ReadonlyArray<NormalizedPath> {
return emptyArray;
}
getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean) {
if (!this.program) {
return [];
@@ -1166,6 +1170,7 @@ namespace ts.server {
* These are created only if a host explicitly calls `openExternalProject`.
*/
export class ExternalProject extends Project {
excludedFiles: ReadonlyArray<NormalizedPath> = [];
private typeAcquisition: TypeAcquisition;
constructor(public externalProjectName: string,
projectService: ProjectService,
@@ -1175,6 +1180,11 @@ namespace ts.server {
public compileOnSaveEnabled: boolean,
private readonly projectFilePath?: string) {
super(externalProjectName, ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
}
getExcludedFiles() {
return this.excludedFiles;
}
getProjectRootPath() {
+9 -2
View File
@@ -14,6 +14,7 @@ namespace ts.server {
globalTypingsCacheLocation: string;
logger: Logger;
typingSafeListLocation: string;
typesMapLocation: string | undefined;
npmLocation: string | undefined;
telemetryEnabled: boolean;
globalPlugins: ReadonlyArray<string>;
@@ -250,6 +251,7 @@ namespace ts.server {
eventPort: number,
readonly globalTypingsCacheLocation: string,
readonly typingSafeListLocation: string,
readonly typesMapLocation: string,
private readonly npmLocation: string | undefined,
private newLine: string) {
this.throttledOperations = new ThrottledOperations(host);
@@ -295,6 +297,9 @@ namespace ts.server {
if (this.typingSafeListLocation) {
args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation);
}
if (this.typesMapLocation) {
args.push(Arguments.TypesMapLocation, this.typesMapLocation);
}
if (this.npmLocation) {
args.push(Arguments.NpmLocation, this.npmLocation);
}
@@ -408,10 +413,10 @@ namespace ts.server {
class IOSession extends Session {
constructor(options: IOSessionOptions) {
const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, canUseEvents } = options;
const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options;
const typingsInstaller = disableAutomaticTypingAcquisition
? undefined
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation, host.newLine);
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, host.newLine);
super({
host,
@@ -768,6 +773,7 @@ namespace ts.server {
setStackTraceLimit();
const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation);
const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), "../typesMap.json");
const npmLocation = findArgument(Arguments.NpmLocation);
function parseStringArray(argName: string): ReadonlyArray<string> {
@@ -797,6 +803,7 @@ namespace ts.server {
disableAutomaticTypingAcquisition,
globalTypingsCacheLocation: getGlobalTypingsCacheLocation(),
typingSafeListLocation,
typesMapLocation,
npmLocation,
telemetryEnabled,
logger,
+1
View File
@@ -12,6 +12,7 @@ namespace ts.server {
export const LogFile = "--logFile";
export const EnableTelemetry = "--enableTelemetry";
export const TypingSafeListLocation = "--typingSafeListLocation";
export const TypesMapLocation = "--typesMapLocation";
/**
* This argument specifies the location of the NPM executable.
* typingsInstaller will run the command with `${npmLocation} install ...`.
+487
View File
@@ -0,0 +1,487 @@
{
"typesMap": {
"jquery": {
"match": "jquery(-(\\.?\\d+)+)?(\\.intellisense)?(\\.min)?\\.js$",
"types": ["jquery"]
},
"WinJS": {
"match": "^(.*\\/winjs-[.\\d]+)\\/js\\/base\\.js$",
"exclude": [["^", 1, "/.*"]],
"types": ["winjs"]
},
"Kendo": {
"match": "^(.*\\/kendo)\\/kendo\\.all\\.min\\.js$",
"exclude": [["^", 1, "/.*"]],
"types": ["kendo-ui"]
},
"Office Nuget": {
"match": "^(.*\\/office\\/1)\\/excel-\\d+\\.debug\\.js$",
"exclude": [["^", 1, "/.*"]],
"types": ["office"]
},
"Minified files": {
"match": "^(.+\\.min\\.js)$",
"exclude": [["^", 1, "$"]]
}
},
"simpleMap": {
"accounting": "accounting",
"ace.js": "ace",
"ag-grid": "ag-grid",
"alertify": "alertify",
"alt": "alt",
"amcharts.js": "amcharts",
"amplify": "amplifyjs",
"angular": "angular",
"angular-bootstrap-lightbox": "angular-bootstrap-lightbox",
"angular-cookie": "angular-cookie",
"angular-file-upload": "angular-file-upload",
"angularfire": "angularfire",
"angular-gettext": "angular-gettext",
"angular-google-analytics": "angular-google-analytics",
"angular-local-storage": "angular-local-storage",
"angularLocalStorage": "angularLocalStorage",
"angular-scroll": "angular-scroll",
"angular-spinner": "angular-spinner",
"angular-strap": "angular-strap",
"angulartics": "angulartics",
"angular-toastr": "angular-toastr",
"angular-translate": "angular-translate",
"angular-ui-router": "angular-ui-router",
"angular-ui-tree": "angular-ui-tree",
"angular-wizard": "angular-wizard",
"async": "async",
"atmosphere": "atmosphere",
"aws-sdk": "aws-sdk",
"aws-sdk-js": "aws-sdk",
"axios": "axios",
"backbone": "backbone",
"backbone.layoutmanager": "backbone.layoutmanager",
"backbone.paginator": "backbone.paginator",
"backbone.radio": "backbone.radio",
"backbone-associations": "backbone-associations",
"backbone-relational": "backbone-relational",
"backgrid": "backgrid",
"Bacon": "baconjs",
"benchmark": "benchmark",
"blazy": "blazy",
"bliss": "blissfuljs",
"bluebird": "bluebird",
"body-parser": "body-parser",
"bootbox": "bootbox",
"bootstrap": "bootstrap",
"bootstrap-editable": "x-editable",
"bootstrap-maxlength": "bootstrap-maxlength",
"bootstrap-notify": "bootstrap-notify",
"bootstrap-slider": "bootstrap-slider",
"bootstrap-switch": "bootstrap-switch",
"bowser": "bowser",
"breeze": "breeze",
"browserify": "browserify",
"bson": "bson",
"c3": "c3",
"canvasjs": "canvasjs",
"chai": "chai",
"chalk": "chalk",
"chance": "chance",
"chartist": "chartist",
"cheerio": "cheerio",
"chokidar": "chokidar",
"chosen.jquery": "chosen",
"chroma": "chroma-js",
"ckeditor.js": "ckeditor",
"cli-color": "cli-color",
"clipboard": "clipboard",
"codemirror": "codemirror",
"colors": "colors",
"commander": "commander",
"commonmark": "commonmark",
"compression": "compression",
"confidence": "confidence",
"connect": "connect",
"Control.FullScreen": "leaflet.fullscreen",
"cookie": "cookie",
"cookie-parser": "cookie-parser",
"cookies": "cookies",
"core": "core-js",
"core-js": "core-js",
"crossfilter": "crossfilter",
"crossroads": "crossroads",
"css": "css",
"ct-ui-router-extras": "ui-router-extras",
"d3": "d3",
"dagre-d3": "dagre-d3",
"dat.gui": "dat-gui",
"debug": "debug",
"deep-diff": "deep-diff",
"Dexie": "dexie",
"dialogs": "angular-dialog-service",
"dojo.js": "dojo",
"doT": "dot",
"dragula": "dragula",
"drop": "drop",
"dropbox": "dropboxjs",
"dropzone": "dropzone",
"Dts Name": "Dts Name",
"dust-core": "dustjs-linkedin",
"easeljs": "easeljs",
"ejs": "ejs",
"ember": "ember",
"envify": "envify",
"epiceditor": "epiceditor",
"es6-promise": "es6-promise",
"ES6-Promise": "es6-promise",
"es6-shim": "es6-shim",
"expect": "expect",
"express": "express",
"express-session": "express-session",
"ext-all.js": "extjs",
"extend": "extend",
"fabric": "fabricjs",
"faker": "faker",
"fastclick": "fastclick",
"favico": "favico.js",
"featherlight": "featherlight",
"FileSaver": "FileSaver",
"fingerprint": "fingerprintjs",
"fixed-data-table": "fixed-data-table",
"flickity.pkgd": "flickity",
"flight": "flight",
"flow": "flowjs",
"Flux": "flux",
"formly": "angular-formly",
"foundation": "foundation",
"fpsmeter": "fpsmeter",
"fuse": "fuse",
"generator": "yeoman-generator",
"gl-matrix": "gl-matrix",
"globalize": "globalize",
"graceful-fs": "graceful-fs",
"gridstack": "gridstack",
"gulp": "gulp",
"gulp-rename": "gulp-rename",
"gulp-uglify": "gulp-uglify",
"gulp-util": "gulp-util",
"hammer": "hammerjs",
"handlebars": "handlebars",
"hasher": "hasher",
"he": "he",
"hello.all": "hellojs",
"highcharts.js": "highcharts",
"highlight": "highlightjs",
"history": "history",
"History": "history",
"hopscotch": "hopscotch",
"hotkeys": "angular-hotkeys",
"html2canvas": "html2canvas",
"humane": "humane",
"i18next": "i18next",
"icheck": "icheck",
"impress": "impress",
"incremental-dom": "incremental-dom",
"Inquirer": "inquirer",
"insight": "insight",
"interact": "interactjs",
"intercom": "intercomjs",
"intro": "intro.js",
"ion.rangeSlider": "ion.rangeSlider",
"ionic": "ionic",
"is": "is_js",
"iscroll": "iscroll",
"jade": "jade",
"jasmine": "jasmine",
"joint": "jointjs",
"jquery": "jquery",
"jquery.address": "jquery.address",
"jquery.are-you-sure": "jquery.are-you-sure",
"jquery.blockUI": "jquery.blockUI",
"jquery.bootstrap.wizard": "jquery.bootstrap.wizard",
"jquery.bootstrap-touchspin": "bootstrap-touchspin",
"jquery.color": "jquery.color",
"jquery.colorbox": "jquery.colorbox",
"jquery.contextMenu": "jquery.contextMenu",
"jquery.cookie": "jquery.cookie",
"jquery.customSelect": "jquery.customSelect",
"jquery.cycle.all": "jquery.cycle",
"jquery.cycle2": "jquery.cycle2",
"jquery.dataTables": "jquery.dataTables",
"jquery.dropotron": "jquery.dropotron",
"jquery.fancybox.pack.js": "fancybox",
"jquery.fancytree-all": "jquery.fancytree",
"jquery.fileupload": "jquery.fileupload",
"jquery.flot": "flot",
"jquery.form": "jquery.form",
"jquery.gridster": "jquery.gridster",
"jquery.handsontable.full": "jquery-handsontable",
"jquery.joyride": "jquery.joyride",
"jquery.jqGrid": "jqgrid",
"jquery.mmenu": "jquery.mmenu",
"jquery.mockjax": "jquery-mockjax",
"jquery.noty": "jquery.noty",
"jquery.payment": "jquery.payment",
"jquery.pjax": "jquery.pjax",
"jquery.placeholder": "jquery.placeholder",
"jquery.qrcode": "jquery.qrcode",
"jquery.qtip": "qtip2",
"jquery.raty": "raty",
"jquery.scrollTo": "jquery.scrollTo",
"jquery.signalR": "signalr",
"jquery.simplemodal": "jquery.simplemodal",
"jquery.timeago": "jquery.timeago",
"jquery.tinyscrollbar": "jquery.tinyscrollbar",
"jquery.tipsy": "jquery.tipsy",
"jquery.tooltipster": "tooltipster",
"jquery.transit": "jquery.transit",
"jquery.uniform": "jquery.uniform",
"jquery.watch": "watch",
"jquery-sortable": "jquery-sortable",
"jquery-ui": "jqueryui",
"js.cookie": "js-cookie",
"js-data": "js-data",
"js-data-angular": "js-data-angular",
"js-data-http": "js-data-http",
"jsdom": "jsdom",
"jsnlog": "jsnlog",
"json5": "json5",
"jspdf": "jspdf",
"jsrender": "jsrender",
"js-signals": "js-signals",
"jstorage": "jstorage",
"jstree": "jstree",
"js-yaml": "js-yaml",
"jszip": "jszip",
"katex": "katex",
"kefir": "kefir",
"keymaster": "keymaster",
"keypress": "keypress",
"kinetic": "kineticjs",
"knockback": "knockback",
"knockout": "knockout",
"knockout.mapping": "knockout.mapping",
"knockout.validation": "knockout.validation",
"knockout-paging": "knockout-paging",
"knockout-pre-rendered": "knockout-pre-rendered",
"ladda": "ladda",
"later": "later",
"lazy": "lazy.js",
"Leaflet.Editable": "leaflet-editable",
"leaflet.js": "leaflet",
"less": "less",
"linq": "linq",
"loading-bar": "angular-loading-bar",
"lodash": "lodash",
"log4javascript": "log4javascript",
"loglevel": "loglevel",
"lokijs": "lokijs",
"lovefield": "lovefield",
"lunr": "lunr",
"lz-string": "lz-string",
"mailcheck": "mailcheck",
"maquette": "maquette",
"marked": "marked",
"math": "mathjs",
"MathJax.js": "mathjax",
"matter": "matter-js",
"md5": "blueimp-md5",
"md5.js": "crypto-js",
"messenger": "messenger",
"method-override": "method-override",
"minimatch": "minimatch",
"minimist": "minimist",
"mithril": "mithril",
"mobile-detect": "mobile-detect",
"mocha": "mocha",
"mock-ajax": "jasmine-ajax",
"modernizr": "modernizr",
"Modernizr": "Modernizr",
"moment": "moment",
"moment-range": "moment-range",
"moment-timezone": "moment-timezone",
"mongoose": "mongoose",
"morgan": "morgan",
"mousetrap": "mousetrap",
"ms": "ms",
"mustache": "mustache",
"native.history": "history",
"nconf": "nconf",
"ncp": "ncp",
"nedb": "nedb",
"ng-cordova": "ng-cordova",
"ngDialog": "ng-dialog",
"ng-flow-standalone": "ng-flow",
"ng-grid": "ng-grid",
"ng-i18next": "ng-i18next",
"ng-table": "ng-table",
"node_redis": "redis",
"node-clone": "clone",
"node-fs-extra": "fs-extra",
"node-glob": "glob",
"Nodemailer": "nodemailer",
"node-mime": "mime",
"node-mkdirp": "mkdirp",
"node-mongodb-native": "mongodb",
"node-mysql": "mysql",
"node-open": "open",
"node-optimist": "optimist",
"node-progress": "progress",
"node-semver": "semver",
"node-tar": "tar",
"node-uuid": "node-uuid",
"node-xml2js": "xml2js",
"nopt": "nopt",
"notify": "notify",
"nouislider": "nouislider",
"npm": "npm",
"nprogress": "nprogress",
"numbro": "numbro",
"numeral": "numeraljs",
"nunjucks": "nunjucks",
"nv.d3": "nvd3",
"object-assign": "object-assign",
"oboe-browser": "oboe",
"office": "office-js",
"offline": "offline-js",
"onsenui": "onsenui",
"OpenLayers.js": "openlayers",
"openpgp": "openpgp",
"p2": "p2",
"packery.pkgd": "packery",
"page": "page",
"pako": "pako",
"papaparse": "papaparse",
"passport": "passport",
"passport-local": "passport-local",
"path": "pathjs",
"peer": "peerjs",
"peg": "pegjs",
"photoswipe": "photoswipe",
"picker.js": "pickadate",
"pikaday": "pikaday",
"pixi": "pixi.js",
"platform": "platform",
"Please": "pleasejs",
"plottable": "plottable",
"polymer": "polymer",
"postal": "postal",
"preloadjs": "preloadjs",
"progress": "progress",
"purify": "dompurify",
"purl": "purl",
"q": "q",
"qs": "qs",
"qunit": "qunit",
"ractive": "ractive",
"rangy-core": "rangy",
"raphael": "raphael",
"raven": "ravenjs",
"react": "react",
"react-bootstrap": "react-bootstrap",
"react-intl": "react-intl",
"react-redux": "react-redux",
"ReactRouter": "react-router",
"ready": "domready",
"redux": "redux",
"request": "request",
"require": "require",
"restangular": "restangular",
"reveal": "reveal",
"rickshaw": "rickshaw",
"rimraf": "rimraf",
"rivets": "rivets",
"rx": "rx",
"rx.angular": "rx-angular",
"sammy": "sammyjs",
"SAT": "sat",
"sax-js": "sax",
"screenfull": "screenfull",
"seedrandom": "seedrandom",
"select2": "select2",
"selectize": "selectize",
"serve-favicon": "serve-favicon",
"serve-static": "serve-static",
"shelljs": "shelljs",
"should": "should",
"showdown": "showdown",
"sigma": "sigmajs",
"signature_pad": "signature_pad",
"sinon": "sinon",
"sjcl": "sjcl",
"slick": "slick-carousel",
"smoothie": "smoothie",
"socket.io": "socket.io",
"socket.io-client": "socket.io-client",
"sockjs": "sockjs-client",
"sortable": "angular-ui-sortable",
"soundjs": "soundjs",
"source-map": "source-map",
"spectrum": "spectrum",
"spin": "spin",
"sprintf": "sprintf",
"stampit": "stampit",
"state-machine": "state-machine",
"Stats": "stats",
"store": "storejs",
"string": "string",
"string_score": "string_score",
"strophe": "strophe",
"stylus": "stylus",
"sugar": "sugar",
"superagent": "superagent",
"svg": "svgjs",
"svg-injector": "svg-injector",
"swfobject": "swfobject",
"swig": "swig",
"swipe": "swipe",
"swiper": "swiper",
"system.js": "systemjs",
"tether": "tether",
"three": "threejs",
"through": "through",
"through2": "through2",
"timeline": "timelinejs",
"tinycolor": "tinycolor",
"tmhDynamicLocale": "angular-dynamic-locale",
"toaster": "angularjs-toaster",
"toastr": "toastr",
"tracking": "tracking",
"trunk8": "trunk8",
"turf": "turf",
"tweenjs": "tweenjs",
"TweenMax": "gsap",
"twig": "twig",
"twix": "twix",
"typeahead.bundle": "typeahead",
"typescript": "typescript",
"ui": "winjs",
"ui-bootstrap-tpls": "angular-ui-bootstrap",
"ui-grid": "ui-grid",
"uikit": "uikit",
"underscore": "underscore",
"underscore.string": "underscore.string",
"update-notifier": "update-notifier",
"url": "jsurl",
"UUID": "uuid",
"validator": "validator",
"vega": "vega",
"vex": "vex-js",
"video": "videojs",
"vue": "vue",
"vue-router": "vue-router",
"webtorrent": "webtorrent",
"when": "when",
"winston": "winston",
"wrench-js": "wrench",
"ws": "ws",
"xlsx": "xlsx",
"xml2json": "x2js",
"xmlbuilder-js": "xmlbuilder",
"xregexp": "xregexp",
"yargs": "yargs",
"yosay": "yosay",
"yui": "yui",
"yui3": "yui",
"zepto": "zepto",
"ZeroClipboard": "zeroclipboard",
"ZSchema-browser": "z-schema"
}
}
@@ -17,10 +17,10 @@ namespace ts.server.typingsInstaller {
constructor(private readonly logFile?: string) {
}
isEnabled() {
isEnabled = () => {
return this.logEnabled && this.logFile !== undefined;
}
writeLine(text: string) {
writeLine = (text: string) => {
try {
fs.appendFileSync(this.logFile, text + sys.newLine);
}
@@ -77,11 +77,12 @@ namespace ts.server.typingsInstaller {
private delayedInitializationError: InitializationFailedResponse;
constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, npmLocation: string | undefined, throttleLimit: number, log: Log) {
constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, typesMapLocation: string, npmLocation: string | undefined, throttleLimit: number, log: Log) {
super(
sys,
globalTypingsCacheLocation,
typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
typesMapLocation ? toPath(typesMapLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typesMap.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
throttleLimit,
log);
this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]);
@@ -102,7 +103,7 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`);
}
this.execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" });
this.execSync(`${this.npmPath} install --ignore-scripts ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" });
if (this.log.isEnabled()) {
this.log.writeLine(`Updated ${TypesRegistryPackageName} npm package`);
}
@@ -152,7 +153,7 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(args)}'.`);
}
const command = `${this.npmPath} install ${args.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`;
const command = `${this.npmPath} install --ignore-scripts ${args.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`;
const start = Date.now();
let stdout: Buffer;
let stderr: Buffer;
@@ -175,6 +176,7 @@ namespace ts.server.typingsInstaller {
const logFilePath = findArgument(server.Arguments.LogFile);
const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation);
const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation);
const typesMapLocation = findArgument(server.Arguments.TypesMapLocation);
const npmLocation = findArgument(server.Arguments.NpmLocation);
const log = new FileLog(logFilePath);
@@ -189,6 +191,6 @@ namespace ts.server.typingsInstaller {
}
process.exit(0);
});
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, npmLocation, /*throttleLimit*/5, log);
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, /*throttleLimit*/5, log);
installer.listen();
}
@@ -97,10 +97,11 @@ namespace ts.server.typingsInstaller {
protected readonly installTypingHost: InstallTypingHost,
private readonly globalCachePath: string,
private readonly safeListPath: Path,
private readonly typesMapLocation: Path,
private readonly throttleLimit: number,
protected readonly log = nullLog) {
if (this.log.isEnabled()) {
this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}'`);
this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}', types map path ${typesMapLocation}`);
}
this.processCacheLocation(this.globalCachePath);
}
@@ -145,11 +146,11 @@ namespace ts.server.typingsInstaller {
}
if (this.safeList === undefined) {
this.safeList = JsTyping.loadSafeList(this.installTypingHost, this.safeListPath);
this.initializeSafeList();
}
const discoverTypingsResult = JsTyping.discoverTypings(
this.installTypingHost,
this.log.isEnabled() ? this.log.writeLine : undefined,
this.log.isEnabled() ? (s => this.log.writeLine(s)) : undefined,
req.fileNames,
req.projectRootPath,
this.safeList,
@@ -178,6 +179,20 @@ namespace ts.server.typingsInstaller {
}
}
private initializeSafeList() {
// Prefer the safe list from the types map if it exists
if (this.typesMapLocation) {
const safeListFromMap = JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation);
if (safeListFromMap) {
this.log.writeLine(`Loaded safelist from types map file '${this.typesMapLocation}'`);
this.safeList = safeListFromMap;
return;
}
this.log.writeLine(`Failed to load safelist from types map file '${this.typesMapLocation}'`);
}
this.safeList = JsTyping.loadSafeList(this.installTypingHost, this.safeListPath);
}
private processCacheLocation(cacheLocation: string) {
if (this.log.isEnabled()) {
this.log.writeLine(`Processing cache location '${cacheLocation}'`);
+1 -1
View File
@@ -49,7 +49,7 @@ namespace ts.server {
export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
return {
projectName: project.getProjectName(),
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true),
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),
compilerOptions: project.getCompilerOptions(),
typeAcquisition,
unresolvedImports,
+8
View File
@@ -47,6 +47,14 @@ namespace ts.JsTyping {
return createMapFromTemplate<string>(result.config);
}
export function loadTypesMap(host: TypingResolutionHost, typesMapPath: Path): SafeList | undefined {
const result = readConfigFile(typesMapPath, path => host.readFile(path));
if (result.config) {
return createMapFromTemplate<string>(result.config.simpleMap);
}
return undefined;
}
/**
* @param host is the object providing I/O related operations.
* @param fileNames are the file names that belong to the same project
+1
View File
@@ -14,6 +14,7 @@
"../compiler/parser.ts",
"../compiler/utilities.ts",
"../compiler/binder.ts",
"../compiler/symbolWalker.ts",
"../compiler/checker.ts",
"../compiler/factory.ts",
"../compiler/visitor.ts",
@@ -0,0 +1,19 @@
tests/cases/compiler/baseExpressionTypeParameters.ts(10,27): error TS2562: Base class expressions cannot reference class type parameters.
==== tests/cases/compiler/baseExpressionTypeParameters.ts (1 errors) ====
// Repro from #17829
function base<T>() {
class Base {
static prop: T;
}
return Base;
}
class Gen<T> extends base<T>() {} // Error, T not in scope
~
!!! error TS2562: Base class expressions cannot reference class type parameters.
class Spec extends Gen<string> {}
<string>Spec.prop;
@@ -0,0 +1,50 @@
//// [baseExpressionTypeParameters.ts]
// Repro from #17829
function base<T>() {
class Base {
static prop: T;
}
return Base;
}
class Gen<T> extends base<T>() {} // Error, T not in scope
class Spec extends Gen<string> {}
<string>Spec.prop;
//// [baseExpressionTypeParameters.js]
// Repro from #17829
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
function base() {
var Base = /** @class */ (function () {
function Base() {
}
return Base;
}());
return Base;
}
var Gen = /** @class */ (function (_super) {
__extends(Gen, _super);
function Gen() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Gen;
}(base())); // Error, T not in scope
var Spec = /** @class */ (function (_super) {
__extends(Spec, _super);
function Spec() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Spec;
}(Gen));
Spec.prop;
@@ -1,21 +0,0 @@
tests/cases/conformance/jsdoc/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
tests/cases/conformance/jsdoc/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/jsdoc/0.js (2 errors) ====
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
~~~~~~~~
!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -1,24 +0,0 @@
//// [0.js]
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
//// [0.js]
// @ts-check
/** @type {function (number)} */
var x1 = function (a) { return a + 1; };
x1("string");
/** @type {function (number): number} */
var x2 = function (a) { return a + 1; };
/** @type {string} */
var a;
a = x2(0);
@@ -0,0 +1,5 @@
=== tests/cases/conformance/jsdoc/test.js ===
/** @type {Array<?number>} */
var nns;
>nns : Symbol(nns, Decl(test.js, 1, 3))
@@ -0,0 +1,5 @@
=== tests/cases/conformance/jsdoc/test.js ===
/** @type {Array<?number>} */
var nns;
>nns : number[]
@@ -0,0 +1,847 @@
tests/cases/compiler/immutable.d.ts(25,39): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(46,20): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(47,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(48,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(49,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(50,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(51,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(52,26): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(58,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(60,63): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(68,41): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(69,38): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(69,47): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(78,21): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(79,21): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(89,20): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(90,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(91,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(92,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(93,23): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(94,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(95,26): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(101,42): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(106,58): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(113,48): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(114,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(114,54): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(120,42): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(125,58): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(134,33): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(134,42): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(135,29): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(135,38): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(139,38): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(155,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(157,62): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(169,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(172,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(174,62): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(188,40): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(195,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(198,19): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(205,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(207,63): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(217,30): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(218,34): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(226,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(227,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(234,48): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(235,52): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(236,109): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(237,109): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(242,22): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(243,25): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(244,24): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(245,28): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(246,25): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(247,25): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(258,8): error TS2304: Cannot find name 'Symbol'.
tests/cases/compiler/immutable.d.ts(258,28): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(266,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(274,44): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(279,60): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(288,44): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(293,47): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(295,65): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(304,40): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(309,47): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(311,64): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(320,38): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(329,58): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(339,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(341,22): error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
Types of property 'toSeq' are incompatible.
Type '() => Keyed<K, V>' is not assignable to type '() => this'.
Type 'Keyed<K, V>' is not assignable to type 'this'.
tests/cases/compiler/immutable.d.ts(347,44): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(352,60): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(355,8): error TS2304: Cannot find name 'Symbol'.
tests/cases/compiler/immutable.d.ts(355,28): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(358,44): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(359,22): error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
Types of property 'toSeq' are incompatible.
Type '() => Indexed<T>' is not assignable to type '() => this'.
Type 'Indexed<T>' is not assignable to type 'this'.
tests/cases/compiler/immutable.d.ts(382,47): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(384,65): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(387,8): error TS2304: Cannot find name 'Symbol'.
tests/cases/compiler/immutable.d.ts(387,28): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(390,40): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(391,22): error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
Types of property 'toSeq' are incompatible.
Type '() => Set<T>' is not assignable to type '() => this'.
Type 'Set<T>' is not assignable to type 'this'.
tests/cases/compiler/immutable.d.ts(396,47): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(398,64): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(401,8): error TS2304: Cannot find name 'Symbol'.
tests/cases/compiler/immutable.d.ts(401,28): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(405,45): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(420,26): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(421,26): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(442,13): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(443,15): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(444,16): error TS2304: Cannot find name 'IterableIterator'.
tests/cases/compiler/immutable.d.ts(476,58): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(503,20): error TS2304: Cannot find name 'Iterable'.
tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Iterable'.
==== tests/cases/compiler/complex.d.ts (0 errors) ====
interface Ara<T> { t: T }
interface Collection<K, V> {
map<M>(mapper: (value: V, key: K, iter: this) => M): Collection<K, M>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Ara<M>, context?: any): Collection<K, M>;
// these seem necessary to push it over the top for memory usage
reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
toSeq(): Seq<K, V>;
}
interface Seq<K, V> extends Collection<K, V> {
}
interface N1<T> extends Collection<void, T> {
map<M>(mapper: (value: T, key: void, iter: this) => M): N1<M>;
flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N1<M>;
}
interface N2<T> extends N1<T> {
map<M>(mapper: (value: T, key: void, iter: this) => M): N2<M>;
flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N2<M>;
toSeq(): N2<T>;
}
==== tests/cases/compiler/immutable.d.ts (98 errors) ====
// Test that complex recursive collections can pass the `extends` assignability check without
// running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures
// started being checked.
declare module Immutable {
export function fromJS(jsValue: any, reviver?: (key: string | number, sequence: Collection.Keyed<string, any> | Collection.Indexed<any>, path?: Array<string | number>) => any): any;
export function is(first: any, second: any): boolean;
export function hash(value: any): number;
export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
export function isOrdered(maybeOrdered: any): boolean;
export function isValueObject(maybeValue: any): maybeValue is ValueObject;
export interface ValueObject {
equals(other: any): boolean;
hashCode(): number;
}
export module List {
function isList(maybeList: any): maybeList is List<any>;
function of<T>(...values: Array<T>): List<T>;
}
export function List(): List<any>;
export function List<T>(): List<T>;
export function List<T>(collection: Iterable<T>): List<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface List<T> extends Collection.Indexed<T> {
// Persistent changes
set(index: number, value: T): List<T>;
delete(index: number): List<T>;
remove(index: number): List<T>;
insert(index: number, value: T): List<T>;
clear(): List<T>;
push(...values: Array<T>): List<T>;
pop(): List<T>;
unshift(...values: Array<T>): List<T>;
shift(): List<T>;
update(index: number, notSetValue: T, updater: (value: T) => T): this;
update(index: number, updater: (value: T) => T): this;
update<R>(updater: (value: this) => R): R;
merge(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeDeep(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeDeepWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
setSize(size: number): List<T>;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
deleteIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
removeIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): List<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): List<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): List<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export module Map {
function isMap(maybeMap: any): maybeMap is Map<any, any>;
function of(...keyValues: Array<any>): Map<any, any>;
}
export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Map<T>(collection: Iterable<Iterable<T>>): Map<T, T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
export function Map<K, V>(): Map<K, V>;
export function Map(): Map<any, any>;
export interface Map<K, V> extends Collection.Keyed<K, V> {
// Persistent changes
set(key: K, value: V): this;
delete(key: K): this;
remove(key: K): this;
deleteAll(keys: Iterable<K>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
removeAll(keys: Iterable<K>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
clear(): this;
update(key: K, notSetValue: V, updater: (value: V) => V): this;
update(key: K, updater: (value: V) => V): this;
update<R>(updater: (value: this) => R): R;
merge(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeDeep(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
deleteIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
removeIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Map<K | KC, V | VC>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
concat<C>(...collections: Array<{[key: string]: C}>): Map<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Map<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Map<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Map<any, any>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module OrderedMap {
function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap<any, any>;
}
export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
export function OrderedMap<K, V>(): OrderedMap<K, V>;
export function OrderedMap(): OrderedMap<any, any>;
export interface OrderedMap<K, V> extends Map<K, V> {
// Sequence algorithms
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): OrderedMap<K | KC, V | VC>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
concat<C>(...collections: Array<{[key: string]: C}>): OrderedMap<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): OrderedMap<any, any>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module Set {
function isSet(maybeSet: any): maybeSet is Set<any>;
function of<T>(...values: Array<T>): Set<T>;
function fromKeys<T>(iter: Collection<T, any>): Set<T>;
function fromKeys(obj: {[key: string]: any}): Set<string>;
function intersect<T>(sets: Iterable<Iterable<T>>): Set<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
function union<T>(sets: Iterable<Iterable<T>>): Set<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
}
export function Set(): Set<any>;
export function Set<T>(): Set<T>;
export function Set<T>(collection: Iterable<T>): Set<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Set<T> extends Collection.Set<T> {
// Persistent changes
add(value: T): this;
delete(value: T): this;
remove(value: T): this;
clear(): this;
union(...collections: Array<Collection<any, T> | Array<T>>): this;
merge(...collections: Array<Collection<any, T> | Array<T>>): this;
intersect(...collections: Array<Collection<any, T> | Array<T>>): this;
subtract(...collections: Array<Collection<any, T> | Array<T>>): this;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Set<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Set<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
}
export module OrderedSet {
function isOrderedSet(maybeOrderedSet: any): boolean;
function of<T>(...values: Array<T>): OrderedSet<T>;
function fromKeys<T>(iter: Collection<T, any>): OrderedSet<T>;
function fromKeys(obj: {[key: string]: any}): OrderedSet<string>;
}
export function OrderedSet(): OrderedSet<any>;
export function OrderedSet<T>(): OrderedSet<T>;
export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface OrderedSet<T> extends Set<T> {
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): OrderedSet<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): OrderedSet<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): OrderedSet<Z>;
zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): OrderedSet<Z>;
zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): OrderedSet<Z>;
}
export module Stack {
function isStack(maybeStack: any): maybeStack is Stack<any>;
function of<T>(...values: Array<T>): Stack<T>;
}
export function Stack(): Stack<any>;
export function Stack<T>(): Stack<T>;
export function Stack<T>(collection: Iterable<T>): Stack<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Stack<T> extends Collection.Indexed<T> {
// Reading values
peek(): T | undefined;
// Persistent changes
clear(): Stack<T>;
unshift(...values: Array<T>): Stack<T>;
unshiftAll(iter: Iterable<T>): Stack<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
shift(): Stack<T>;
push(...values: Array<T>): Stack<T>;
pushAll(iter: Iterable<T>): Stack<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
pop(): Stack<T>;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Stack<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Stack<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
export module Record {
export function isRecord(maybeRecord: any): maybeRecord is Record.Instance<any>;
export function getDescriptiveName(record: Instance<any>): string;
export interface Class<T extends Object> {
(values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
new (values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
}
export interface Instance<T extends Object> {
readonly size: number;
// Reading values
has(key: string): boolean;
get<K extends keyof T>(key: K): T[K];
// Reading deep values
hasIn(keyPath: Iterable<any>): boolean;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
getIn(keyPath: Iterable<any>): any;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Value equality
equals(other: any): boolean;
hashCode(): number;
// Persistent changes
set<K extends keyof T>(key: K, value: T[K]): this;
update<K extends keyof T>(key: K, updater: (value: T[K]) => T[K]): this;
merge(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeDeep(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
delete<K extends keyof T>(key: K): this;
remove<K extends keyof T>(key: K): this;
clear(): this;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
deleteIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
removeIn(keyPath: Iterable<any>): this;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Conversion to JavaScript types
toJS(): { [K in keyof T]: any };
toJSON(): T;
toObject(): T;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
toSeq(): Seq.Keyed<keyof T, T[keyof T]>;
[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
}
}
export function Record<T>(defaultValues: T, name?: string): Record.Class<T>;
export module Seq {
function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed<any> | Seq.Keyed<any, any>;
function of<T>(...values: Array<T>): Seq.Indexed<T>;
export module Keyed {}
export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
export function Keyed<K, V>(): Seq.Keyed<K, V>;
export function Keyed(): Seq.Keyed<any, any>;
export interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
toJS(): Object;
toJSON(): { [key: string]: V };
toSeq(): this;
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Seq.Keyed<K | KC, V | VC>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
concat<C>(...collections: Array<{[key: string]: C}>): Seq.Keyed<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq.Keyed<any, any>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
module Indexed {
function of<T>(...values: Array<T>): Seq.Indexed<T>;
}
export function Indexed(): Seq.Indexed<any>;
export function Indexed<T>(): Seq.Indexed<T>;
export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): this;
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Indexed<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Seq.Indexed<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export module Set {
function of<T>(...values: Array<T>): Seq.Set<T>;
}
export function Set(): Seq.Set<any>;
export function Set<T>(): Seq.Set<T>;
export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Set<T> extends Seq<never, T>, Collection.Set<T> {
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): this;
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Set<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Seq.Set<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
}
}
export function Seq<S extends Seq<any, any>>(seq: S): S;
export function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
export function Seq(): Seq<any, any>;
export interface Seq<K, V> extends Collection<K, V> {
readonly size: number | undefined;
// Force evaluation
cacheResult(): this;
// Sequence algorithms
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq<K, M>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq<K, M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module Collection {
function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
function isOrdered(maybeOrdered: any): boolean;
export module Keyed {}
export function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
export interface Keyed<K, V> extends Collection<K, V> {
~~~~~
!!! error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Keyed<K, V>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Keyed<K, V>' is not assignable to type 'this'.
toJS(): Object;
toJSON(): { [key: string]: V };
toSeq(): Seq.Keyed<K, V>;
// Sequence functions
flip(): this;
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Collection.Keyed<K | KC, V | VC>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
concat<C>(...collections: Array<{[key: string]: C}>): Collection.Keyed<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection.Keyed<any, any>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<[K, V]>;
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
}
export module Indexed {}
export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Indexed<T> extends Collection<number, T> {
~~~~~~~
!!! error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Indexed<T>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Indexed<T>' is not assignable to type 'this'.
toJS(): Array<any>;
toJSON(): Array<T>;
// Reading values
get<NSV>(index: number, notSetValue: NSV): T | NSV;
get(index: number): T | undefined;
// Conversion to Seq
toSeq(): Seq.Indexed<T>;
fromEntrySeq(): Seq.Keyed<any, any>;
// Combination
interpose(separator: T): this;
interleave(...collections: Array<Collection<any, T>>): this;
splice(index: number, removeNum: number, ...values: Array<T>): this;
zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): Collection.Indexed<Z>;
zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): Collection.Indexed<Z>;
zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): Collection.Indexed<Z>;
// Search for value
indexOf(searchValue: T): number;
lastIndexOf(searchValue: T): number;
findIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Indexed<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Collection.Indexed<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<T>;
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
}
export module Set {}
export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export interface Set<T> extends Collection<never, T> {
~~~
!!! error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
!!! error TS2430: Types of property 'toSeq' are incompatible.
!!! error TS2430: Type '() => Set<T>' is not assignable to type '() => this'.
!!! error TS2430: Type 'Set<T>' is not assignable to type 'this'.
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): Seq.Set<T>;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Set<T | C>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Collection.Set<M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<T>;
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
}
}
export function Collection<I extends Collection<any, any>>(collection: I): I;
export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
export function Collection<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
export interface Collection<K, V> extends ValueObject {
// Value equality
equals(other: any): boolean;
hashCode(): number;
// Reading values
get<NSV>(key: K, notSetValue: NSV): V | NSV;
get(key: K): V | undefined;
has(key: K): boolean;
includes(value: V): boolean;
contains(value: V): boolean;
first(): V | undefined;
last(): V | undefined;
// Reading deep values
getIn(searchKeyPath: Iterable<any>, notSetValue?: any): any;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
hasIn(searchKeyPath: Iterable<any>): boolean;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Persistent changes
update<R>(updater: (value: this) => R): R;
// Conversion to JavaScript types
toJS(): Array<any> | { [key: string]: any };
toJSON(): Array<V> | { [key: string]: V };
toArray(): Array<V>;
toObject(): { [key: string]: V };
// Conversion to Collections
toMap(): Map<K, V>;
toOrderedMap(): OrderedMap<K, V>;
toSet(): Set<V>;
toOrderedSet(): OrderedSet<V>;
toList(): List<V>;
toStack(): Stack<V>;
// Conversion to Seq
toSeq(): this;
toKeyedSeq(): Seq.Keyed<K, V>;
toIndexedSeq(): Seq.Indexed<V>;
toSetSeq(): Seq.Set<V>;
// Iterators
keys(): IterableIterator<K>;
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
values(): IterableIterator<V>;
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
entries(): IterableIterator<[K, V]>;
~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'IterableIterator'.
// Collections (Seq)
keySeq(): Seq.Indexed<K>;
valueSeq(): Seq.Indexed<V>;
entrySeq(): Seq.Indexed<[K, V]>;
// Sequence algorithms
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection<K, M>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
filterNot(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
reverse(): this;
sort(comparator?: (valueA: V, valueB: V) => number): this;
sortBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): this;
groupBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): /*Map*/Seq.Keyed<G, /*this*/Collection<K, V>>;
// Side effects
forEach(sideEffect: (value: V, key: K, iter: this) => any, context?: any): number;
// Creating subsets
slice(begin?: number, end?: number): this;
rest(): this;
butLast(): this;
skip(amount: number): this;
skipLast(amount: number): this;
skipWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
skipUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
take(amount: number): this;
takeLast(amount: number): this;
takeWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
takeUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
// Combination
concat(...valuesOrCollections: Array<any>): Collection<any, any>;
flatten(depth?: number): Collection<any, any>;
flatten(shallow?: boolean): Collection<any, any>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection<K, M>;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
// Reducing a value
reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
reduceRight<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduceRight<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
every(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
some(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
join(separator?: string): string;
isEmpty(): boolean;
count(): number;
count(predicate: (value: V, key: K, iter: this) => boolean, context?: any): number;
countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G, number>;
// Search for value
find(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
findLast(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
findEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
findLastEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
findKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
findLastKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
keyOf(searchValue: V): K | undefined;
lastKeyOf(searchValue: V): K | undefined;
max(comparator?: (valueA: V, valueB: V) => number): V | undefined;
maxBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
min(comparator?: (valueA: V, valueB: V) => number): V | undefined;
minBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
// Comparison
isSubset(iter: Iterable<V>): boolean;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
isSuperset(iter: Iterable<V>): boolean;
~~~~~~~~
!!! error TS2304: Cannot find name 'Iterable'.
readonly size: number;
}
}
declare module "immutable" {
export = Immutable
}
@@ -1,17 +0,0 @@
tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration.
==== tests/cases/compiler/exportAssignmentOfGenericType1_1.ts (0 errors) ====
///<reference path='exportAssignmentOfGenericType1_0.ts'/>
import q = require("exportAssignmentOfGenericType1_0");
class M extends q<string> { }
var m: M;
var r: string = m.foo;
==== tests/cases/compiler/exportAssignmentOfGenericType1_0.ts (1 errors) ====
export = T;
~
!!! error TS2449: Class 'T' used before its declaration.
class T<X> { foo: X; }
@@ -1,21 +0,0 @@
tests/cases/compiler/w1.ts(1,1): error TS2449: Class 'Widget1' used before its declaration.
tests/cases/compiler/w1.ts(1,10): error TS2449: Class 'Widget1' used before its declaration.
==== tests/cases/compiler/consumer.ts (0 errors) ====
import e = require('./exporter');
export function w(): e.w { // Should be OK
return new e.w();
}
==== tests/cases/compiler/w1.ts (2 errors) ====
export = Widget1
~~~~~~~~~~~~~~~~
!!! error TS2449: Class 'Widget1' used before its declaration.
~~~~~~~
!!! error TS2449: Class 'Widget1' used before its declaration.
class Widget1 { name = 'one'; }
==== tests/cases/compiler/exporter.ts (0 errors) ====
export import w = require('./w1');
@@ -1,11 +1,11 @@
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'.
tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface.
==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ====
class C<T> extends T { }
~
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
!!! error TS2304: Cannot find name 'T'.
interface I<T> extends T { }
~
!!! error TS2312: An interface may only extend a class or another interface.
@@ -0,0 +1,17 @@
tests/cases/compiler/invalidContinueInDownlevelAsync.ts(3,9): error TS1107: Jump target cannot cross function boundary.
tests/cases/compiler/invalidContinueInDownlevelAsync.ts(6,9): error TS7027: Unreachable code detected.
==== tests/cases/compiler/invalidContinueInDownlevelAsync.ts (2 errors) ====
async function func() {
if (true) {
continue;
~~~~~~~~~
!!! error TS1107: Jump target cannot cross function boundary.
}
else {
await 1;
~~~~~
!!! error TS7027: Unreachable code detected.
}
}
@@ -0,0 +1,63 @@
//// [invalidContinueInDownlevelAsync.ts]
async function func() {
if (true) {
continue;
}
else {
await 1;
}
}
//// [invalidContinueInDownlevelAsync.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
function func() {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 1];
continue;
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, 1];
case 2:
_a.sent();
_a.label = 3;
case 3: return [2 /*return*/];
}
});
});
}
@@ -4,7 +4,7 @@ tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested:
Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'.
Types of property 'prop' are incompatible.
Type '{ colour: string; }' is not assignable to type 'CSSProps'.
Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'.
Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'?
==== tests/cases/compiler/nestedFreshLiteral.ts (1 errors) ====
@@ -27,5 +27,5 @@ tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested:
!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'.
!!! error TS2322: Types of property 'prop' are incompatible.
!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'CSSProps'.
!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'.
!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'?
}
@@ -1,5 +1,5 @@
tests/cases/compiler/objectLiteralExcessProperties.ts(9,18): error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'.
Object literal may only specify known properties, and 'forword' does not exist in type 'Book'.
Object literal may only specify known properties, but 'forword' does not exist in type 'Book'. Did you mean to write 'foreword'?
tests/cases/compiler/objectLiteralExcessProperties.ts(11,27): error TS2322: Type '{ foreward: string; }' is not assignable to type 'string | Book'.
Object literal may only specify known properties, and 'foreward' does not exist in type 'string | Book'.
tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book | Book[]'.
@@ -8,9 +8,9 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type
Type '{ forwards: string; }' is not assignable to type 'Book'.
Object literal may only specify known properties, and 'forwards' does not exist in type 'Book'.
tests/cases/compiler/objectLiteralExcessProperties.ts(15,42): error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'.
Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'.
Object literal may only specify known properties, but 'colour' does not exist in type 'Book & Cover'. Did you mean to write 'color'?
tests/cases/compiler/objectLiteralExcessProperties.ts(17,26): error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'.
Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'.
Object literal may only specify known properties, but 'foreward' does not exist in type 'Book & Cover'. Did you mean to write 'foreword'?
tests/cases/compiler/objectLiteralExcessProperties.ts(19,57): error TS2322: Type '{ foreword: string; color: string; price: number; }' is not assignable to type 'Book & Cover'.
Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'.
tests/cases/compiler/objectLiteralExcessProperties.ts(21,43): error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'.
@@ -22,7 +22,7 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(25,27): error TS2322: Type
tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type '{ 0: { colour: string; }; }' is not assignable to type 'Indexed'.
Property '0' is incompatible with index signature.
Type '{ colour: string; }' is not assignable to type 'Cover'.
Object literal may only specify known properties, and 'colour' does not exist in type 'Cover'.
Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'?
==== tests/cases/compiler/objectLiteralExcessProperties.ts (10 errors) ====
@@ -37,7 +37,7 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
var b1: Book = { forword: "oops" };
~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'.
!!! error TS2322: Object literal may only specify known properties, and 'forword' does not exist in type 'Book'.
!!! error TS2322: Object literal may only specify known properties, but 'forword' does not exist in type 'Book'. Did you mean to write 'foreword'?
var b2: Book | string = { foreward: "nope" };
~~~~~~~~~~~~~~~~
@@ -55,12 +55,12 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
var b4: Book & Cover = { foreword: "hi", colour: "blue" };
~~~~~~~~~~~~~~
!!! error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'.
!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'.
!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'Book & Cover'. Did you mean to write 'color'?
var b5: Book & Cover = { foreward: "hi", color: "blue" };
~~~~~~~~~~~~~~
!!! error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'.
!!! error TS2322: Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'.
!!! error TS2322: Object literal may only specify known properties, but 'foreward' does not exist in type 'Book & Cover'. Did you mean to write 'foreword'?
var b6: Book & Cover = { foreword: "hi", color: "blue", price: 10.99 };
~~~~~~~~~~~~
@@ -93,5 +93,5 @@ tests/cases/compiler/objectLiteralExcessProperties.ts(33,27): error TS2322: Type
!!! error TS2322: Type '{ 0: { colour: string; }; }' is not assignable to type 'Indexed'.
!!! error TS2322: Property '0' is incompatible with index signature.
!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'Cover'.
!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'Cover'.
!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'Cover'. Did you mean to write 'color'?
@@ -0,0 +1,26 @@
//// [objectSpreadWithinMethodWithinObjectWithSpread.ts]
const obj = {};
const a = {
...obj,
prop() {
return {
...obj,
metadata: 213
};
}
};
//// [objectSpreadWithinMethodWithinObjectWithSpread.js]
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var obj = {};
var a = __assign({}, obj, { prop: function () {
return __assign({}, obj, { metadata: 213 });
} });
@@ -0,0 +1,24 @@
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
const obj = {};
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
const a = {
>a : Symbol(a, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 1, 5))
...obj,
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
prop() {
>prop : Symbol(prop, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 2, 11))
return {
...obj,
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
metadata: 213
>metadata : Symbol(metadata, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 5, 19))
};
}
};
@@ -0,0 +1,29 @@
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
const obj = {};
>obj : {}
>{} : {}
const a = {
>a : { prop(): { metadata: number; }; }
>{ ...obj, prop() { return { ...obj, metadata: 213 }; }} : { prop(): { metadata: number; }; }
...obj,
>obj : {}
prop() {
>prop : () => { metadata: number; }
return {
>{ ...obj, metadata: 213 } : { metadata: number; }
...obj,
>obj : {}
metadata: 213
>metadata : number
>213 : 213
};
}
};
@@ -1,20 +0,0 @@
tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,1): error TS2449: Class 'Foo' used before its declaration.
tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,10): error TS2449: Class 'Foo' used before its declaration.
==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts (0 errors) ====
import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0");
export = Bar;
interface Bar {
foo: Foo<number>;
}
==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts (2 errors) ====
export = Foo;
~~~~~~~~~~~~~
!!! error TS2449: Class 'Foo' used before its declaration.
~~~
!!! error TS2449: Class 'Foo' used before its declaration.
class Foo<A> {
constructor(public a: A) { }
}
@@ -0,0 +1,28 @@
tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(6,3): error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '__foo'?
tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts(14,5): error TS2322: Type '{ ___foo: number; }' is not assignable to type '{ __foo: number; }'.
Object literal may only specify known properties, but '___foo' does not exist in type '{ __foo: number; }'. Did you mean to write '__foo'?
==== tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts (2 errors) ====
// @filename abc.ts
export declare let a: {
__foo: 10,
}
a.___foo
~~~~~~
!!! error TS2551: Property '___foo' does not exist on type '{ __foo: 10; }'. Did you mean '__foo'?
// @filename def.ts
export let b: {
__foo: number
}
b = {
___foo: 100,
~~~~~~~~~~~
!!! error TS2322: Type '{ ___foo: number; }' is not assignable to type '{ __foo: number; }'.
!!! error TS2322: Object literal may only specify known properties, but '___foo' does not exist in type '{ __foo: number; }'. Did you mean to write '__foo'?
}
@@ -0,0 +1,26 @@
//// [spellingSuggestionLeadingUnderscores01.ts]
// @filename abc.ts
export declare let a: {
__foo: 10,
}
a.___foo
// @filename def.ts
export let b: {
__foo: number
}
b = {
___foo: 100,
}
//// [spellingSuggestionLeadingUnderscores01.js]
"use strict";
exports.__esModule = true;
exports.a.___foo;
exports.b = {
___foo: 100
};
@@ -84,7 +84,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,20): e
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS1003: Identifier expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,27): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,24): error TS1138: Parameter declaration expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS1003: Identifier expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,30): error TS1005: ',' expected.
@@ -94,7 +93,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): e
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'.
==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (60 errors) ====
==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (59 errors) ====
class C {
n: number;
explicitThis(this: this, m: number): number {
@@ -403,8 +402,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e
function optional(this?: C): number { return this.n; }
~
!!! error TS1005: ',' expected.
~
!!! error TS1138: Parameter declaration expected.
function decorated(@deco() this: C): number { return this.n; }
~~~~
!!! error TS1003: Identifier expected.
@@ -345,7 +345,7 @@ function modifiers(, C) {
return this.n;
}
function restParam(C) { return this.n; }
function optional(C) { return this.n; }
function optional() { return this.n; }
function decorated(, C) {
if ( === void 0) { = this; }
return this.n;
@@ -0,0 +1,40 @@
//// [index.tsx]
namespace JSX {
export interface Element {}
}
type Props<T> = PropsBase<string> | PropsWithConvert<T>;
interface PropsBase<T> {
data: T;
}
interface PropsWithConvert<T> extends PropsBase<T> {
convert: (t: T) => string;
}
function ShouldInferFromData<T>(props: Props<T>): JSX.Element {
return <div />;
}
// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
ShouldInferFromData({ data: "1", convert: n => "" + n });
ShouldInferFromData({ data: 2, convert: n => "" + n });
const f1 = <ShouldInferFromData data={"1"} />;
const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />;
const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
//// [index.jsx]
function ShouldInferFromData(props) {
return <div />;
}
// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
ShouldInferFromData({ data: "1", convert: function (n) { return "" + n; } });
ShouldInferFromData({ data: 2, convert: function (n) { return "" + n; } });
var f1 = <ShouldInferFromData data={"1"}/>;
var f2 = <ShouldInferFromData data={"1"} convert={function (n) { return "" + n; }}/>;
var f3 = <ShouldInferFromData data={2} convert={function (n) { return "" + n; }}/>;
@@ -0,0 +1,90 @@
=== tests/cases/compiler/index.tsx ===
namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
export interface Element {}
>Element : Symbol(Element, Decl(index.tsx, 0, 15))
}
type Props<T> = PropsBase<string> | PropsWithConvert<T>;
>Props : Symbol(Props, Decl(index.tsx, 2, 1))
>T : Symbol(T, Decl(index.tsx, 4, 11))
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1))
>T : Symbol(T, Decl(index.tsx, 4, 11))
interface PropsBase<T> {
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>T : Symbol(T, Decl(index.tsx, 6, 20))
data: T;
>data : Symbol(PropsBase.data, Decl(index.tsx, 6, 24))
>T : Symbol(T, Decl(index.tsx, 6, 20))
}
interface PropsWithConvert<T> extends PropsBase<T> {
>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1))
>T : Symbol(T, Decl(index.tsx, 10, 27))
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>T : Symbol(T, Decl(index.tsx, 10, 27))
convert: (t: T) => string;
>convert : Symbol(PropsWithConvert.convert, Decl(index.tsx, 10, 52))
>t : Symbol(t, Decl(index.tsx, 11, 14))
>T : Symbol(T, Decl(index.tsx, 10, 27))
}
function ShouldInferFromData<T>(props: Props<T>): JSX.Element {
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>T : Symbol(T, Decl(index.tsx, 14, 29))
>props : Symbol(props, Decl(index.tsx, 14, 32))
>Props : Symbol(Props, Decl(index.tsx, 2, 1))
>T : Symbol(T, Decl(index.tsx, 14, 29))
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
>Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15))
return <div />;
>div : Symbol(unknown)
}
// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 19, 21))
ShouldInferFromData({ data: "1", convert: n => "" + n });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 20, 21))
>convert : Symbol(convert, Decl(index.tsx, 20, 32))
>n : Symbol(n, Decl(index.tsx, 20, 41))
>n : Symbol(n, Decl(index.tsx, 20, 41))
ShouldInferFromData({ data: 2, convert: n => "" + n });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 21, 21))
>convert : Symbol(convert, Decl(index.tsx, 21, 30))
>n : Symbol(n, Decl(index.tsx, 21, 39))
>n : Symbol(n, Decl(index.tsx, 21, 39))
const f1 = <ShouldInferFromData data={"1"} />;
>f1 : Symbol(f1, Decl(index.tsx, 24, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 24, 31))
const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />;
>f2 : Symbol(f2, Decl(index.tsx, 25, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 25, 31))
>convert : Symbol(convert, Decl(index.tsx, 25, 42))
>n : Symbol(n, Decl(index.tsx, 25, 52))
>n : Symbol(n, Decl(index.tsx, 25, 52))
const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
>f3 : Symbol(f3, Decl(index.tsx, 26, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 26, 31))
>convert : Symbol(convert, Decl(index.tsx, 26, 40))
>n : Symbol(n, Decl(index.tsx, 26, 50))
>n : Symbol(n, Decl(index.tsx, 26, 50))
@@ -0,0 +1,118 @@
=== tests/cases/compiler/index.tsx ===
namespace JSX {
>JSX : any
export interface Element {}
>Element : Element
}
type Props<T> = PropsBase<string> | PropsWithConvert<T>;
>Props : Props<T>
>T : T
>PropsBase : PropsBase<T>
>PropsWithConvert : PropsWithConvert<T>
>T : T
interface PropsBase<T> {
>PropsBase : PropsBase<T>
>T : T
data: T;
>data : T
>T : T
}
interface PropsWithConvert<T> extends PropsBase<T> {
>PropsWithConvert : PropsWithConvert<T>
>T : T
>PropsBase : PropsBase<T>
>T : T
convert: (t: T) => string;
>convert : (t: T) => string
>t : T
>T : T
}
function ShouldInferFromData<T>(props: Props<T>): JSX.Element {
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>T : T
>props : Props<T>
>Props : Props<T>
>T : T
>JSX : any
>Element : JSX.Element
return <div />;
><div /> : JSX.Element
>div : any
}
// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
>ShouldInferFromData({ data: "1" }) : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>{ data: "1" } : { data: string; }
>data : string
>"1" : "1"
ShouldInferFromData({ data: "1", convert: n => "" + n });
>ShouldInferFromData({ data: "1", convert: n => "" + n }) : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>{ data: "1", convert: n => "" + n } : { data: string; convert: (n: string) => string; }
>data : string
>"1" : "1"
>convert : (n: string) => string
>n => "" + n : (n: string) => string
>n : string
>"" + n : string
>"" : ""
>n : string
ShouldInferFromData({ data: 2, convert: n => "" + n });
>ShouldInferFromData({ data: 2, convert: n => "" + n }) : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>{ data: 2, convert: n => "" + n } : { data: number; convert: (n: number) => string; }
>data : number
>2 : 2
>convert : (n: number) => string
>n => "" + n : (n: number) => string
>n : number
>"" + n : string
>"" : ""
>n : number
const f1 = <ShouldInferFromData data={"1"} />;
>f1 : JSX.Element
><ShouldInferFromData data={"1"} /> : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>data : string
>"1" : "1"
const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />;
>f2 : JSX.Element
><ShouldInferFromData data={"1"} convert={n => "" + n} /> : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>data : string
>"1" : "1"
>convert : (n: "1") => string
>n => "" + n : (n: "1") => string
>n : "1"
>"" + n : string
>"" : ""
>n : "1"
const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
>f3 : JSX.Element
><ShouldInferFromData data={2} convert={n => "" + n} /> : JSX.Element
>ShouldInferFromData : <T>(props: Props<T>) => JSX.Element
>data : number
>2 : 2
>convert : (n: 2) => string
>n => "" + n : (n: 2) => string
>n : 2
>"" + n : string
>"" : ""
>n : 2
@@ -1,11 +1,11 @@
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'.
tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface.
==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ====
class C<T> extends T {}
~
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
!!! error TS2304: Cannot find name 'T'.
class C2<T> implements T {}
~
!!! error TS2422: A class may only implement another class or interface.
@@ -1,5 +1,5 @@
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2693: 'U' only refers to a type, but is being used as a value here.
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'.
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'.
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface.
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface.
@@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e
class C<T> extends T { }
~
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
!!! error TS2304: Cannot find name 'T'.
class C2<T, U> extends U { }
~
!!! error TS2693: 'U' only refers to a type, but is being used as a value here.
!!! error TS2304: Cannot find name 'U'.
interface I<T> extends T { }
~
@@ -1,11 +1,8 @@
tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo<U>' is not assignable to type 'Foo<T>'.
Type 'U' is not assignable to type 'T'.
tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
Type 'T' is not assignable to type 'U'.
tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo<U>' is not assignable to type 'Foo<T>'.
Type 'U' is not assignable to type 'T'.
tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
Type 'T' is not assignable to type 'U'.
==== tests/cases/compiler/typeParameterAssignmentCompat1.ts (4 errors) ====
@@ -23,7 +20,6 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type
return x;
~~~~~~~~~
!!! error TS2322: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
}
class C<T> {
@@ -33,10 +29,8 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type
x = y; // should be an error
~
!!! error TS2322: Type 'Foo<U>' is not assignable to type 'Foo<T>'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
return x;
~~~~~~~~~
!!! error TS2322: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
}
}
@@ -0,0 +1,13 @@
// Repro from #17829
function base<T>() {
class Base {
static prop: T;
}
return Base;
}
class Gen<T> extends base<T>() {} // Error, T not in scope
class Spec extends Gen<string> {}
<string>Spec.prop;
@@ -0,0 +1,532 @@
// @Filename: complex.d.ts
interface Ara<T> { t: T }
interface Collection<K, V> {
map<M>(mapper: (value: V, key: K, iter: this) => M): Collection<K, M>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Ara<M>, context?: any): Collection<K, M>;
// these seem necessary to push it over the top for memory usage
reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
toSeq(): Seq<K, V>;
}
interface Seq<K, V> extends Collection<K, V> {
}
interface N1<T> extends Collection<void, T> {
map<M>(mapper: (value: T, key: void, iter: this) => M): N1<M>;
flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N1<M>;
}
interface N2<T> extends N1<T> {
map<M>(mapper: (value: T, key: void, iter: this) => M): N2<M>;
flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N2<M>;
toSeq(): N2<T>;
}
// @Filename: immutable.d.ts
// Test that complex recursive collections can pass the `extends` assignability check without
// running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures
// started being checked.
declare module Immutable {
export function fromJS(jsValue: any, reviver?: (key: string | number, sequence: Collection.Keyed<string, any> | Collection.Indexed<any>, path?: Array<string | number>) => any): any;
export function is(first: any, second: any): boolean;
export function hash(value: any): number;
export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
export function isOrdered(maybeOrdered: any): boolean;
export function isValueObject(maybeValue: any): maybeValue is ValueObject;
export interface ValueObject {
equals(other: any): boolean;
hashCode(): number;
}
export module List {
function isList(maybeList: any): maybeList is List<any>;
function of<T>(...values: Array<T>): List<T>;
}
export function List(): List<any>;
export function List<T>(): List<T>;
export function List<T>(collection: Iterable<T>): List<T>;
export interface List<T> extends Collection.Indexed<T> {
// Persistent changes
set(index: number, value: T): List<T>;
delete(index: number): List<T>;
remove(index: number): List<T>;
insert(index: number, value: T): List<T>;
clear(): List<T>;
push(...values: Array<T>): List<T>;
pop(): List<T>;
unshift(...values: Array<T>): List<T>;
shift(): List<T>;
update(index: number, notSetValue: T, updater: (value: T) => T): this;
update(index: number, updater: (value: T) => T): this;
update<R>(updater: (value: this) => R): R;
merge(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeDeep(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
mergeDeepWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
setSize(size: number): List<T>;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
deleteIn(keyPath: Iterable<any>): this;
removeIn(keyPath: Iterable<any>): this;
updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): List<T | C>;
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): List<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): List<M>;
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export module Map {
function isMap(maybeMap: any): maybeMap is Map<any, any>;
function of(...keyValues: Array<any>): Map<any, any>;
}
export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
export function Map<T>(collection: Iterable<Iterable<T>>): Map<T, T>;
export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
export function Map<K, V>(): Map<K, V>;
export function Map(): Map<any, any>;
export interface Map<K, V> extends Collection.Keyed<K, V> {
// Persistent changes
set(key: K, value: V): this;
delete(key: K): this;
remove(key: K): this;
deleteAll(keys: Iterable<K>): this;
removeAll(keys: Iterable<K>): this;
clear(): this;
update(key: K, notSetValue: V, updater: (value: V) => V): this;
update(key: K, updater: (value: V) => V): this;
update<R>(updater: (value: this) => R): R;
merge(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeDeep(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
deleteIn(keyPath: Iterable<any>): this;
removeIn(keyPath: Iterable<any>): this;
updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Map<K | KC, V | VC>;
concat<C>(...collections: Array<{[key: string]: C}>): Map<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Map<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Map<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Map<any, any>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module OrderedMap {
function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap<any, any>;
}
export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
export function OrderedMap<K, V>(): OrderedMap<K, V>;
export function OrderedMap(): OrderedMap<any, any>;
export interface OrderedMap<K, V> extends Map<K, V> {
// Sequence algorithms
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): OrderedMap<K | KC, V | VC>;
concat<C>(...collections: Array<{[key: string]: C}>): OrderedMap<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): OrderedMap<any, any>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module Set {
function isSet(maybeSet: any): maybeSet is Set<any>;
function of<T>(...values: Array<T>): Set<T>;
function fromKeys<T>(iter: Collection<T, any>): Set<T>;
function fromKeys(obj: {[key: string]: any}): Set<string>;
function intersect<T>(sets: Iterable<Iterable<T>>): Set<T>;
function union<T>(sets: Iterable<Iterable<T>>): Set<T>;
}
export function Set(): Set<any>;
export function Set<T>(): Set<T>;
export function Set<T>(collection: Iterable<T>): Set<T>;
export interface Set<T> extends Collection.Set<T> {
// Persistent changes
add(value: T): this;
delete(value: T): this;
remove(value: T): this;
clear(): this;
union(...collections: Array<Collection<any, T> | Array<T>>): this;
merge(...collections: Array<Collection<any, T> | Array<T>>): this;
intersect(...collections: Array<Collection<any, T> | Array<T>>): this;
subtract(...collections: Array<Collection<any, T> | Array<T>>): this;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Set<T | C>;
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Set<M>;
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
}
export module OrderedSet {
function isOrderedSet(maybeOrderedSet: any): boolean;
function of<T>(...values: Array<T>): OrderedSet<T>;
function fromKeys<T>(iter: Collection<T, any>): OrderedSet<T>;
function fromKeys(obj: {[key: string]: any}): OrderedSet<string>;
}
export function OrderedSet(): OrderedSet<any>;
export function OrderedSet<T>(): OrderedSet<T>;
export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
export interface OrderedSet<T> extends Set<T> {
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): OrderedSet<T | C>;
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): OrderedSet<M>;
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): OrderedSet<Z>;
zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): OrderedSet<Z>;
zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): OrderedSet<Z>;
}
export module Stack {
function isStack(maybeStack: any): maybeStack is Stack<any>;
function of<T>(...values: Array<T>): Stack<T>;
}
export function Stack(): Stack<any>;
export function Stack<T>(): Stack<T>;
export function Stack<T>(collection: Iterable<T>): Stack<T>;
export interface Stack<T> extends Collection.Indexed<T> {
// Reading values
peek(): T | undefined;
// Persistent changes
clear(): Stack<T>;
unshift(...values: Array<T>): Stack<T>;
unshiftAll(iter: Iterable<T>): Stack<T>;
shift(): Stack<T>;
push(...values: Array<T>): Stack<T>;
pushAll(iter: Iterable<T>): Stack<T>;
pop(): Stack<T>;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Stack<T | C>;
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Stack<M>;
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
export module Record {
export function isRecord(maybeRecord: any): maybeRecord is Record.Instance<any>;
export function getDescriptiveName(record: Instance<any>): string;
export interface Class<T extends Object> {
(values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
new (values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
}
export interface Instance<T extends Object> {
readonly size: number;
// Reading values
has(key: string): boolean;
get<K extends keyof T>(key: K): T[K];
// Reading deep values
hasIn(keyPath: Iterable<any>): boolean;
getIn(keyPath: Iterable<any>): any;
// Value equality
equals(other: any): boolean;
hashCode(): number;
// Persistent changes
set<K extends keyof T>(key: K, value: T[K]): this;
update<K extends keyof T>(key: K, updater: (value: T[K]) => T[K]): this;
merge(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
mergeDeep(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
delete<K extends keyof T>(key: K): this;
remove<K extends keyof T>(key: K): this;
clear(): this;
// Deep persistent changes
setIn(keyPath: Iterable<any>, value: any): this;
updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
deleteIn(keyPath: Iterable<any>): this;
removeIn(keyPath: Iterable<any>): this;
// Conversion to JavaScript types
toJS(): { [K in keyof T]: any };
toJSON(): T;
toObject(): T;
// Transient changes
withMutations(mutator: (mutable: this) => any): this;
asMutable(): this;
asImmutable(): this;
// Sequence algorithms
toSeq(): Seq.Keyed<keyof T, T[keyof T]>;
[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
}
}
export function Record<T>(defaultValues: T, name?: string): Record.Class<T>;
export module Seq {
function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed<any> | Seq.Keyed<any, any>;
function of<T>(...values: Array<T>): Seq.Indexed<T>;
export module Keyed {}
export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
export function Keyed<K, V>(): Seq.Keyed<K, V>;
export function Keyed(): Seq.Keyed<any, any>;
export interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
toJS(): Object;
toJSON(): { [key: string]: V };
toSeq(): this;
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Seq.Keyed<K | KC, V | VC>;
concat<C>(...collections: Array<{[key: string]: C}>): Seq.Keyed<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq.Keyed<any, any>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
module Indexed {
function of<T>(...values: Array<T>): Seq.Indexed<T>;
}
export function Indexed(): Seq.Indexed<any>;
export function Indexed<T>(): Seq.Indexed<T>;
export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): this;
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Indexed<T | C>;
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Seq.Indexed<M>;
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
}
export module Set {
function of<T>(...values: Array<T>): Seq.Set<T>;
}
export function Set(): Seq.Set<any>;
export function Set<T>(): Seq.Set<T>;
export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
export interface Set<T> extends Seq<never, T>, Collection.Set<T> {
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): this;
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Set<T | C>;
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Seq.Set<M>;
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
}
}
export function Seq<S extends Seq<any, any>>(seq: S): S;
export function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
export function Seq(): Seq<any, any>;
export interface Seq<K, V> extends Collection<K, V> {
readonly size: number | undefined;
// Force evaluation
cacheResult(): this;
// Sequence algorithms
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq<K, M>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq<K, M>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
}
export module Collection {
function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
function isOrdered(maybeOrdered: any): boolean;
export module Keyed {}
export function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
export function Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
export interface Keyed<K, V> extends Collection<K, V> {
toJS(): Object;
toJSON(): { [key: string]: V };
toSeq(): Seq.Keyed<K, V>;
// Sequence functions
flip(): this;
concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Collection.Keyed<K | KC, V | VC>;
concat<C>(...collections: Array<{[key: string]: C}>): Collection.Keyed<K | string, V | C>;
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed<K, M>;
mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed<M, V>;
mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed<KM, VM>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection.Keyed<any, any>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<[K, V]>;
}
export module Indexed {}
export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
export interface Indexed<T> extends Collection<number, T> {
toJS(): Array<any>;
toJSON(): Array<T>;
// Reading values
get<NSV>(index: number, notSetValue: NSV): T | NSV;
get(index: number): T | undefined;
// Conversion to Seq
toSeq(): Seq.Indexed<T>;
fromEntrySeq(): Seq.Keyed<any, any>;
// Combination
interpose(separator: T): this;
interleave(...collections: Array<Collection<any, T>>): this;
splice(index: number, removeNum: number, ...values: Array<T>): this;
zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): Collection.Indexed<Z>;
zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): Collection.Indexed<Z>;
zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): Collection.Indexed<Z>;
// Search for value
indexOf(searchValue: T): number;
lastIndexOf(searchValue: T): number;
findIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Indexed<T | C>;
map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed<M>;
flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Collection.Indexed<M>;
filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed<F>;
filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<T>;
}
export module Set {}
export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
export interface Set<T> extends Collection<never, T> {
toJS(): Array<any>;
toJSON(): Array<T>;
toSeq(): Seq.Set<T>;
// Sequence algorithms
concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Set<T | C>;
map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set<M>;
flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Collection.Set<M>;
filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set<F>;
filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
[Symbol.iterator](): IterableIterator<T>;
}
}
export function Collection<I extends Collection<any, any>>(collection: I): I;
export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
export function Collection<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
export interface Collection<K, V> extends ValueObject {
// Value equality
equals(other: any): boolean;
hashCode(): number;
// Reading values
get<NSV>(key: K, notSetValue: NSV): V | NSV;
get(key: K): V | undefined;
has(key: K): boolean;
includes(value: V): boolean;
contains(value: V): boolean;
first(): V | undefined;
last(): V | undefined;
// Reading deep values
getIn(searchKeyPath: Iterable<any>, notSetValue?: any): any;
hasIn(searchKeyPath: Iterable<any>): boolean;
// Persistent changes
update<R>(updater: (value: this) => R): R;
// Conversion to JavaScript types
toJS(): Array<any> | { [key: string]: any };
toJSON(): Array<V> | { [key: string]: V };
toArray(): Array<V>;
toObject(): { [key: string]: V };
// Conversion to Collections
toMap(): Map<K, V>;
toOrderedMap(): OrderedMap<K, V>;
toSet(): Set<V>;
toOrderedSet(): OrderedSet<V>;
toList(): List<V>;
toStack(): Stack<V>;
// Conversion to Seq
toSeq(): this;
toKeyedSeq(): Seq.Keyed<K, V>;
toIndexedSeq(): Seq.Indexed<V>;
toSetSeq(): Seq.Set<V>;
// Iterators
keys(): IterableIterator<K>;
values(): IterableIterator<V>;
entries(): IterableIterator<[K, V]>;
// Collections (Seq)
keySeq(): Seq.Indexed<K>;
valueSeq(): Seq.Indexed<V>;
entrySeq(): Seq.Indexed<[K, V]>;
// Sequence algorithms
map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection<K, M>;
filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection<K, F>;
filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
filterNot(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
reverse(): this;
sort(comparator?: (valueA: V, valueB: V) => number): this;
sortBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): this;
groupBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): /*Map*/Seq.Keyed<G, /*this*/Collection<K, V>>;
// Side effects
forEach(sideEffect: (value: V, key: K, iter: this) => any, context?: any): number;
// Creating subsets
slice(begin?: number, end?: number): this;
rest(): this;
butLast(): this;
skip(amount: number): this;
skipLast(amount: number): this;
skipWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
skipUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
take(amount: number): this;
takeLast(amount: number): this;
takeWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
takeUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
// Combination
concat(...valuesOrCollections: Array<any>): Collection<any, any>;
flatten(depth?: number): Collection<any, any>;
flatten(shallow?: boolean): Collection<any, any>;
flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection<K, M>;
// Reducing a value
reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
reduceRight<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
reduceRight<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
every(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
some(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
join(separator?: string): string;
isEmpty(): boolean;
count(): number;
count(predicate: (value: V, key: K, iter: this) => boolean, context?: any): number;
countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G, number>;
// Search for value
find(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
findLast(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
findEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
findLastEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
findKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
findLastKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
keyOf(searchValue: V): K | undefined;
lastKeyOf(searchValue: V): K | undefined;
max(comparator?: (valueA: V, valueB: V) => number): V | undefined;
maxBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
min(comparator?: (valueA: V, valueB: V) => number): V | undefined;
minBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
// Comparison
isSubset(iter: Iterable<V>): boolean;
isSuperset(iter: Iterable<V>): boolean;
readonly size: number;
}
}
declare module "immutable" {
export = Immutable
}
@@ -0,0 +1,8 @@
async function func() {
if (true) {
continue;
}
else {
await 1;
}
}
@@ -0,0 +1,10 @@
const obj = {};
const a = {
...obj,
prop() {
return {
...obj,
metadata: 213
};
}
};
@@ -0,0 +1,17 @@
// @module: commonjs
// @filename abc.ts
export declare let a: {
__foo: 10,
}
a.___foo
// @filename def.ts
export let b: {
__foo: number
}
b = {
___foo: 100,
}
@@ -0,0 +1,29 @@
// @jsx: preserve
// @filename: index.tsx
namespace JSX {
export interface Element {}
}
type Props<T> = PropsBase<string> | PropsWithConvert<T>;
interface PropsBase<T> {
data: T;
}
interface PropsWithConvert<T> extends PropsBase<T> {
convert: (t: T) => string;
}
function ShouldInferFromData<T>(props: Props<T>): JSX.Element {
return <div />;
}
// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
ShouldInferFromData({ data: "1", convert: n => "" + n });
ShouldInferFromData({ data: 2, convert: n => "" + n });
const f1 = <ShouldInferFromData data={"1"} />;
const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />;
const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
@@ -0,0 +1,6 @@
// @Filename:test.js
// @checkJs: true
// @allowJs: true
// @noEmit: true
/** @type {Array<?number>} */
var nns;