Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/28297-make-error-message-at--a-constant-or-a-read-only-property--more-specific

This commit is contained in:
Alexander T committed 2018-11-07 10:05:34 +02:00
commit 5bd0051daa
390 files changed
+13594 -6396

No files matched your search

+7 -1
View File
@@ -2418,7 +2418,7 @@ namespace ts {
const flags = exportAssignmentIsAlias(node)
? SymbolFlags.Alias // An export= with an EntityNameExpression or a ClassExpression exports all meanings of that identifier or class
: SymbolFlags.Property | SymbolFlags.ExportValue | SymbolFlags.ValueModule;
declareSymbol(file.symbol.exports!, file.symbol, node, flags, SymbolFlags.None);
declareSymbol(file.symbol.exports!, file.symbol, node, flags | SymbolFlags.Assignment, SymbolFlags.None);
}
function bindThisPropertyAssignment(node: BinaryExpression | PropertyAccessExpression) {
@@ -3702,6 +3702,10 @@ namespace ts {
}
break;
case SyntaxKind.BigIntLiteral:
transformFlags |= TransformFlags.AssertESNext;
break;
case SyntaxKind.ForOfStatement:
// This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of).
if ((<ForOfStatement>node).awaitModifier) {
@@ -3718,6 +3722,7 @@ namespace ts {
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.NeverKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.StringKeyword:
@@ -3926,6 +3931,7 @@ namespace ts {
return TransformFlags.MethodOrAccessorExcludes;
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.NeverKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.ObjectKeyword:
+29 -1
View File
@@ -225,7 +225,35 @@ namespace ts {
*/
function removeSemanticDiagnosticsOfFilesReferencingPath(state: BuilderProgramState, referencedPath: Path) {
return forEachEntry(state.referencedMap!, (referencesInFile, filePath) =>
referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath as Path)
referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath as Path)
);
}
/**
* Removes semantic diagnostics of file and anything that exports this file
*/
function removeSemanticDiagnosticsOfFileAndExportsOfFile(state: BuilderProgramState, filePath: Path): boolean {
if (removeSemanticDiagnosticsOf(state, filePath)) {
// If there are no more diagnostics from old cache, done
return true;
}
Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
// Go through exported modules from cache first
// If exported modules has path, all files referencing file exported from are affected
if (forEachEntry(state.currentAffectedFilesExportedModulesMap!, (exportedModules, exportedFromPath) =>
exportedModules &&
exportedModules.has(filePath) &&
removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath as Path)
)) {
return true;
}
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
return !!forEachEntry(state.exportedModulesMap!, (exportedModules, exportedFromPath) =>
!state.currentAffectedFilesExportedModulesMap!.has(exportedFromPath) && // If we already iterated this through cache, ignore it
exportedModules.has(filePath) &&
removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath as Path)
);
}
+379 -160
View File
File diff suppressed because it is too large. Load diff
+8 -1
View File
@@ -44,7 +44,8 @@ namespace ts {
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.symbol", "lib.esnext.symbol.d.ts"],
["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"]
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.bigint", "lib.esnext.bigint.d.ts"]
];
/**
@@ -583,6 +584,12 @@ namespace ts {
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "experimentalBigInt",
type: "boolean",
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_ESNext_BigInt_literals
},
// Advanced
{
+27 -3
View File
@@ -1011,6 +1011,10 @@
"category": "Message",
"code": 1350
},
"Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.": {
"category": "Error",
"code": 1351
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@@ -1236,7 +1240,7 @@
"category": "Error",
"code": 2355
},
"An arithmetic operand must be of type 'any', 'number' or an enum type.": {
"An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.": {
"category": "Error",
"code": 2356
},
@@ -1260,11 +1264,11 @@
"category": "Error",
"code": 2361
},
"The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": {
"The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.": {
"category": "Error",
"code": 2362
},
"The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": {
"The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.": {
"category": "Error",
"code": 2363
},
@@ -2497,6 +2501,22 @@
"category": "Error",
"code": 2734
},
"Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?": {
"category": "Error",
"code": 2735
},
"Operator '{0}' cannot be applied to type '{1}'.": {
"category": "Error",
"code": 2736
},
"BigInt literals are not available when targetting lower than ESNext.": {
"category": "Error",
"code": 2737
},
"An outer value of 'this' is shadowed by this container.": {
"category": "Message",
"code": 2738
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -3905,6 +3925,10 @@
"category": "Error",
"code": 6370
},
"Enables experimental support for ESNext BigInt literals.": {
"category": "Message",
"code": 6371
},
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
"category": "Message",
+4 -2
View File
@@ -905,7 +905,8 @@ namespace ts {
switch (node.kind) {
// Literals
case SyntaxKind.NumericLiteral:
return emitNumericLiteral(<NumericLiteral>node);
case SyntaxKind.BigIntLiteral:
return emitNumericOrBigIntLiteral(<NumericLiteral | BigIntLiteral>node);
case SyntaxKind.StringLiteral:
case SyntaxKind.RegularExpressionLiteral:
@@ -1068,7 +1069,8 @@ namespace ts {
//
// SyntaxKind.NumericLiteral
function emitNumericLiteral(node: NumericLiteral) {
// SyntaxKind.BigIntLiteral
function emitNumericOrBigIntLiteral(node: NumericLiteral | BigIntLiteral) {
emitLiteral(node);
}
+13 -4
View File
@@ -68,13 +68,16 @@ namespace ts {
/* @internal */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral; // tslint:disable-line unified-signatures
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral;
export function createLiteral(value: number): NumericLiteral;
export function createLiteral(value: number | PseudoBigInt): NumericLiteral;
export function createLiteral(value: boolean): BooleanLiteral;
export function createLiteral(value: string | number | boolean): PrimaryExpression;
export function createLiteral(value: string | number | boolean | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote?: boolean): PrimaryExpression {
export function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression;
export function createLiteral(value: string | number | PseudoBigInt | boolean | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote?: boolean): PrimaryExpression {
if (typeof value === "number") {
return createNumericLiteral(value + "");
}
if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt
return createBigIntLiteral(pseudoBigIntToString(value) + "n");
}
if (typeof value === "boolean") {
return value ? createTrue() : createFalse();
}
@@ -93,6 +96,12 @@ namespace ts {
return node;
}
export function createBigIntLiteral(value: string): BigIntLiteral {
const node = <BigIntLiteral>createSynthesizedNode(SyntaxKind.BigIntLiteral);
node.text = value;
return node;
}
export function createStringLiteral(text: string): StringLiteral {
const node = <StringLiteral>createSynthesizedNode(SyntaxKind.StringLiteral);
node.text = text;
@@ -2216,7 +2225,6 @@ namespace ts {
/* @internal */
function createJSDocTag<T extends JSDocTag>(kind: T["kind"], tagName: string): T {
const node = createSynthesizedNode(kind) as T;
node.atToken = createToken(SyntaxKind.AtToken);
node.tagName = createIdentifier(tagName);
return node;
}
@@ -3467,6 +3475,7 @@ namespace ts {
return cacheIdentifiers;
case SyntaxKind.ThisKeyword:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
return false;
case SyntaxKind.ArrayLiteralExpression:
+52 -61
View File
@@ -2247,8 +2247,7 @@ namespace ts {
function parseLiteralLikeNode(kind: SyntaxKind): LiteralExpression | LiteralLikeNode {
const node = <LiteralExpression>createNode(kind);
const text = scanner.getTokenValue();
node.text = text;
node.text = scanner.getTokenValue();
if (scanner.hasExtendedUnicodeEscape()) {
node.hasExtendedUnicodeEscape = true;
@@ -2892,8 +2891,9 @@ namespace ts {
return finishNode(node);
}
function nextTokenIsNumericLiteral() {
return nextToken() === SyntaxKind.NumericLiteral;
function nextTokenIsNumericOrBigIntLiteral() {
nextToken();
return token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.BigIntLiteral;
}
function parseNonArrayType(): TypeNode {
@@ -2902,6 +2902,7 @@ namespace ts {
case SyntaxKind.UnknownKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.UndefinedKeyword:
@@ -2922,11 +2923,12 @@ namespace ts {
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
return parseLiteralTypeNode();
case SyntaxKind.MinusToken:
return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference();
return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference();
case SyntaxKind.VoidKeyword:
case SyntaxKind.NullKeyword:
return parseTokenNode<TypeNode>();
@@ -2960,6 +2962,7 @@ namespace ts {
case SyntaxKind.UnknownKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.UniqueKeyword:
@@ -2977,6 +2980,7 @@ namespace ts {
case SyntaxKind.NewKeyword:
case SyntaxKind.StringLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.ObjectKeyword:
@@ -2990,7 +2994,7 @@ namespace ts {
case SyntaxKind.FunctionKeyword:
return !inStartOfParameter;
case SyntaxKind.MinusToken:
return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral);
return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
case SyntaxKind.OpenParenToken:
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
// or something that starts a type. We don't want to consider things like '(1)' a type.
@@ -3215,6 +3219,7 @@ namespace ts {
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.TemplateHead:
@@ -4624,6 +4629,7 @@ namespace ts {
function parsePrimaryExpression(): PrimaryExpression {
switch (token()) {
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
return parseLiteralNode();
@@ -5139,7 +5145,7 @@ namespace ts {
function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
nextToken();
return (tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.StringLiteral) && !scanner.hasPrecedingLineBreak();
return (tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.BigIntLiteral || token() === SyntaxKind.StringLiteral) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration(): boolean {
@@ -6542,8 +6548,7 @@ namespace ts {
function parseTag(indent: number) {
Debug.assert(token() === SyntaxKind.AtToken);
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getTokenPos());
atToken.end = scanner.getTextPos();
const start = scanner.getTokenPos();
nextJSDocToken();
const tagName = parseJSDocIdentifierName(/*message*/ undefined);
@@ -6553,40 +6558,40 @@ namespace ts {
switch (tagName.escapedText) {
case "augments":
case "extends":
tag = parseAugmentsTag(atToken, tagName);
tag = parseAugmentsTag(start, tagName);
break;
case "class":
case "constructor":
tag = parseClassTag(atToken, tagName);
tag = parseClassTag(start, tagName);
break;
case "this":
tag = parseThisTag(atToken, tagName);
tag = parseThisTag(start, tagName);
break;
case "enum":
tag = parseEnumTag(atToken, tagName);
tag = parseEnumTag(start, tagName);
break;
case "arg":
case "argument":
case "param":
return parseParameterOrPropertyTag(atToken, tagName, PropertyLikeParse.Parameter, indent);
return parseParameterOrPropertyTag(start, tagName, PropertyLikeParse.Parameter, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
tag = parseReturnTag(start, tagName);
break;
case "template":
tag = parseTemplateTag(atToken, tagName);
tag = parseTemplateTag(start, tagName);
break;
case "type":
tag = parseTypeTag(atToken, tagName);
tag = parseTypeTag(start, tagName);
break;
case "typedef":
tag = parseTypedefTag(atToken, tagName, indent);
tag = parseTypedefTag(start, tagName, indent);
break;
case "callback":
tag = parseCallbackTag(atToken, tagName, indent);
tag = parseCallbackTag(start, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
tag = parseUnknownTag(start, tagName);
break;
}
@@ -6669,9 +6674,8 @@ namespace ts {
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken: AtToken, tagName: Identifier) {
const result = <JSDocTag>createNode(SyntaxKind.JSDocTag, atToken.pos);
result.atToken = atToken;
function parseUnknownTag(start: number, tagName: Identifier) {
const result = <JSDocTag>createNode(SyntaxKind.JSDocTag, start);
result.tagName = tagName;
return finishNode(result);
}
@@ -6728,7 +6732,7 @@ namespace ts {
}
}
function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, target: PropertyLikeParse, indent: number): JSDocParameterTag | JSDocPropertyTag {
function parseParameterOrPropertyTag(start: number, tagName: Identifier, target: PropertyLikeParse, indent: number): JSDocParameterTag | JSDocPropertyTag {
let typeExpression = tryParseTypeExpression();
let isNameFirst = !typeExpression;
skipWhitespaceOrAsterisk();
@@ -6741,15 +6745,14 @@ namespace ts {
}
const result = target === PropertyLikeParse.Property ?
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos) :
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos);
const comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, start) :
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, start);
const comment = parseTagComments(indent + scanner.getStartPos() - start);
const nestedTypeLiteral = target !== PropertyLikeParse.CallbackParameter && parseNestedTypeLiteral(typeExpression, name, target, indent);
if (nestedTypeLiteral) {
typeExpression = nestedTypeLiteral;
isNameFirst = true;
}
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = typeExpression;
result.name = name;
@@ -6783,33 +6786,30 @@ namespace ts {
}
}
function parseReturnTag(atToken: AtToken, tagName: Identifier): JSDocReturnTag {
function parseReturnTag(start: number, tagName: Identifier): JSDocReturnTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
}
const result = <JSDocReturnTag>createNode(SyntaxKind.JSDocReturnTag, atToken.pos);
result.atToken = atToken;
const result = <JSDocReturnTag>createNode(SyntaxKind.JSDocReturnTag, start);
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken: AtToken, tagName: Identifier): JSDocTypeTag {
function parseTypeTag(start: number, tagName: Identifier): JSDocTypeTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
}
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
result.atToken = atToken;
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, start);
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
return finishNode(result);
}
function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag {
const result = <JSDocAugmentsTag>createNode(SyntaxKind.JSDocAugmentsTag, atToken.pos);
result.atToken = atToken;
function parseAugmentsTag(start: number, tagName: Identifier): JSDocAugmentsTag {
const result = <JSDocAugmentsTag>createNode(SyntaxKind.JSDocAugmentsTag, start);
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
return finishNode(result);
@@ -6838,37 +6838,33 @@ namespace ts {
return node;
}
function parseClassTag(atToken: AtToken, tagName: Identifier): JSDocClassTag {
const tag = <JSDocClassTag>createNode(SyntaxKind.JSDocClassTag, atToken.pos);
tag.atToken = atToken;
function parseClassTag(start: number, tagName: Identifier): JSDocClassTag {
const tag = <JSDocClassTag>createNode(SyntaxKind.JSDocClassTag, start);
tag.tagName = tagName;
return finishNode(tag);
}
function parseThisTag(atToken: AtToken, tagName: Identifier): JSDocThisTag {
const tag = <JSDocThisTag>createNode(SyntaxKind.JSDocThisTag, atToken.pos);
tag.atToken = atToken;
function parseThisTag(start: number, tagName: Identifier): JSDocThisTag {
const tag = <JSDocThisTag>createNode(SyntaxKind.JSDocThisTag, start);
tag.tagName = tagName;
tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
skipWhitespace();
return finishNode(tag);
}
function parseEnumTag(atToken: AtToken, tagName: Identifier): JSDocEnumTag {
const tag = <JSDocEnumTag>createNode(SyntaxKind.JSDocEnumTag, atToken.pos);
tag.atToken = atToken;
function parseEnumTag(start: number, tagName: Identifier): JSDocEnumTag {
const tag = <JSDocEnumTag>createNode(SyntaxKind.JSDocEnumTag, start);
tag.tagName = tagName;
tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
skipWhitespace();
return finishNode(tag);
}
function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag {
function parseTypedefTag(start: number, tagName: Identifier, indent: number): JSDocTypedefTag {
const typeExpression = tryParseTypeExpression();
skipWhitespaceOrAsterisk();
const typedefTag = <JSDocTypedefTag>createNode(SyntaxKind.JSDocTypedefTag, atToken.pos);
typedefTag.atToken = atToken;
const typedefTag = <JSDocTypedefTag>createNode(SyntaxKind.JSDocTypedefTag, start);
typedefTag.tagName = tagName;
typedefTag.fullName = parseJSDocTypeNameWithNamespace();
typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
@@ -6881,7 +6877,6 @@ namespace ts {
let child: JSDocTypeTag | JSDocPropertyTag | false;
let jsdocTypeLiteral: JSDocTypeLiteral | undefined;
let childTypeTag: JSDocTypeTag | undefined;
const start = atToken.pos;
while (child = tryParse(() => parseChildPropertyTag(indent))) {
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = <JSDocTypeLiteral>createNode(SyntaxKind.JSDocTypeLiteral, start);
@@ -6935,9 +6930,8 @@ namespace ts {
return typeNameOrNamespaceName;
}
function parseCallbackTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocCallbackTag {
const callbackTag = createNode(SyntaxKind.JSDocCallbackTag, atToken.pos) as JSDocCallbackTag;
callbackTag.atToken = atToken;
function parseCallbackTag(start: number, tagName: Identifier, indent: number): JSDocCallbackTag {
const callbackTag = createNode(SyntaxKind.JSDocCallbackTag, start) as JSDocCallbackTag;
callbackTag.tagName = tagName;
callbackTag.fullName = parseJSDocTypeNameWithNamespace();
callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
@@ -6945,7 +6939,6 @@ namespace ts {
callbackTag.comment = parseTagComments(indent);
let child: JSDocParameterTag | false;
const start = scanner.getStartPos();
const jsdocSignature = createNode(SyntaxKind.JSDocSignature, start) as JSDocSignature;
jsdocSignature.parameters = [];
while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.CallbackParameter, indent) as JSDocParameterTag)) {
@@ -7033,8 +7026,7 @@ namespace ts {
function tryParseChildTag(target: PropertyLikeParse, indent: number): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false {
Debug.assert(token() === SyntaxKind.AtToken);
const atToken = <AtToken>createNode(SyntaxKind.AtToken);
atToken.end = scanner.getTextPos();
const start = scanner.getStartPos();
nextJSDocToken();
const tagName = parseJSDocIdentifierName();
@@ -7042,7 +7034,7 @@ namespace ts {
let t: PropertyLikeParse;
switch (tagName.escapedText) {
case "type":
return target === PropertyLikeParse.Property && parseTypeTag(atToken, tagName);
return target === PropertyLikeParse.Property && parseTypeTag(start, tagName);
case "prop":
case "property":
t = PropertyLikeParse.Property;
@@ -7058,10 +7050,10 @@ namespace ts {
if (!(target & t)) {
return false;
}
return parseParameterOrPropertyTag(atToken, tagName, target, indent);
return parseParameterOrPropertyTag(start, tagName, target, indent);
}
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag {
function parseTemplateTag(start: number, tagName: Identifier): JSDocTemplateTag {
// the template tag looks like '@template {Constraint} T,U,V'
let constraint: JSDocTypeExpression | undefined;
if (token() === SyntaxKind.OpenBraceToken) {
@@ -7079,8 +7071,7 @@ namespace ts {
typeParameters.push(typeParameter);
} while (parseOptionalJsdoc(SyntaxKind.CommaToken));
const result = <JSDocTemplateTag>createNode(SyntaxKind.JSDocTemplateTag, atToken.pos);
result.atToken = atToken;
const result = <JSDocTemplateTag>createNode(SyntaxKind.JSDocTemplateTag, start);
result.tagName = tagName;
result.constraint = constraint;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
+79 -58
View File
@@ -64,6 +64,7 @@ namespace ts {
abstract: SyntaxKind.AbstractKeyword,
any: SyntaxKind.AnyKeyword,
as: SyntaxKind.AsKeyword,
bigint: SyntaxKind.BigIntKeyword,
boolean: SyntaxKind.BooleanKeyword,
break: SyntaxKind.BreakKeyword,
case: SyntaxKind.CaseKeyword,
@@ -919,7 +920,7 @@ namespace ts {
return result + text.substring(start, pos);
}
function scanNumber(): string {
function scanNumber(): {type: SyntaxKind, value: string} {
const start = pos;
const mainFragment = scanNumberFragment();
let decimalFragment: string | undefined;
@@ -943,18 +944,29 @@ namespace ts {
end = pos;
}
}
let result: string;
if (tokenFlags & TokenFlags.ContainsSeparator) {
let result = mainFragment;
result = mainFragment;
if (decimalFragment) {
result += "." + decimalFragment;
}
if (scientificFragment) {
result += scientificFragment;
}
return "" + +result;
}
else {
return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed
result = text.substring(start, end); // No need to use all the fragments; no _ removal needed
}
if (decimalFragment !== undefined || tokenFlags & TokenFlags.Scientific) {
return {
type: SyntaxKind.NumericLiteral,
value: "" + +result // if value is not an integer, it can be safely coerced to a number
};
}
else {
tokenValue = result;
const type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint
return { type, value: tokenValue };
}
}
@@ -971,24 +983,24 @@ namespace ts {
* returning -1 if the given number is unavailable.
*/
function scanExactNumberOfHexDigits(count: number, canHaveSeparators: boolean): number {
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators);
const valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators);
return valueString ? parseInt(valueString, 16) : -1;
}
/**
* Scans as many hexadecimal digits as are available in the text,
* returning -1 if the given number of digits was unavailable.
* returning "" if the given number of digits was unavailable.
*/
function scanMinimumNumberOfHexDigits(count: number, canHaveSeparators: boolean): number {
function scanMinimumNumberOfHexDigits(count: number, canHaveSeparators: boolean): string {
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators);
}
function scanHexDigits(minCount: number, scanAsManyAsPossible: boolean, canHaveSeparators: boolean): number {
let digits = 0;
let value = 0;
function scanHexDigits(minCount: number, scanAsManyAsPossible: boolean, canHaveSeparators: boolean): string {
let valueChars: number[] = [];
let allowSeparator = false;
let isPreviousTokenSeparator = false;
while (digits < minCount || scanAsManyAsPossible) {
const ch = text.charCodeAt(pos);
while (valueChars.length < minCount || scanAsManyAsPossible) {
let ch = text.charCodeAt(pos);
if (canHaveSeparators && ch === CharacterCodes._) {
tokenFlags |= TokenFlags.ContainsSeparator;
if (allowSeparator) {
@@ -1005,29 +1017,25 @@ namespace ts {
continue;
}
allowSeparator = canHaveSeparators;
if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) {
value = value * 16 + ch - CharacterCodes._0;
if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {
ch += CharacterCodes.a - CharacterCodes.A; // standardize hex literals to lowercase
}
else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {
value = value * 16 + ch - CharacterCodes.A + 10;
}
else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) {
value = value * 16 + ch - CharacterCodes.a + 10;
}
else {
else if (!((ch >= CharacterCodes._0 && ch <= CharacterCodes._9) ||
(ch >= CharacterCodes.a && ch <= CharacterCodes.f)
)) {
break;
}
valueChars.push(ch);
pos++;
digits++;
isPreviousTokenSeparator = false;
}
if (digits < minCount) {
value = -1;
if (valueChars.length < minCount) {
valueChars = [];
}
if (text.charCodeAt(pos - 1) === CharacterCodes._) {
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
}
return value;
return String.fromCharCode(...valueChars);
}
function scanString(jsxAttributeString = false): string {
@@ -1207,7 +1215,8 @@ namespace ts {
}
function scanExtendedUnicodeEscape(): string {
const escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
const escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
let isInvalidExtendedEscape = false;
// Validate the value of the digit
@@ -1309,13 +1318,10 @@ namespace ts {
return token = SyntaxKind.Identifier;
}
function scanBinaryOrOctalDigits(base: number): number {
Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8");
let value = 0;
function scanBinaryOrOctalDigits(base: 2 | 8): string {
let value = "";
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
// Similarly valid octalIntegerLiteral must have at least one octal digit following o or O.
let numberOfDigits = 0;
let separatorAllowed = false;
let isPreviousTokenSeparator = false;
while (true) {
@@ -1337,27 +1343,42 @@ namespace ts {
continue;
}
separatorAllowed = true;
const valueOfCh = ch - CharacterCodes._0;
if (!isDigit(ch) || valueOfCh >= base) {
if (!isDigit(ch) || ch - CharacterCodes._0 >= base) {
break;
}
value = value * base + valueOfCh;
value += text[pos];
pos++;
numberOfDigits++;
isPreviousTokenSeparator = false;
}
// Invalid binaryIntegerLiteral or octalIntegerLiteral
if (numberOfDigits === 0) {
return -1;
}
if (text.charCodeAt(pos - 1) === CharacterCodes._) {
// Literal ends with underscore - not allowed
error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
return value;
}
return value;
}
function checkBigIntSuffix(): SyntaxKind {
if (text.charCodeAt(pos) === CharacterCodes.n) {
tokenValue += "n";
// Use base 10 instead of base 2 or base 8 for shorter literals
if (tokenFlags & TokenFlags.BinaryOrOctalSpecifier) {
tokenValue = parsePseudoBigInt(tokenValue) + "n";
}
pos++;
return SyntaxKind.BigIntLiteral;
}
else { // not a bigint, so can convert to number in simplified form
// Number() may not support 0b or 0o, so use parseInt() instead
const numericValue = tokenFlags & TokenFlags.BinarySpecifier
? parseInt(tokenValue.slice(2), 2) // skip "0b"
: tokenFlags & TokenFlags.OctalSpecifier
? parseInt(tokenValue.slice(2), 8) // skip "0o"
: +tokenValue;
tokenValue = "" + numericValue;
return SyntaxKind.NumericLiteral;
}
}
function scan(): SyntaxKind {
startPos = pos;
tokenFlags = 0;
@@ -1506,7 +1527,7 @@ namespace ts {
return token = SyntaxKind.MinusToken;
case CharacterCodes.dot:
if (isDigit(text.charCodeAt(pos + 1))) {
tokenValue = scanNumber();
tokenValue = scanNumber().value;
return token = SyntaxKind.NumericLiteral;
}
if (text.charCodeAt(pos + 1) === CharacterCodes.dot && text.charCodeAt(pos + 2) === CharacterCodes.dot) {
@@ -1582,36 +1603,36 @@ namespace ts {
case CharacterCodes._0:
if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.X || text.charCodeAt(pos + 1) === CharacterCodes.x)) {
pos += 2;
let value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
if (value < 0) {
tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
if (!tokenValue) {
error(Diagnostics.Hexadecimal_digit_expected);
value = 0;
tokenValue = "0";
}
tokenValue = "" + value;
tokenValue = "0x" + tokenValue;
tokenFlags |= TokenFlags.HexSpecifier;
return token = SyntaxKind.NumericLiteral;
return token = checkBigIntSuffix();
}
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.B || text.charCodeAt(pos + 1) === CharacterCodes.b)) {
pos += 2;
let value = scanBinaryOrOctalDigits(/* base */ 2);
if (value < 0) {
tokenValue = scanBinaryOrOctalDigits(/* base */ 2);
if (!tokenValue) {
error(Diagnostics.Binary_digit_expected);
value = 0;
tokenValue = "0";
}
tokenValue = "" + value;
tokenValue = "0b" + tokenValue;
tokenFlags |= TokenFlags.BinarySpecifier;
return token = SyntaxKind.NumericLiteral;
return token = checkBigIntSuffix();
}
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.O || text.charCodeAt(pos + 1) === CharacterCodes.o)) {
pos += 2;
let value = scanBinaryOrOctalDigits(/* base */ 8);
if (value < 0) {
tokenValue = scanBinaryOrOctalDigits(/* base */ 8);
if (!tokenValue) {
error(Diagnostics.Octal_digit_expected);
value = 0;
tokenValue = "0";
}
tokenValue = "" + value;
tokenValue = "0o" + tokenValue;
tokenFlags |= TokenFlags.OctalSpecifier;
return token = SyntaxKind.NumericLiteral;
return token = checkBigIntSuffix();
}
// Try to parse as an octal
if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
@@ -1632,8 +1653,8 @@ namespace ts {
case CharacterCodes._7:
case CharacterCodes._8:
case CharacterCodes._9:
tokenValue = scanNumber();
return token = SyntaxKind.NumericLiteral;
({ type: token, value: tokenValue } = scanNumber());
return token;
case CharacterCodes.colon:
pos++;
return token = SyntaxKind.ColonToken;
+23
View File
@@ -1901,6 +1901,9 @@ namespace ts {
case SyntaxKind.NumericLiteral:
return createIdentifier("Number");
case SyntaxKind.BigIntLiteral:
return getGlobalBigIntNameWithFallback();
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
return createIdentifier("Boolean");
@@ -1912,6 +1915,9 @@ namespace ts {
case SyntaxKind.NumberKeyword:
return createIdentifier("Number");
case SyntaxKind.BigIntKeyword:
return getGlobalBigIntNameWithFallback();
case SyntaxKind.SymbolKeyword:
return languageVersion < ScriptTarget.ES2015
? getGlobalSymbolNameWithFallback()
@@ -2006,6 +2012,9 @@ namespace ts {
case TypeReferenceSerializationKind.VoidNullableOrNeverType:
return createVoidZero();
case TypeReferenceSerializationKind.BigIntLikeType:
return getGlobalBigIntNameWithFallback();
case TypeReferenceSerializationKind.BooleanType:
return createIdentifier("Boolean");
@@ -2115,6 +2124,20 @@ namespace ts {
);
}
/**
* Gets an expression that points to the global "BigInt" constructor at runtime if it is
* available.
*/
function getGlobalBigIntNameWithFallback(): SerializedTypeNode {
return languageVersion < ScriptTarget.ESNext
? createConditional(
createTypeCheck(createIdentifier("BigInt"), "function"),
createIdentifier("BigInt"),
createIdentifier("Object")
)
: createIdentifier("BigInt");
}
/**
* A simple inlinable expression is an expression which can be copied into multiple locations
* without risk of repeating any sideeffects and whose value could not possibly change between
+61 -37
View File
@@ -31,6 +31,7 @@ namespace ts {
| SyntaxKind.AbstractKeyword
| SyntaxKind.AnyKeyword
| SyntaxKind.AsKeyword
| SyntaxKind.BigIntKeyword
| SyntaxKind.BooleanKeyword
| SyntaxKind.BreakKeyword
| SyntaxKind.CaseKeyword
@@ -128,6 +129,7 @@ namespace ts {
ConflictMarkerTrivia,
// Literals
NumericLiteral,
BigIntLiteral,
StringLiteral,
JsxText,
JsxTextAllWhiteSpaces,
@@ -271,6 +273,7 @@ namespace ts {
UnknownKeyword,
FromKeyword,
GlobalKeyword,
BigIntKeyword,
OfKeyword, // LastKeyword and LastToken and LastContextualKeyword
// Parse tree nodes
@@ -716,7 +719,6 @@ namespace ts {
export type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
export type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
export type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
export type AtToken = Token<SyntaxKind.AtToken>;
export type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
export type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
export type PlusToken = Token<SyntaxKind.PlusToken>;
@@ -1109,6 +1111,7 @@ namespace ts {
kind: SyntaxKind.AnyKeyword
| SyntaxKind.UnknownKeyword
| SyntaxKind.NumberKeyword
| SyntaxKind.BigIntKeyword
| SyntaxKind.ObjectKeyword
| SyntaxKind.BooleanKeyword
| SyntaxKind.StringKeyword
@@ -1659,7 +1662,7 @@ namespace ts {
OctalSpecifier = 1 << 8, // e.g. `0o777`
ContainsSeparator = 1 << 9, // e.g. `0b1100_0101`
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinarySpecifier | OctalSpecifier | ContainsSeparator
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator
}
export interface NumericLiteral extends LiteralExpression {
@@ -1668,6 +1671,10 @@ namespace ts {
numericLiteralFlags: TokenFlags;
}
export interface BigIntLiteral extends LiteralExpression {
kind: SyntaxKind.BigIntLiteral;
}
export interface TemplateHead extends LiteralLikeNode {
kind: SyntaxKind.TemplateHead;
parent: TemplateExpression;
@@ -2413,7 +2420,6 @@ namespace ts {
export interface JSDocTag extends Node {
parent: JSDoc | JSDocTypeLiteral;
atToken: AtToken;
tagName: Identifier;
comment?: string;
}
@@ -3173,6 +3179,8 @@ namespace ts {
/* @internal */ getTypeCount(): number;
/* @internal */ isArrayLikeType(type: Type): boolean;
/* @internal */ getObjectFlags(type: Type): ObjectFlags;
/**
* True if `contextualType` should not be considered for completions because
* e.g. it specifies `kind: "a"` and obj has `kind: "b"`.
@@ -3459,6 +3467,7 @@ namespace ts {
// of a type, such as the global `Promise` type in lib.d.ts).
VoidNullableOrNeverType, // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type.
NumberLikeType, // The TypeReferenceNode resolves to a Number-like type.
BigIntLikeType, // The TypeReferenceNode resolves to a BigInt-like type.
StringLikeType, // The TypeReferenceNode resolves to a String-like type.
BooleanType, // The TypeReferenceNode resolves to a Boolean-like type.
ArrayLikeType, // The TypeReferenceNode resolves to an Array-like type.
@@ -3803,29 +3812,27 @@ namespace ts {
Number = 1 << 3,
Boolean = 1 << 4,
Enum = 1 << 5,
StringLiteral = 1 << 6,
NumberLiteral = 1 << 7,
BooleanLiteral = 1 << 8,
EnumLiteral = 1 << 9, // Always combined with StringLiteral, NumberLiteral, or Union
ESSymbol = 1 << 10, // Type of symbol primitive introduced in ES6
UniqueESSymbol = 1 << 11, // unique symbol
Void = 1 << 12,
Undefined = 1 << 13,
Null = 1 << 14,
Never = 1 << 15, // Never type
TypeParameter = 1 << 16, // Type parameter
Object = 1 << 17, // Object type
Union = 1 << 18, // Union (T | U)
Intersection = 1 << 19, // Intersection (T & U)
Index = 1 << 20, // keyof T
IndexedAccess = 1 << 21, // T[K]
Conditional = 1 << 22, // T extends U ? X : Y
Substitution = 1 << 23, // Type parameter substitution
NonPrimitive = 1 << 24, // intrinsic object type
/* @internal */
FreshLiteral = 1 << 25, // Fresh literal or unique type
/* @internal */
UnionOfPrimitiveTypes = 1 << 26, // Type is union of primitive types
BigInt = 1 << 6,
StringLiteral = 1 << 7,
NumberLiteral = 1 << 8,
BooleanLiteral = 1 << 9,
EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union
BigIntLiteral = 1 << 11,
ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6
UniqueESSymbol = 1 << 13, // unique symbol
Void = 1 << 14,
Undefined = 1 << 15,
Null = 1 << 16,
Never = 1 << 17, // Never type
TypeParameter = 1 << 18, // Type parameter
Object = 1 << 19, // Object type
Union = 1 << 20, // Union (T | U)
Intersection = 1 << 21, // Intersection (T & U)
Index = 1 << 22, // keyof T
IndexedAccess = 1 << 23, // T[K]
Conditional = 1 << 24, // T extends U ? X : Y
Substitution = 1 << 25, // Type parameter substitution
NonPrimitive = 1 << 26, // intrinsic object type
/* @internal */
ContainsWideningType = 1 << 27, // Type is or contains undefined or null widening type
/* @internal */
@@ -3837,26 +3844,27 @@ namespace ts {
AnyOrUnknown = Any | Unknown,
/* @internal */
Nullable = Undefined | Null,
Literal = StringLiteral | NumberLiteral | BooleanLiteral,
Literal = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral,
Unit = Literal | UniqueESSymbol | Nullable,
StringOrNumberLiteral = StringLiteral | NumberLiteral,
/* @internal */
StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol,
/* @internal */
DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null,
PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean,
DefinitelyFalsy = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral | Void | Undefined | Null,
PossiblyFalsy = DefinitelyFalsy | String | Number | BigInt | Boolean,
/* @internal */
Intrinsic = Any | Unknown | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
Intrinsic = Any | Unknown | String | Number | BigInt | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
/* @internal */
Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol,
Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol,
StringLike = String | StringLiteral,
NumberLike = Number | NumberLiteral | Enum,
BigIntLike = BigInt | BigIntLiteral,
BooleanLike = Boolean | BooleanLiteral,
EnumLike = Enum | EnumLiteral,
ESSymbolLike = ESSymbol | UniqueESSymbol,
VoidLike = Void | Undefined,
/* @internal */
DisjointDomains = NonPrimitive | StringLike | NumberLike | BooleanLike | ESSymbolLike | VoidLike | Null,
DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null,
UnionOrIntersection = Union | Intersection,
StructuredType = Object | Union | Intersection,
TypeVariable = TypeParameter | IndexedAccess,
@@ -3867,7 +3875,7 @@ namespace ts {
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
NotUnionOrUnit = Any | Unknown | ESSymbol | Object | NonPrimitive,
/* @internal */
NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | StructuredOrInstantiable,
@@ -3924,10 +3932,11 @@ namespace ts {
// String literal types (TypeFlags.StringLiteral)
// Numeric literal types (TypeFlags.NumberLiteral)
// BigInt literal types (TypeFlags.BigIntLiteral)
export interface LiteralType extends Type {
value: string | number; // Value of literal
freshType: LiteralType; // Fresh version of type
regularType: LiteralType; // Regular version of type
value: string | number | PseudoBigInt; // Value of literal
freshType: LiteralType; // Fresh version of type
regularType: LiteralType; // Regular version of type
}
// Unique symbol types (TypeFlags.UniqueESSymbol)
@@ -3943,6 +3952,10 @@ namespace ts {
value: number;
}
export interface BigIntLiteralType extends LiteralType {
value: PseudoBigInt;
}
// Enum types (TypeFlags.Enum)
export interface EnumType extends Type {
}
@@ -3963,6 +3976,7 @@ namespace ts {
JsxAttributes = 1 << 12, // Jsx attributes type
MarkerType = 1 << 13, // Marker type used for variance probing
JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members
FreshLiteral = 1 << 15, // Fresh object literal
ClassOrInterface = Class | Interface
}
@@ -4058,7 +4072,10 @@ namespace ts {
couldContainTypeVariables: boolean;
}
export interface UnionType extends UnionOrIntersectionType { }
export interface UnionType extends UnionOrIntersectionType {
/* @internal */
primitiveTypesOnly: boolean;
}
export interface IntersectionType extends UnionOrIntersectionType {
/* @internal */
@@ -4484,6 +4501,7 @@ namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/help?: boolean;
@@ -5759,4 +5777,10 @@ namespace ts {
readonly importModuleSpecifierEnding?: "minimal" | "index" | "js";
readonly allowTextChangesInNewFiles?: boolean;
}
/** Represents a bigint literal value without requiring bigint support */
export interface PseudoBigInt {
negative: boolean;
base10Value: string;
}
}
+95 -2
View File
@@ -527,7 +527,10 @@ namespace ts {
export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, neverAsciiEscape: boolean | undefined) {
// If we don't need to downlevel and we can reach the original source text using
// the node's parent reference, then simply get the text as it was originally written.
if (!nodeIsSynthesized(node) && node.parent && !(isNumericLiteral(node) && node.numericLiteralFlags & TokenFlags.ContainsSeparator)) {
if (!nodeIsSynthesized(node) && node.parent && !(
(isNumericLiteral(node) && node.numericLiteralFlags & TokenFlags.ContainsSeparator) ||
isBigIntLiteral(node)
)) {
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
}
@@ -554,6 +557,7 @@ namespace ts {
case SyntaxKind.TemplateTail:
return "}" + escapeText(node.text, CharacterCodes.backtick) + "`";
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.RegularExpressionLiteral:
return node.text;
}
@@ -976,6 +980,7 @@ namespace ts {
case SyntaxKind.AnyKeyword:
case SyntaxKind.UnknownKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
@@ -1599,6 +1604,7 @@ namespace ts {
}
// falls through
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.ThisKeyword:
return isInExpressionContext(node);
@@ -2490,6 +2496,7 @@ namespace ts {
// export { x as <symbol> } from ...
// export = <EntityNameExpression>
// export default <EntityNameExpression>
// module.exports = <EntityNameExpression>
export function isAliasSymbolDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.ImportEqualsDeclaration ||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
@@ -2498,7 +2505,7 @@ namespace ts {
node.kind === SyntaxKind.ImportSpecifier ||
node.kind === SyntaxKind.ExportSpecifier ||
node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node) ||
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports;
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node);
}
export function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean {
@@ -2585,6 +2592,10 @@ namespace ts {
return token !== undefined && isNonContextualKeyword(token);
}
export function isIdentifierANonContextualKeyword({ originalKeywordKind }: Identifier): boolean {
return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
}
export type TriviaKind = SyntaxKind.SingleLineCommentTrivia
| SyntaxKind.MultiLineCommentTrivia
| SyntaxKind.NewLineTrivia
@@ -2900,6 +2911,7 @@ namespace ts {
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.ObjectLiteralExpression:
@@ -5266,6 +5278,10 @@ namespace ts {
return node.kind === SyntaxKind.NumericLiteral;
}
export function isBigIntLiteral(node: Node): node is BigIntLiteral {
return node.kind === SyntaxKind.BigIntLiteral;
}
export function isStringLiteral(node: Node): node is StringLiteral {
return node.kind === SyntaxKind.StringLiteral;
}
@@ -6209,6 +6225,7 @@ namespace ts {
|| kind === SyntaxKind.AnyKeyword
|| kind === SyntaxKind.UnknownKeyword
|| kind === SyntaxKind.NumberKeyword
|| kind === SyntaxKind.BigIntKeyword
|| kind === SyntaxKind.ObjectKeyword
|| kind === SyntaxKind.BooleanKeyword
|| kind === SyntaxKind.StringKeyword
@@ -6391,6 +6408,7 @@ namespace ts {
case SyntaxKind.Identifier:
case SyntaxKind.RegularExpressionLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.TemplateExpression:
@@ -8422,4 +8440,79 @@ namespace ts {
return got;
}
}
/**
* Converts a bigint literal string, e.g. `0x1234n`,
* to its decimal string representation, e.g. `4660`.
*/
export function parsePseudoBigInt(stringValue: string): string {
let log2Base: number;
switch (stringValue.charCodeAt(1)) { // "x" in "0x123"
case CharacterCodes.b:
case CharacterCodes.B: // 0b or 0B
log2Base = 1;
break;
case CharacterCodes.o:
case CharacterCodes.O: // 0o or 0O
log2Base = 3;
break;
case CharacterCodes.x:
case CharacterCodes.X: // 0x or 0X
log2Base = 4;
break;
default: // already in decimal; omit trailing "n"
const nIndex = stringValue.length - 1;
// Skip leading 0s
let nonZeroStart = 0;
while (stringValue.charCodeAt(nonZeroStart) === CharacterCodes._0) {
nonZeroStart++;
}
return stringValue.slice(nonZeroStart, nIndex) || "0";
}
// Omit leading "0b", "0o", or "0x", and trailing "n"
const startIndex = 2, endIndex = stringValue.length - 1;
const bitsNeeded = (endIndex - startIndex) * log2Base;
// Stores the value specified by the string as a LE array of 16-bit integers
// using Uint16 instead of Uint32 so combining steps can use bitwise operators
const segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
// Add the digits, one at a time
for (let i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
const segment = bitOffset >>> 4;
const digitChar = stringValue.charCodeAt(i);
// Find character range: 0-9 < A-F < a-f
const digit = digitChar <= CharacterCodes._9
? digitChar - CharacterCodes._0
: 10 + digitChar -
(digitChar <= CharacterCodes.F ? CharacterCodes.A : CharacterCodes.a);
const shiftedDigit = digit << (bitOffset & 15);
segments[segment] |= shiftedDigit;
const residual = shiftedDigit >>> 16;
if (residual) segments[segment + 1] |= residual; // overflows segment
}
// Repeatedly divide segments by 10 and add remainder to base10Value
let base10Value = "";
let firstNonzeroSegment = segments.length - 1;
let segmentsRemaining = true;
while (segmentsRemaining) {
let mod10 = 0;
segmentsRemaining = false;
for (let segment = firstNonzeroSegment; segment >= 0; segment--) {
const newSegment = mod10 << 16 | segments[segment];
const segmentValue = (newSegment / 10) | 0;
segments[segment] = segmentValue;
mod10 = newSegment - segmentValue * 10;
if (segmentValue && !segmentsRemaining) {
firstNonzeroSegment = segment;
segmentsRemaining = true;
}
}
base10Value = mod10 + base10Value;
}
return base10Value;
}
export function pseudoBigIntToString({negative, base10Value}: PseudoBigInt): string {
return (negative && base10Value !== "0" ? "-" : "") + base10Value;
}
}
+284 -248
View File
@@ -787,6 +787,7 @@ namespace FourSlash {
}
if (options.excludes) {
for (const exclude of toArray(options.excludes)) {
assert(typeof exclude === "string");
if (nameToEntries.has(exclude)) {
this.raiseError(`Did not expect to get a completion named ${exclude}`);
}
@@ -812,7 +813,9 @@ namespace FourSlash {
}
if (kind !== undefined || kindModifiers !== undefined) {
assert.equal(actual.kind, kind);
if (actual.kind !== kind) {
this.raiseError(`Unexpected kind for ${actual.name}: Expected ${kind}, actual ${actual.kind}`);
}
if (actual.kindModifiers !== (kindModifiers || "")) {
this.raiseError(`Bad kind modifiers for ${actual.name}: Expected ${kindModifiers || ""}, actual ${actual.kindModifiers}`);
}
@@ -4427,110 +4430,119 @@ namespace FourSlashInterface {
}
}
export namespace Completion {
const res: string[] = [];
const functionEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "function", kindModifiers: "declare" });
const constEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "const", kindModifiers: "declare" });
const moduleEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "module", kindModifiers: "declare" });
const keywordEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "keyword" });
const methodEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "method", kindModifiers: "declare" });
const propertyEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "property", kindModifiers: "declare" });
const interfaceEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "interface", kindModifiers: "declare" });
const typeEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "type", kindModifiers: "declare" });
const res: ExpectedCompletionEntryObject[] = [];
for (let i = ts.SyntaxKind.FirstKeyword; i <= ts.SyntaxKind.LastKeyword; i++) {
res.push(ts.Debug.assertDefined(ts.tokenToString(i)));
res.push({ name: ts.Debug.assertDefined(ts.tokenToString(i)), kind: "keyword" });
}
export const keywordsWithUndefined: ReadonlyArray<string> = res;
export const keywords: ReadonlyArray<string> = keywordsWithUndefined.filter(k => k !== "undefined");
export const keywordsWithUndefined: ReadonlyArray<ExpectedCompletionEntryObject> = res;
export const keywords: ReadonlyArray<ExpectedCompletionEntryObject> = keywordsWithUndefined.filter(k => k.name !== "undefined");
export const typeKeywords: ReadonlyArray<string> =
["false", "null", "true", "void", "any", "boolean", "keyof", "never", "number", "object", "string", "symbol", "undefined", "unique", "unknown"];
export const typeKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
["false", "null", "true", "void", "any", "boolean", "keyof", "never", "number", "object", "string", "symbol", "undefined", "unique", "unknown"].map(keywordEntry);
const globalTypeDecls = [
"Symbol",
"PropertyKey",
"PropertyDescriptor",
"PropertyDescriptorMap",
"Object",
"ObjectConstructor",
"Function",
"FunctionConstructor",
"CallableFunction",
"NewableFunction",
"IArguments",
"String",
"StringConstructor",
"Boolean",
"BooleanConstructor",
"Number",
"NumberConstructor",
"TemplateStringsArray",
"ImportMeta",
"Math",
"Date",
"DateConstructor",
"RegExpMatchArray",
"RegExpExecArray",
"RegExp",
"RegExpConstructor",
"Error",
"ErrorConstructor",
"EvalError",
"EvalErrorConstructor",
"RangeError",
"RangeErrorConstructor",
"ReferenceError",
"ReferenceErrorConstructor",
"SyntaxError",
"SyntaxErrorConstructor",
"TypeError",
"TypeErrorConstructor",
"URIError",
"URIErrorConstructor",
"JSON",
"ReadonlyArray",
"ConcatArray",
"Array",
"ArrayConstructor",
"TypedPropertyDescriptor",
"ClassDecorator",
"PropertyDecorator",
"MethodDecorator",
"ParameterDecorator",
"PromiseConstructorLike",
"PromiseLike",
"Promise",
"ArrayLike",
"Partial",
"Required",
"Readonly",
"Pick",
"Record",
"Exclude",
"Extract",
"NonNullable",
"Parameters",
"ConstructorParameters",
"ReturnType",
"InstanceType",
"ThisType",
"ArrayBuffer",
"ArrayBufferTypes",
"ArrayBufferLike",
"ArrayBufferConstructor",
"ArrayBufferView",
"DataView",
"DataViewConstructor",
"Int8Array",
"Int8ArrayConstructor",
"Uint8Array",
"Uint8ArrayConstructor",
"Uint8ClampedArray",
"Uint8ClampedArrayConstructor",
"Int16Array",
"Int16ArrayConstructor",
"Uint16Array",
"Uint16ArrayConstructor",
"Int32Array",
"Int32ArrayConstructor",
"Uint32Array",
"Uint32ArrayConstructor",
"Float32Array",
"Float32ArrayConstructor",
"Float64Array",
"Float64ArrayConstructor",
"Intl",
const globalTypeDecls: ReadonlyArray<ExpectedCompletionEntryObject> = [
interfaceEntry("Symbol"),
typeEntry("PropertyKey"),
interfaceEntry("PropertyDescriptor"),
interfaceEntry("PropertyDescriptorMap"),
constEntry("Object"),
interfaceEntry("ObjectConstructor"),
constEntry("Function"),
interfaceEntry("FunctionConstructor"),
interfaceEntry("CallableFunction"),
interfaceEntry("NewableFunction"),
interfaceEntry("IArguments"),
constEntry("String"),
interfaceEntry("StringConstructor"),
constEntry("Boolean"),
interfaceEntry("BooleanConstructor"),
constEntry("Number"),
interfaceEntry("NumberConstructor"),
interfaceEntry("TemplateStringsArray"),
interfaceEntry("ImportMeta"),
constEntry("Math"),
constEntry("Date"),
interfaceEntry("DateConstructor"),
interfaceEntry("RegExpMatchArray"),
interfaceEntry("RegExpExecArray"),
constEntry("RegExp"),
interfaceEntry("RegExpConstructor"),
constEntry("Error"),
interfaceEntry("ErrorConstructor"),
constEntry("EvalError"),
interfaceEntry("EvalErrorConstructor"),
constEntry("RangeError"),
interfaceEntry("RangeErrorConstructor"),
constEntry("ReferenceError"),
interfaceEntry("ReferenceErrorConstructor"),
constEntry("SyntaxError"),
interfaceEntry("SyntaxErrorConstructor"),
constEntry("TypeError"),
interfaceEntry("TypeErrorConstructor"),
constEntry("URIError"),
interfaceEntry("URIErrorConstructor"),
constEntry("JSON"),
interfaceEntry("ReadonlyArray"),
interfaceEntry("ConcatArray"),
constEntry("Array"),
interfaceEntry("ArrayConstructor"),
interfaceEntry("TypedPropertyDescriptor"),
typeEntry("ClassDecorator"),
typeEntry("PropertyDecorator"),
typeEntry("MethodDecorator"),
typeEntry("ParameterDecorator"),
typeEntry("PromiseConstructorLike"),
interfaceEntry("PromiseLike"),
interfaceEntry("Promise"),
interfaceEntry("ArrayLike"),
typeEntry("Partial"),
typeEntry("Required"),
typeEntry("Readonly"),
typeEntry("Pick"),
typeEntry("Record"),
typeEntry("Exclude"),
typeEntry("Extract"),
typeEntry("NonNullable"),
typeEntry("Parameters"),
typeEntry("ConstructorParameters"),
typeEntry("ReturnType"),
typeEntry("InstanceType"),
interfaceEntry("ThisType"),
constEntry("ArrayBuffer"),
interfaceEntry("ArrayBufferTypes"),
typeEntry("ArrayBufferLike"),
interfaceEntry("ArrayBufferConstructor"),
interfaceEntry("ArrayBufferView"),
constEntry("DataView"),
interfaceEntry("DataViewConstructor"),
constEntry("Int8Array"),
interfaceEntry("Int8ArrayConstructor"),
constEntry("Uint8Array"),
interfaceEntry("Uint8ArrayConstructor"),
constEntry("Uint8ClampedArray"),
interfaceEntry("Uint8ClampedArrayConstructor"),
constEntry("Int16Array"),
interfaceEntry("Int16ArrayConstructor"),
constEntry("Uint16Array"),
interfaceEntry("Uint16ArrayConstructor"),
constEntry("Int32Array"),
interfaceEntry("Int32ArrayConstructor"),
constEntry("Uint32Array"),
interfaceEntry("Uint32ArrayConstructor"),
constEntry("Float32Array"),
interfaceEntry("Float32ArrayConstructor"),
constEntry("Float64Array"),
interfaceEntry("Float64ArrayConstructor"),
moduleEntry("Intl"),
];
export const globalTypes = globalTypesPlus([]);
@@ -4543,54 +4555,54 @@ namespace FourSlashInterface {
];
}
export const classElementKeywords: ReadonlyArray<string> =
["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"];
export const classElementKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(keywordEntry);
export const constructorParameterKeywords: ReadonlyArray<ExpectedCompletionEntry> =
["private", "protected", "public", "readonly"].map((name): ExpectedCompletionEntry => ({ name, kind: "keyword" }));
export const constructorParameterKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
["private", "protected", "public", "readonly"].map((name): ExpectedCompletionEntryObject => ({ name, kind: "keyword" }));
export const functionMembers: ReadonlyArray<ExpectedCompletionEntry> = [
"apply",
"call",
"bind",
"toString",
"length",
{ name: "arguments", text: "(property) Function.arguments: any" },
"caller"
export const functionMembers: ReadonlyArray<ExpectedCompletionEntryObject> = [
methodEntry("apply"),
methodEntry("call"),
methodEntry("bind"),
methodEntry("toString"),
propertyEntry("length"),
{ name: "arguments", kind: "property", kindModifiers: "declare", text: "(property) Function.arguments: any" },
propertyEntry("caller"),
];
export const stringMembers: ReadonlyArray<ExpectedCompletionEntry> = [
"toString",
"charAt",
"charCodeAt",
"concat",
"indexOf",
"lastIndexOf",
"localeCompare",
"match",
"replace",
"search",
"slice",
"split",
"substring",
"toLowerCase",
"toLocaleLowerCase",
"toUpperCase",
"toLocaleUpperCase",
"trim",
"length",
"substr",
"valueOf",
export const stringMembers: ReadonlyArray<ExpectedCompletionEntryObject> = [
methodEntry("toString"),
methodEntry("charAt"),
methodEntry("charCodeAt"),
methodEntry("concat"),
methodEntry("indexOf"),
methodEntry("lastIndexOf"),
methodEntry("localeCompare"),
methodEntry("match"),
methodEntry("replace"),
methodEntry("search"),
methodEntry("slice"),
methodEntry("split"),
methodEntry("substring"),
methodEntry("toLowerCase"),
methodEntry("toLocaleLowerCase"),
methodEntry("toUpperCase"),
methodEntry("toLocaleUpperCase"),
methodEntry("trim"),
propertyEntry("length"),
methodEntry("substr"),
methodEntry("valueOf"),
];
export const functionMembersWithPrototype: ReadonlyArray<ExpectedCompletionEntry> = [
export const functionMembersWithPrototype: ReadonlyArray<ExpectedCompletionEntryObject> = [
...functionMembers.slice(0, 4),
"prototype",
propertyEntry("prototype"),
...functionMembers.slice(4),
];
// TODO: Shouldn't propose type keywords in statement position
export const statementKeywordsWithTypes: ReadonlyArray<string> = [
export const statementKeywordsWithTypes: ReadonlyArray<ExpectedCompletionEntryObject> = [
"break",
"case",
"catch",
@@ -4663,109 +4675,127 @@ namespace FourSlashInterface {
"unknown",
"from",
"global",
"bigint",
"of",
].map(keywordEntry);
export const statementKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = statementKeywordsWithTypes.filter(k => {
const name = k.name;
switch (name) {
case "false":
case "true":
case "null":
case "void":
return true;
case "declare":
case "module":
return false;
default:
return !ts.contains(typeKeywords, k);
}
});
export const globalsVars: ReadonlyArray<ExpectedCompletionEntryObject> = [
functionEntry("eval"),
functionEntry("parseInt"),
functionEntry("parseFloat"),
functionEntry("isNaN"),
functionEntry("isFinite"),
functionEntry("decodeURI"),
functionEntry("decodeURIComponent"),
functionEntry("encodeURI"),
functionEntry("encodeURIComponent"),
functionEntry("escape"),
functionEntry("unescape"),
constEntry("NaN"),
constEntry("Infinity"),
constEntry("Object"),
constEntry("Function"),
constEntry("String"),
constEntry("Boolean"),
constEntry("Number"),
constEntry("Math"),
constEntry("Date"),
constEntry("RegExp"),
constEntry("Error"),
constEntry("EvalError"),
constEntry("RangeError"),
constEntry("ReferenceError"),
constEntry("SyntaxError"),
constEntry("TypeError"),
constEntry("URIError"),
constEntry("JSON"),
constEntry("Array"),
constEntry("ArrayBuffer"),
constEntry("DataView"),
constEntry("Int8Array"),
constEntry("Uint8Array"),
constEntry("Uint8ClampedArray"),
constEntry("Int16Array"),
constEntry("Uint16Array"),
constEntry("Int32Array"),
constEntry("Uint32Array"),
constEntry("Float32Array"),
constEntry("Float64Array"),
moduleEntry("Intl"),
];
export const statementKeywords: ReadonlyArray<string> = statementKeywordsWithTypes.filter(k =>
k === "false" || k === "true" || k === "null" || k === "void" || !ts.contains(typeKeywords, k) && k !== "declare" && k !== "module");
export const globalsVars: ReadonlyArray<string> = [
"eval",
"parseInt",
"parseFloat",
"isNaN",
"isFinite",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape",
"NaN",
"Infinity",
"Object",
"Function",
"String",
"Boolean",
"Number",
"Math",
"Date",
"RegExp",
"Error",
"EvalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError",
"JSON",
"Array",
"ArrayBuffer",
"DataView",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Uint16Array",
"Int32Array",
"Uint32Array",
"Float32Array",
"Float64Array",
"Intl",
];
const globalKeywordsInsideFunction: ReadonlyArray<ExpectedCompletionEntryObject> = [
"break",
"case",
"catch",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"else",
"enum",
"export",
"extends",
"false",
"finally",
"for",
"function",
"if",
"import",
"in",
"instanceof",
"new",
"null",
"return",
"super",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"var",
"void",
"while",
"with",
"implements",
"interface",
"let",
"package",
"yield",
"async",
].map(keywordEntry);
// TODO: many of these are inappropriate to always provide
export const globalsInsideFunction = (plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> => [
"arguments",
{ name: "arguments", kind: "local var" },
...plus,
...globalsVars,
"undefined",
"break",
"case",
"catch",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"else",
"enum",
"export",
"extends",
"false",
"finally",
"for",
"function",
"if",
"import",
"in",
"instanceof",
"new",
"null",
"return",
"super",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"var",
"void",
"while",
"with",
"implements",
"interface",
"let",
"package",
"yield",
"async",
{ name: "undefined", kind: "var" },
...globalKeywordsInsideFunction,
];
// TODO: many of these are inappropriate to always provide
export const globalKeywords: ReadonlyArray<string> = [
export const globalKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = [
"break",
"case",
"catch",
@@ -4838,10 +4868,11 @@ namespace FourSlashInterface {
"unknown",
"from",
"global",
"bigint",
"of",
];
].map(keywordEntry);
export const insideMethodKeywords: ReadonlyArray<string> = [
export const insideMethodKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = [
"break",
"case",
"catch",
@@ -4884,17 +4915,21 @@ namespace FourSlashInterface {
"package",
"yield",
"async",
];
].map(keywordEntry);
export const globalKeywordsPlusUndefined: ReadonlyArray<string> = (() => {
const i = globalKeywords.indexOf("unique");
return [...globalKeywords.slice(0, i), "undefined", ...globalKeywords.slice(i)];
export const globalKeywordsPlusUndefined: ReadonlyArray<ExpectedCompletionEntryObject> = (() => {
const i = ts.findIndex(globalKeywords, x => x.name === "unique");
return [...globalKeywords.slice(0, i), keywordEntry("undefined"), ...globalKeywords.slice(i)];
})();
export const globals: ReadonlyArray<string> = [...globalsVars, "undefined", ...globalKeywords];
export const globals: ReadonlyArray<ExpectedCompletionEntryObject> = [
...globalsVars,
{ name: "undefined", kind: "var" },
...globalKeywords
];
export function globalsPlus(plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> {
return [...globalsVars, ...plus, "undefined", ...globalKeywords];
return [...globalsVars, ...plus, { name: "undefined", kind: "var" }, ...globalKeywords];
}
}
@@ -4912,20 +4947,21 @@ namespace FourSlashInterface {
newContent: NewFileContent;
}
export type ExpectedCompletionEntry = string | {
readonly name: string,
readonly source?: string,
readonly insertText?: string,
readonly replacementSpan?: FourSlash.Range,
readonly hasAction?: boolean, // If not specified, will assert that this is false.
export type ExpectedCompletionEntry = string | ExpectedCompletionEntryObject;
export interface ExpectedCompletionEntryObject {
readonly name: string;
readonly source?: string;
readonly insertText?: string;
readonly replacementSpan?: FourSlash.Range;
readonly hasAction?: boolean; // If not specified, will assert that this is false.
readonly isRecommended?: boolean; // If not specified, will assert that this is false.
readonly kind?: string, // If not specified, won't assert about this
readonly kindModifiers?: string, // Must be paired with 'kind'
readonly kind?: string; // If not specified, won't assert about this
readonly kindModifiers?: string; // Must be paired with 'kind'
readonly text?: string;
readonly documentation?: string;
readonly sourceDisplay?: string;
readonly tags?: ReadonlyArray<ts.JSDocTagInfo>;
};
}
export interface VerifyCompletionsOptions {
readonly marker?: ArrayOrSingle<string | FourSlash.Marker>;
@@ -5021,7 +5057,7 @@ namespace FourSlashInterface {
export interface VerifyRefactorOptions {
name: string;
actionName: string;
refactors: ts.ApplicableRefactorInfo[];
refactors: ReadonlyArray<ts.ApplicableRefactorInfo>;
}
export interface VerifyCompletionActionOptions extends NewContentOptions {
+14 -13
View File
@@ -1,4 +1,18 @@
namespace Harness.LanguageService {
export function makeDefaultProxy(info: ts.server.PluginCreateInfo): ts.LanguageService {
// tslint:disable-next-line:no-null-keyword
const proxy = Object.create(/*prototype*/ null);
const langSvc: any = info.languageService;
for (const k of Object.keys(langSvc)) {
// tslint:disable-next-line only-arrow-functions
proxy[k] = function () {
return langSvc[k].apply(langSvc, arguments);
};
}
return proxy;
}
export class ScriptInfo {
public version = 1;
public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = [];
@@ -869,19 +883,6 @@ namespace Harness.LanguageService {
error: new Error("Could not resolve module")
};
}
function makeDefaultProxy(info: ts.server.PluginCreateInfo): ts.LanguageService {
// tslint:disable-next-line:no-null-keyword
const proxy = Object.create(/*prototype*/ null);
const langSvc: any = info.languageService;
for (const k of Object.keys(langSvc)) {
// tslint:disable-next-line only-arrow-functions
proxy[k] = function () {
return langSvc[k].apply(langSvc, arguments);
};
}
return proxy;
}
}
}
@@ -341,6 +341,7 @@ interface Array<T> {}`
private readonly currentDirectory: string;
private readonly dynamicPriorityWatchFile: HostWatchFile | undefined;
private readonly customRecursiveWatchDirectory: HostWatchDirectory | undefined;
public require: (initialPath: string, moduleName: string) => server.RequireResult;
constructor(public withSafeList: boolean, public useCaseSensitiveFileNames: boolean, executingFilePath: string, currentDirectory: string, fileOrFolderorSymLinkList: ReadonlyArray<FileOrFolderOrSymLink>, public readonly newLine = "\n", public readonly useWindowsStylePath?: boolean, private readonly environmentVariables?: Map<string>) {
this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
+609
View File
@@ -0,0 +1,609 @@
interface BigInt {
/**
* Returns a string representation of an object.
* @param radix Specifies a radix for converting numeric values to strings.
*/
toString(radix?: number): string;
/** Returns a string representation appropriate to the host environment's current locale. */
toLocaleString(): string;
/** Returns the primitive value of the specified object. */
valueOf(): bigint;
readonly [Symbol.toStringTag]: "BigInt";
}
interface BigIntConstructor {
(value?: any): bigint;
readonly prototype: BigInt;
/**
* Interprets the low bits of a BigInt as a 2's-complement signed integer.
* All higher bits are discarded.
* @param bits The number of low bits to use
* @param int The BigInt whose bits to extract
*/
asIntN(bits: number, int: bigint): bigint;
/**
* Interprets the low bits of a BigInt as an unsigned integer.
* All higher bits are discarded.
* @param bits The number of low bits to use
* @param int The BigInt whose bits to extract
*/
asUintN(bits: number, int: bigint): bigint;
}
declare const BigInt: BigIntConstructor;
/**
* A typed array of 64-bit signed integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated, an exception is raised.
*/
interface BigInt64Array {
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/** The ArrayBuffer instance referenced by the array. */
readonly buffer: ArrayBufferLike;
/** The length in bytes of the array. */
readonly byteLength: number;
/** The offset in bytes of the array. */
readonly byteOffset: number;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): this;
/** Yields index, value pairs for every entry in the array. */
entries(): IterableIterator<[number, bigint]>;
/**
* Determines whether all the members of an array satisfy the specified test.
* @param callbackfn A function that accepts up to three arguments. The every method calls
* the callbackfn function for each element in the array until the callbackfn returns false,
* or until the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: bigint, start?: number, end?: number): this;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A function that accepts up to three arguments. The filter method calls
* the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array;
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
* Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
*/
indexOf(searchElement: bigint, fromIndex?: number): number;
/**
* 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.
*/
join(separator?: string): string;
/** Yields each index in the array. */
keys(): IterableIterator<number>;
/**
* Returns the index of the last occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
*/
lastIndexOf(searchElement: bigint, fromIndex?: number): number;
/** The length of the array. */
readonly length: number;
/**
* Calls a defined callback function on each element of an array, and returns an array that
* contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an
* argument instead of an array value.
*/
reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U;
/** Reverses the elements in the array. */
reverse(): this;
/**
* Sets a value or an array of values.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: ArrayLike<bigint>, offset?: number): void;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array.
*/
slice(start?: number, end?: number): BigInt64Array;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param callbackfn A function that accepts up to three arguments. The some method calls the
* callbackfn function for each element in the array until the callbackfn returns true, or until
* the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean;
/**
* Sorts the array.
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
*/
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
/**
* Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements
* at begin, inclusive, up to end, exclusive.
* @param begin The index of the beginning of the array.
* @param end The index of the end of the array.
*/
subarray(begin: number, end?: number): BigInt64Array;
/** Converts the array to a string by using the current locale. */
toLocaleString(): string;
/** Returns a string representation of the array. */
toString(): string;
/** Yields each value in the array. */
values(): IterableIterator<bigint>;
[Symbol.iterator](): IterableIterator<bigint>;
readonly [Symbol.toStringTag]: "BigInt64Array";
[index: number]: bigint;
}
interface BigInt64ArrayConstructor {
readonly prototype: BigInt64Array;
new(length?: number): BigInt64Array;
new(array: Iterable<bigint>): BigInt64Array;
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array;
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of(...items: bigint[]): BigInt64Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: ArrayLike<bigint>): BigInt64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array;
}
declare const BigInt64Array: BigInt64ArrayConstructor;
/**
* A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated, an exception is raised.
*/
interface BigUint64Array {
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/** The ArrayBuffer instance referenced by the array. */
readonly buffer: ArrayBufferLike;
/** The length in bytes of the array. */
readonly byteLength: number;
/** The offset in bytes of the array. */
readonly byteOffset: number;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): this;
/** Yields index, value pairs for every entry in the array. */
entries(): IterableIterator<[number, bigint]>;
/**
* Determines whether all the members of an array satisfy the specified test.
* @param callbackfn A function that accepts up to three arguments. The every method calls
* the callbackfn function for each element in the array until the callbackfn returns false,
* or until the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: bigint, start?: number, end?: number): this;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A function that accepts up to three arguments. The filter method calls
* the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array;
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
* Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
*/
indexOf(searchElement: bigint, fromIndex?: number): number;
/**
* 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.
*/
join(separator?: string): string;
/** Yields each index in the array. */
keys(): IterableIterator<number>;
/**
* Returns the index of the last occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
*/
lastIndexOf(searchElement: bigint, fromIndex?: number): number;
/** The length of the array. */
readonly length: number;
/**
* Calls a defined callback function on each element of an array, and returns an array that
* contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an
* argument instead of an array value.
*/
reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U;
/** Reverses the elements in the array. */
reverse(): this;
/**
* Sets a value or an array of values.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: ArrayLike<bigint>, offset?: number): void;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array.
*/
slice(start?: number, end?: number): BigUint64Array;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param callbackfn A function that accepts up to three arguments. The some method calls the
* callbackfn function for each element in the array until the callbackfn returns true, or until
* the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean;
/**
* Sorts the array.
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
*/
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
/**
* Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements
* at begin, inclusive, up to end, exclusive.
* @param begin The index of the beginning of the array.
* @param end The index of the end of the array.
*/
subarray(begin: number, end?: number): BigUint64Array;
/** Converts the array to a string by using the current locale. */
toLocaleString(): string;
/** Returns a string representation of the array. */
toString(): string;
/** Yields each value in the array. */
values(): IterableIterator<bigint>;
[Symbol.iterator](): IterableIterator<bigint>;
readonly [Symbol.toStringTag]: "BigUint64Array";
[index: number]: bigint;
}
interface BigUint64ArrayConstructor {
readonly prototype: BigUint64Array;
new(length?: number): BigUint64Array;
new(array: Iterable<bigint>): BigUint64Array;
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array;
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of(...items: bigint[]): BigUint64Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: ArrayLike<bigint>): BigUint64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array;
}
declare const BigUint64Array: BigUint64ArrayConstructor;
interface DataView {
/**
* Gets the BigInt64 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
*/
getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
/**
* Gets the BigUint64 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
*/
getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
/**
* Stores a BigInt64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
* @param littleEndian If false or undefined, a big-endian value should be written,
* otherwise a little-endian value should be written.
*/
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
/**
* Stores a BigUint64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
* @param littleEndian If false or undefined, a big-endian value should be written,
* otherwise a little-endian value should be written.
*/
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
}
+1
View File
@@ -1,5 +1,6 @@
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.array" />
/// <reference lib="esnext.bigint" />
/// <reference lib="esnext.symbol" />
/// <reference lib="esnext.intl" />
+1
View File
@@ -34,6 +34,7 @@
"es2018.intl",
"esnext.asynciterable",
"esnext.array",
"esnext.bigint",
"esnext.symbol",
"esnext.intl",
// Default libraries
+7 -1
View File
@@ -867,7 +867,7 @@ namespace ts.server {
private doEnsureDefaultProjectForFile(fileName: NormalizedPath): Project {
this.ensureProjectStructuresUptoDate();
const scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
return scriptInfo ? scriptInfo.getDefaultProject() : Errors.ThrowNoProject();
return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), Errors.ThrowNoProject());
}
getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string) {
@@ -1966,6 +1966,12 @@ namespace ts.server {
return configProject && configProject.getCompilerOptions().configFile;
}
/* @internal */
logErrorForScriptInfoNotFound(fileName: string): void {
const names = arrayFrom(this.filenameToScriptInfo.entries()).map(([path, scriptInfo]) => ({ path, fileName: scriptInfo.fileName }));
this.logger.msg(`Could not find file ${JSON.stringify(fileName)}.\nAll files are: ${JSON.stringify(names)}`, Msg.Err);
}
/**
* Returns the projects that contain script info through SymLink
* Note that this does not return projects in info.containingProjects
+5
View File
@@ -221,6 +221,11 @@ namespace ts.server.protocol {
* Contains message body if success === true.
*/
body?: any;
/**
* Contains extra information that plugin can include to be passed on
*/
metadata?: unknown;
}
/**
+40 -13
View File
@@ -688,7 +688,26 @@ namespace ts.server {
success,
};
if (success) {
res.body = info;
let metadata: unknown;
if (isArray(info)) {
res.body = info;
metadata = (info as WithMetadata<ReadonlyArray<any>>).metadata;
delete (info as WithMetadata<ReadonlyArray<any>>).metadata;
}
else if (typeof info === "object") {
if ((info as WithMetadata<{}>).metadata) {
const { metadata: infoMetadata, ...body } = (info as WithMetadata<{}>);
res.body = body;
metadata = infoMetadata;
}
else {
res.body = info;
}
}
else {
res.body = info;
}
if (metadata) res.metadata = metadata;
}
else {
Debug.assert(info === undefined);
@@ -1157,7 +1176,9 @@ namespace ts.server {
this.projectService.getScriptInfoEnsuringProjectsUptoDate(args.file) :
this.projectService.getScriptInfo(args.file);
if (!scriptInfo) {
return ignoreNoProjectError ? emptyArray : Errors.ThrowNoProject();
if (ignoreNoProjectError) return emptyArray;
this.projectService.logErrorForScriptInfoNotFound(args.file);
return Errors.ThrowNoProject();
}
projects = scriptInfo.containingProjects;
symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
@@ -1165,6 +1186,7 @@ namespace ts.server {
// filter handles case when 'projects' is undefined
projects = filter(projects, p => p.languageServiceEnabled && !p.isOrphan());
if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) {
this.projectService.logErrorForScriptInfoNotFound(args.file);
return Errors.ThrowNoProject();
}
return symLinkedProjects ? { projects: projects!, symLinkedProjects } : projects!; // TODO: GH#18217
@@ -1464,7 +1486,7 @@ namespace ts.server {
});
}
private getCompletions(args: protocol.CompletionsRequestArgs, kind: protocol.CommandTypes.CompletionInfo | protocol.CommandTypes.Completions | protocol.CommandTypes.CompletionsFull): ReadonlyArray<protocol.CompletionEntry> | protocol.CompletionInfo | CompletionInfo | undefined {
private getCompletions(args: protocol.CompletionsRequestArgs, kind: protocol.CommandTypes.CompletionInfo | protocol.CommandTypes.Completions | protocol.CommandTypes.CompletionsFull): WithMetadata<ReadonlyArray<protocol.CompletionEntry>> | protocol.CompletionInfo | CompletionInfo | undefined {
const { file, project } = this.getFileAndProject(args);
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
const position = this.getPosition(args, scriptInfo);
@@ -1489,7 +1511,10 @@ namespace ts.server {
}
}).sort((a, b) => compareStringsCaseSensitiveUI(a.name, b.name));
if (kind === protocol.CommandTypes.Completions) return entries;
if (kind === protocol.CommandTypes.Completions) {
if (completions.metadata) (entries as WithMetadata<ReadonlyArray<protocol.CompletionEntry>>).metadata = completions.metadata;
return entries;
}
const res: protocol.CompletionInfo = {
...completions,
@@ -1908,8 +1933,17 @@ namespace ts.server {
return textChanges.map(change => this.mapTextChangeToCodeEdit(change));
}
private mapTextChangeToCodeEdit(change: FileTextChanges): protocol.FileCodeEdits {
return mapTextChangesToCodeEdits(change, this.projectService.getScriptInfoOrConfig(change.fileName));
private mapTextChangeToCodeEdit(textChanges: FileTextChanges): protocol.FileCodeEdits {
const scriptInfo = this.projectService.getScriptInfoOrConfig(textChanges.fileName);
if (!!textChanges.isNewFile === !!scriptInfo) {
if (!scriptInfo) { // and !isNewFile
this.projectService.logErrorForScriptInfoNotFound(textChanges.fileName);
}
Debug.fail("Expected isNewFile for (only) new files. " + JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo }));
}
return scriptInfo
? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(textChange => convertTextChangeToCodeEdit(textChange, scriptInfo)) }
: convertNewFileTextChangeToCodeEdit(textChanges);
}
private convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfo): protocol.CodeEdit {
@@ -2431,13 +2465,6 @@ namespace ts.server {
return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) };
}
function mapTextChangesToCodeEdits(textChanges: FileTextChanges, scriptInfo: ScriptInfoOrConfig | undefined): protocol.FileCodeEdits {
Debug.assert(!!textChanges.isNewFile === !scriptInfo, "Expected isNewFile for (only) new files", () => JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo }));
return scriptInfo
? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(textChange => convertTextChangeToCodeEdit(textChange, scriptInfo)) }
: convertNewFileTextChangeToCodeEdit(textChanges);
}
function convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfoOrConfig): protocol.CodeEdit {
return { start: positionToLineOffset(scriptInfo, change.span.start), end: positionToLineOffset(scriptInfo, textSpanEnd(change.span)), newText: change.newText };
}
+9 -1
View File
@@ -182,6 +182,7 @@ namespace ts {
SyntaxKind.Identifier,
SyntaxKind.StringLiteral,
SyntaxKind.NumericLiteral,
SyntaxKind.BigIntLiteral,
SyntaxKind.RegularExpressionLiteral,
SyntaxKind.ThisKeyword,
SyntaxKind.PlusPlusToken,
@@ -286,6 +287,7 @@ namespace ts {
case ClassificationType.comment: return TokenClass.Comment;
case ClassificationType.keyword: return TokenClass.Keyword;
case ClassificationType.numericLiteral: return TokenClass.NumberLiteral;
case ClassificationType.bigintLiteral: return TokenClass.BigIntLiteral;
case ClassificationType.operator: return TokenClass.Operator;
case ClassificationType.stringLiteral: return TokenClass.StringLiteral;
case ClassificationType.whiteSpace: return TokenClass.Whitespace;
@@ -422,6 +424,8 @@ namespace ts {
switch (token) {
case SyntaxKind.NumericLiteral:
return ClassificationType.numericLiteral;
case SyntaxKind.BigIntLiteral:
return ClassificationType.bigintLiteral;
case SyntaxKind.StringLiteral:
return ClassificationType.stringLiteral;
case SyntaxKind.RegularExpressionLiteral:
@@ -542,6 +546,7 @@ namespace ts {
case ClassificationType.identifier: return ClassificationTypeNames.identifier;
case ClassificationType.keyword: return ClassificationTypeNames.keyword;
case ClassificationType.numericLiteral: return ClassificationTypeNames.numericLiteral;
case ClassificationType.bigintLiteral: return ClassificationTypeNames.bigintLiteral;
case ClassificationType.operator: return ClassificationTypeNames.operator;
case ClassificationType.stringLiteral: return ClassificationTypeNames.stringLiteral;
case ClassificationType.whiteSpace: return ClassificationTypeNames.whiteSpace;
@@ -698,7 +703,7 @@ namespace ts {
pushCommentRange(pos, tag.pos - pos);
}
pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation); // "@"
pushClassification(tag.pos, 1, ClassificationType.punctuation); // "@"
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName); // e.g. "param"
pos = tag.tagName.end;
@@ -886,6 +891,9 @@ namespace ts {
else if (tokenKind === SyntaxKind.NumericLiteral) {
return ClassificationType.numericLiteral;
}
else if (tokenKind === SyntaxKind.BigIntLiteral) {
return ClassificationType.bigintLiteral;
}
else if (tokenKind === SyntaxKind.StringLiteral) {
// TODO: GH#18217
return token!.parent.kind === SyntaxKind.JsxAttribute ? ClassificationType.jsxAttributeStringLiteralValue : ClassificationType.stringLiteral;
@@ -185,6 +185,10 @@ namespace ts.codefix {
const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
typeNode = checker.typeToTypeNode(widenedType, classDeclaration);
}
else {
const contextualType = checker.getContextualType(token.parent as Expression);
typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined;
}
return typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword);
}
+107 -46
View File
@@ -194,7 +194,8 @@ namespace ts.codefix {
case SyntaxKind.Constructor:
return true;
case SyntaxKind.FunctionExpression:
return !!declaration.name;
const parent = declaration.parent;
return isVariableDeclaration(parent) && isIdentifier(parent.name) || !!declaration.name;
}
return false;
}
@@ -335,22 +336,31 @@ namespace ts.codefix {
}
function inferTypeForVariableFromUsage(token: Identifier, program: Program, cancellationToken: CancellationToken): Type {
return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken);
const references = getReferences(token, program, cancellationToken);
const checker = program.getTypeChecker();
const types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken);
return InferFromReference.unifyFromContext(types, checker);
}
function inferTypeForParametersFromUsage(containingFunction: FunctionLikeDeclaration, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): ParameterInference[] | undefined {
let searchToken;
switch (containingFunction.kind) {
case SyntaxKind.Constructor:
searchToken = findChildOfKind<Token<SyntaxKind.ConstructorKeyword>>(containingFunction, SyntaxKind.ConstructorKeyword, sourceFile);
break;
case SyntaxKind.FunctionExpression:
const parent = containingFunction.parent;
searchToken = isVariableDeclaration(parent) && isIdentifier(parent.name) ?
parent.name :
containingFunction.name;
break;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
const isConstructor = containingFunction.kind === SyntaxKind.Constructor;
const searchToken = isConstructor ?
findChildOfKind<Token<SyntaxKind.ConstructorKeyword>>(containingFunction, SyntaxKind.ConstructorKeyword, sourceFile) :
containingFunction.name;
if (searchToken) {
return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken);
}
searchToken = containingFunction.name;
break;
}
if (searchToken) {
return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken);
}
}
@@ -369,7 +379,9 @@ namespace ts.codefix {
interface UsageContext {
isNumber?: boolean;
isString?: boolean;
isNumberOrString?: boolean;
hasNonVacuousType?: boolean;
hasNonVacuousNonAnonymousType?: boolean;
candidateTypes?: Type[];
properties?: UnderscoreEscapedMap<UsageContext>;
callContexts?: CallContext[];
@@ -378,13 +390,13 @@ namespace ts.codefix {
stringIndexContext?: UsageContext;
}
export function inferTypeFromReferences(references: ReadonlyArray<Identifier>, checker: TypeChecker, cancellationToken: CancellationToken): Type {
export function inferTypesFromReferences(references: ReadonlyArray<Identifier>, checker: TypeChecker, cancellationToken: CancellationToken): Type[] {
const usageContext: UsageContext = {};
for (const reference of references) {
cancellationToken.throwIfCancellationRequested();
inferTypeFromContext(reference, checker, usageContext);
}
return getTypeFromUsageContext(usageContext, checker) || checker.getAnyType();
return inferFromContext(usageContext, checker);
}
export function inferTypeForParametersFromReferences(references: ReadonlyArray<Identifier>, declaration: FunctionLikeDeclaration, program: Program, cancellationToken: CancellationToken): ParameterInference[] | undefined {
@@ -392,7 +404,6 @@ namespace ts.codefix {
if (references.length === 0) {
return undefined;
}
if (!declaration.parameters) {
return undefined;
}
@@ -411,10 +422,9 @@ namespace ts.codefix {
for (const callContext of callContexts) {
if (callContext.argumentTypes.length <= parameterIndex) {
isOptional = isInJSFile(declaration);
continue;
types.push(checker.getUndefinedType());
}
if (isRest) {
else if (isRest) {
for (let i = parameterIndex; i < callContext.argumentTypes.length; i++) {
types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i]));
}
@@ -423,14 +433,10 @@ namespace ts.codefix {
types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex]));
}
}
let type = types.length && checker.getWidenedType(checker.getUnionType(types, UnionReduction.Subtype));
if ((!type || type.flags & TypeFlags.Any) && isIdentifier(parameter.name)) {
type = inferTypeForVariableFromUsage(parameter.name, program, cancellationToken);
}
if (!type) {
type = checker.getAnyType();
if (isIdentifier(parameter.name)) {
types.push(...inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken));
}
const type = unifyFromContext(types, checker);
return {
type: isRest ? checker.createArrayType(type) : type,
isOptional: isOptional && !isRest,
@@ -504,7 +510,8 @@ namespace ts.codefix {
break;
case SyntaxKind.PlusToken:
usageContext.isNumberOrString = true;
usageContext.isNumber = true;
usageContext.isString = true;
break;
// case SyntaxKind.ExclamationToken:
@@ -575,7 +582,8 @@ namespace ts.codefix {
usageContext.isString = true;
}
else {
usageContext.isNumberOrString = true;
usageContext.isNumber = true;
usageContext.isString = true;
}
break;
@@ -649,7 +657,8 @@ namespace ts.codefix {
function inferTypeFromPropertyElementExpressionContext(parent: ElementAccessExpression, node: Expression, checker: TypeChecker, usageContext: UsageContext): void {
if (node === parent.argumentExpression) {
usageContext.isNumberOrString = true;
usageContext.isNumber = true;
usageContext.isString = true;
return;
}
else {
@@ -665,29 +674,83 @@ namespace ts.codefix {
}
}
function getTypeFromUsageContext(usageContext: UsageContext, checker: TypeChecker): Type | undefined {
if (usageContext.isNumberOrString && !usageContext.isNumber && !usageContext.isString) {
return checker.getUnionType([checker.getNumberType(), checker.getStringType()]);
export function unifyFromContext(inferences: ReadonlyArray<Type>, checker: TypeChecker, fallback = checker.getAnyType()): Type {
if (!inferences.length) return fallback;
const hasNonVacuousType = inferences.some(i => !(i.flags & (TypeFlags.Any | TypeFlags.Void)));
const hasNonVacuousNonAnonymousType = inferences.some(
i => !(i.flags & (TypeFlags.Nullable | TypeFlags.Any | TypeFlags.Void)) && !(checker.getObjectFlags(i) & ObjectFlags.Anonymous));
const anons = inferences.filter(i => checker.getObjectFlags(i) & ObjectFlags.Anonymous) as AnonymousType[];
const good = [];
if (!hasNonVacuousNonAnonymousType && anons.length) {
good.push(unifyAnonymousTypes(anons, checker));
}
else if (usageContext.isNumber) {
return checker.getNumberType();
good.push(...inferences.filter(i => !(checker.getObjectFlags(i) & ObjectFlags.Anonymous) && !(hasNonVacuousType && i.flags & (TypeFlags.Any | TypeFlags.Void))));
return checker.getWidenedType(checker.getUnionType(good));
}
function unifyAnonymousTypes(anons: AnonymousType[], checker: TypeChecker) {
if (anons.length === 1) {
return anons[0];
}
else if (usageContext.isString) {
return checker.getStringType();
const calls = [];
const constructs = [];
const stringIndices = [];
const numberIndices = [];
let stringIndexReadonly = false;
let numberIndexReadonly = false;
const props = createMultiMap<Type>();
for (const anon of anons) {
for (const p of checker.getPropertiesOfType(anon)) {
props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration));
}
calls.push(...checker.getSignaturesOfType(anon, SignatureKind.Call));
constructs.push(...checker.getSignaturesOfType(anon, SignatureKind.Construct));
if (anon.stringIndexInfo) {
stringIndices.push(anon.stringIndexInfo.type);
stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly;
}
if (anon.numberIndexInfo) {
numberIndices.push(anon.numberIndexInfo.type);
numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly;
}
}
else if (usageContext.candidateTypes) {
return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(t => checker.getBaseTypeOfLiteralType(t)), UnionReduction.Subtype));
const members = mapEntries(props, (name, types) => {
const isOptional = types.length < anons.length ? SymbolFlags.Optional : 0;
const s = checker.createSymbol(SymbolFlags.Property | isOptional, name as __String);
s.type = checker.getUnionType(types);
return [name, s];
});
return checker.createAnonymousType(
anons[0].symbol,
members as UnderscoreEscapedMap<TransientSymbol>,
calls,
constructs,
stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined,
numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined);
}
function inferFromContext(usageContext: UsageContext, checker: TypeChecker) {
const types = [];
if (usageContext.isNumber) {
types.push(checker.getNumberType());
}
else if (usageContext.properties && hasCallContext(usageContext.properties.get("then" as __String))) {
if (usageContext.isString) {
types.push(checker.getStringType());
}
types.push(...(usageContext.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t)));
if (usageContext.properties && hasCallContext(usageContext.properties.get("then" as __String))) {
const paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then" as __String)!.callContexts!, /*isRestParameter*/ false, checker)!; // TODO: GH#18217
const types = paramType.getCallSignatures().map(c => c.getReturnType());
return checker.createPromiseType(types.length ? checker.getUnionType(types, UnionReduction.Subtype) : checker.getAnyType());
types.push(checker.createPromiseType(types.length ? checker.getUnionType(types, UnionReduction.Subtype) : checker.getAnyType()));
}
else if (usageContext.properties && hasCallContext(usageContext.properties.get("push" as __String))) {
return checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push" as __String)!.callContexts!, /*isRestParameter*/ false, checker)!);
types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push" as __String)!.callContexts!, /*isRestParameter*/ false, checker)!));
}
else if (usageContext.numberIndexContext) {
return checker.createArrayType(recur(usageContext.numberIndexContext));
if (usageContext.numberIndexContext) {
return [checker.createArrayType(recur(usageContext.numberIndexContext))];
}
else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) {
const members = createUnderscoreEscapedMap<Symbol>();
@@ -719,14 +782,12 @@ namespace ts.codefix {
stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false);
}
return checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217
}
else {
return undefined;
types.push(checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217
}
return types;
function recur(innerContext: UsageContext): Type {
return getTypeFromUsageContext(innerContext, checker) || checker.getAnyType();
return unifyFromContext(inferFromContext(innerContext, checker), checker);
}
}
@@ -759,7 +820,7 @@ namespace ts.codefix {
symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i]));
parameters.push(symbol);
}
const returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType();
const returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType());
// TODO: GH#18217
return checker.createSignature(/*declaration*/ undefined!, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
}
+11 -8
View File
@@ -165,8 +165,9 @@ namespace ts.Completions {
});
}
const completionNameForLiteral = JSON.stringify;
function createCompletionEntryForLiteral(literal: string | number): CompletionEntry {
const completionNameForLiteral = (literal: string | number | PseudoBigInt) =>
typeof literal === "object" ? pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
function createCompletionEntryForLiteral(literal: string | number | PseudoBigInt): CompletionEntry {
return { name: completionNameForLiteral(literal), kind: ScriptElementKind.string, kindModifiers: ScriptElementKindModifier.none, sortText: "0" };
}
@@ -337,7 +338,7 @@ namespace ts.Completions {
readonly isJsxInitializer: IsJsxInitializer;
}
function getSymbolCompletionFromEntryId(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier,
): SymbolCompletion | { type: "request", request: Request } | { type: "literal", literal: string | number } | { type: "none" } {
): SymbolCompletion | { type: "request", request: Request } | { type: "literal", literal: string | number | PseudoBigInt } | { type: "none" } {
const compilerOptions = program.getCompilerOptions();
const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId);
if (!completionData) {
@@ -502,7 +503,7 @@ namespace ts.Completions {
readonly isNewIdentifierLocation: boolean;
readonly location: Node | undefined;
readonly keywordFilters: KeywordCompletionFilters;
readonly literals: ReadonlyArray<string | number>;
readonly literals: ReadonlyArray<string | number | PseudoBigInt>;
readonly symbolToOriginInfoMap: SymbolOriginInfoMap;
readonly recommendedCompletion: Symbol | undefined;
readonly previousToken: Node | undefined;
@@ -1167,14 +1168,16 @@ namespace ts.Completions {
// The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details.
// This is just to avoid adding duplicate completion entries.
//
// If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols.
// If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check).
// If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols.
if (typeChecker.getMergedSymbol(symbol.parent!) !== resolvedModuleSymbol
|| some(symbol.declarations, d => isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier)) {
|| some(symbol.declarations, d =>
// If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion.
// If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check).
isExportSpecifier(d) && (d.propertyName ? isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier))) {
continue;
}
const isDefaultExport = symbol.name === InternalSymbolName.Default;
const isDefaultExport = symbol.escapedName === InternalSymbolName.Default;
if (isDefaultExport) {
symbol = getLocalSymbolForExportDefault(symbol) || symbol;
}
+2 -2
View File
@@ -22,8 +22,8 @@ namespace ts.formatting {
const binaryKeywordOperators = [SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword];
const unaryPrefixOperators = [SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken];
const unaryPrefixExpressions = [
SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken,
SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword];
SyntaxKind.NumericLiteral, SyntaxKind.BigIntLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken,
SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword];
const unaryPreincrementExpressions = [SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword];
const unaryPostincrementExpressions = [SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword];
const unaryPredecrementExpressions = [SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword];
+1 -1
View File
@@ -5,7 +5,7 @@ namespace ts {
getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined;
/** Compute (quickly) which actions are available here */
getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined;
getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo>;
}
export interface RefactorContext extends textChanges.TextChangesContext {
@@ -15,10 +15,10 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction {
addBraces: boolean;
}
function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
const { file, startPosition } = context;
const info = getConvertibleArrowFunctionAtPosition(file, startPosition);
if (!info) return undefined;
if (!info) return emptyArray;
return [{
name: refactorName,
+2 -2
View File
@@ -4,9 +4,9 @@ namespace ts.refactor {
const actionNameDefaultToNamed = "Convert default export to named export";
const actionNameNamedToDefault = "Convert named export to default export";
registerRefactor(refactorName, {
getAvailableActions(context): ApplicableRefactorInfo[] | undefined {
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
const info = getInfo(context);
if (!info) return undefined;
if (!info) return emptyArray;
const description = info.wasDefault ? Diagnostics.Convert_default_export_to_named_export.message : Diagnostics.Convert_named_export_to_default_export.message;
const actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault;
return [{ name: refactorName, description, actions: [{ name: actionName, description }] }];
+2 -2
View File
@@ -4,9 +4,9 @@ namespace ts.refactor {
const actionNameNamespaceToNamed = "Convert namespace import to named imports";
const actionNameNamedToNamespace = "Convert named imports to namespace import";
registerRefactor(refactorName, {
getAvailableActions(context): ApplicableRefactorInfo[] | undefined {
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
const i = getImportToConvert(context);
if (!i) return undefined;
if (!i) return emptyArray;
const description = i.kind === SyntaxKind.NamespaceImport ? Diagnostics.Convert_namespace_import_to_named_imports.message : Diagnostics.Convert_named_imports_to_namespace_import.message;
const actionName = i.kind === SyntaxKind.NamespaceImport ? actionNameNamespaceToNamed : actionNameNamedToNamespace;
return [{ name: refactorName, description, actions: [{ name: actionName, description }] }];
+4 -4
View File
@@ -7,18 +7,18 @@ namespace ts.refactor.extractSymbol {
* Compute the associated code actions
* Exported for tests.
*/
export function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
export function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
const rangeToExtract = getRangeToExtract(context.file, getRefactorContextSpan(context));
const targetRange = rangeToExtract.targetRange;
if (targetRange === undefined) {
return undefined;
return emptyArray;
}
const extractions = getPossibleExtractions(targetRange, context);
if (extractions === undefined) {
// No extractions possible
return undefined;
return emptyArray;
}
const functionActions: RefactorActionInfo[] = [];
@@ -82,7 +82,7 @@ namespace ts.refactor.extractSymbol {
});
}
return infos.length ? infos : undefined;
return infos.length ? infos : emptyArray;
}
/* Exported for tests */
@@ -20,8 +20,8 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
readonly renameAccessor: boolean;
}
function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
if (!getConvertibleFieldAtPosition(context)) return undefined;
function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
if (!getConvertibleFieldAtPosition(context)) return emptyArray;
return [{
name: actionName,
+2 -2
View File
@@ -2,8 +2,8 @@
namespace ts.refactor {
const refactorName = "Move to a new file";
registerRefactor(refactorName, {
getAvailableActions(context): ApplicableRefactorInfo[] | undefined {
if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return undefined;
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return emptyArray;
const description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
return [{ name: refactorName, description, actions: [{ name: refactorName, description }] }];
},
+1 -1
View File
@@ -45,6 +45,7 @@
"refactorProvider.ts",
"codefixes/addMissingInvocationForDecorator.ts",
"codefixes/annotateWithTypeFromJSDoc.ts",
"codefixes/inferFromUsage.ts",
"codefixes/convertFunctionToEs6Class.ts",
"codefixes/convertToAsyncFunction.ts",
"codefixes/convertToEs6Module.ts",
@@ -66,7 +67,6 @@
"codefixes/fixAwaitInSyncFunction.ts",
"codefixes/disableJsDiagnostics.ts",
"codefixes/helpers.ts",
"codefixes/inferFromUsage.ts",
"codefixes/fixInvalidImportSyntax.ts",
"codefixes/fixStrictClassInitialization.ts",
"codefixes/generateTypes.ts",
+6 -1
View File
@@ -238,6 +238,8 @@ namespace ts {
/* @internal */
export const emptyOptions = {};
export type WithMetadata<T> = T & { metadata?: unknown; };
//
// Public services of a language service instance associated
// with a language service host instance
@@ -268,7 +270,7 @@ namespace ts {
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata<CompletionInfo> | undefined;
// "options" and "source" are optional only for backwards-compatibility
getCompletionEntryDetails(
fileName: string,
@@ -978,6 +980,7 @@ namespace ts {
Whitespace,
Identifier,
NumberLiteral,
BigIntLiteral,
StringLiteral,
RegExpLiteral,
}
@@ -1141,6 +1144,7 @@ namespace ts {
identifier = "identifier",
keyword = "keyword",
numericLiteral = "number",
bigintLiteral = "bigint",
operator = "operator",
stringLiteral = "string",
whiteSpace = "whitespace",
@@ -1189,5 +1193,6 @@ namespace ts {
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
bigintLiteral = 25,
}
}
+1
View File
@@ -1028,6 +1028,7 @@ namespace ts {
case SyntaxKind.Identifier:
case SyntaxKind.StringLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.BigIntLiteral:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
+1
View File
@@ -65,6 +65,7 @@
"unittests/matchFiles.ts",
"unittests/moduleResolution.ts",
"unittests/organizeImports.ts",
"unittests/parsePseudoBigInt.ts",
"unittests/paths.ts",
"unittests/printer.ts",
"unittests/programMissingFiles.ts",
@@ -57,7 +57,7 @@ namespace ts {
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -259,7 +259,7 @@ namespace ts {
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -278,7 +278,7 @@ namespace ts {
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -295,7 +295,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@@ -326,7 +326,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@@ -357,7 +357,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@@ -388,7 +388,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@@ -107,7 +107,7 @@ namespace ts {
};
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
assert.equal(rangeToExtract.errors, undefined, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText);
const infos = refactor.extractSymbol.getAvailableActions(context)!;
const infos = refactor.extractSymbol.getAvailableActions(context);
const actions = find(infos, info => info.description === description.message)!.actions;
const data: string[] = [];
@@ -169,7 +169,7 @@ namespace ts {
};
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
assert.isUndefined(rangeToExtract.errors, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText);
const infos = refactor.extractSymbol.getAvailableActions(context)!;
const infos = refactor.extractSymbol.getAvailableActions(context);
assert.isUndefined(find(infos, info => info.description === description.message));
});
}
@@ -0,0 +1,71 @@
namespace ts {
describe("BigInt literal base conversions", () => {
describe("parsePseudoBigInt", () => {
const testNumbers: number[] = [];
for (let i = 0; i < 1e3; i++) testNumbers.push(i);
for (let bits = 0; bits <= 52; bits++) {
testNumbers.push(2 ** bits, 2 ** bits - 1);
}
it("can strip base-10 strings", () => {
for (const testNumber of testNumbers) {
for (let leadingZeros = 0; leadingZeros < 10; leadingZeros++) {
assert.equal(
parsePseudoBigInt("0".repeat(leadingZeros) + testNumber + "n"),
String(testNumber)
);
}
}
});
it("can parse binary literals", () => {
for (const testNumber of testNumbers) {
for (let leadingZeros = 0; leadingZeros < 10; leadingZeros++) {
const binary = "0".repeat(leadingZeros) + testNumber.toString(2) + "n";
for (const prefix of ["0b", "0B"]) {
assert.equal(parsePseudoBigInt(prefix + binary), String(testNumber));
}
}
}
});
it("can parse octal literals", () => {
for (const testNumber of testNumbers) {
for (let leadingZeros = 0; leadingZeros < 10; leadingZeros++) {
const octal = "0".repeat(leadingZeros) + testNumber.toString(8) + "n";
for (const prefix of ["0o", "0O"]) {
assert.equal(parsePseudoBigInt(prefix + octal), String(testNumber));
}
}
}
});
it("can parse hex literals", () => {
for (const testNumber of testNumbers) {
for (let leadingZeros = 0; leadingZeros < 10; leadingZeros++) {
const hex = "0".repeat(leadingZeros) + testNumber.toString(16) + "n";
for (const prefix of ["0x", "0X"]) {
for (const hexCase of [hex.toLowerCase(), hex.toUpperCase()]) {
assert.equal(parsePseudoBigInt(prefix + hexCase), String(testNumber));
}
}
}
}
});
it("can parse large literals", () => {
assert.equal(
parsePseudoBigInt("123456789012345678901234567890n"),
"123456789012345678901234567890"
);
assert.equal(
parsePseudoBigInt("0b1100011101110100100001111111101101100001101110011111000001110111001001110001111110000101011010010n"),
"123456789012345678901234567890"
);
assert.equal(
parsePseudoBigInt("0o143564417755415637016711617605322n"),
"123456789012345678901234567890"
);
assert.equal(
parsePseudoBigInt("0x18ee90ff6c373e0ee4e3f0ad2n"),
"123456789012345678901234567890"
);
});
});
});
}
+64 -1
View File
@@ -1298,7 +1298,7 @@ export default test;`;
]);
changeParameterType("y", "string", [
getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.indexOf("5"), 1, Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1, "5", "string"),
getDiagnosticOfFileFromProgram(watch(), bFile.path, bFile.content.indexOf("y /"), 1, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)
getDiagnosticOfFileFromProgram(watch(), bFile.path, bFile.content.indexOf("y /"), 1, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type)
]);
function changeParameterType(parameterName: string, toType: string, expectedErrors: ReadonlyArray<Diagnostic>) {
@@ -1472,6 +1472,69 @@ foo().hello`
checkProgramActualFiles(watch(), [aFile.path, libFile.path]);
checkOutputErrorsIncremental(host, emptyArray);
});
it("updates errors when file transitively exported file changes", () => {
const projectLocation = "/user/username/projects/myproject";
const config: File = {
path: `${projectLocation}/tsconfig.json`,
content: JSON.stringify({
files: ["app.ts"],
compilerOptions: { baseUrl: "." }
})
};
const app: File = {
path: `${projectLocation}/app.ts`,
content: `import { Data } from "lib2/public";
export class App {
public constructor() {
new Data().test();
}
}`
};
const lib2Public: File = {
path: `${projectLocation}/lib2/public.ts`,
content: `export * from "./data";`
};
const lib2Data: File = {
path: `${projectLocation}/lib2/data.ts`,
content: `import { ITest } from "lib1/public";
export class Data {
public test() {
const result: ITest = {
title: "title"
}
return result;
}
}`
};
const lib1Public: File = {
path: `${projectLocation}/lib1/public.ts`,
content: `export * from "./tools/public";`
};
const lib1ToolsPublic: File = {
path: `${projectLocation}/lib1/tools/public.ts`,
content: `export * from "./tools.interface";`
};
const lib1ToolsInterface: File = {
path: `${projectLocation}/lib1/tools/tools.interface.ts`,
content: `export interface ITest {
title: string;
}`
};
const filesWithoutConfig = [libFile, app, lib2Public, lib2Data, lib1Public, lib1ToolsPublic, lib1ToolsInterface];
const files = [config, ...filesWithoutConfig];
const host = createWatchedSystem(files, { currentDirectory: projectLocation });
const watch = createWatchOfConfigFile(config.path, host);
checkProgramActualFiles(watch(), filesWithoutConfig.map(f => f.path));
checkOutputErrorsInitial(host, emptyArray);
host.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2"));
host.checkTimeoutQueueLengthAndRun(1);
checkProgramActualFiles(watch(), filesWithoutConfig.map(f => f.path));
checkOutputErrorsIncremental(host, [
"lib2/data.ts(5,13): error TS2322: Type '{ title: string; }' is not assignable to type 'ITest'.\n Object literal may only specify known properties, but 'title' does not exist in type 'ITest'. Did you mean to write 'title2'?\n"
]);
});
});
describe("tsc-watch emit with outFile or out setting", () => {
@@ -17,6 +17,14 @@ namespace ts.projectSystem {
import safeList = TestFSWithWatch.safeList;
import Tsc_WatchDirectory = TestFSWithWatch.Tsc_WatchDirectory;
const outputEventRegex = /Content\-Length: [\d]+\r\n\r\n/;
function mapOutputToJson(s: string) {
return convertToObject(
parseJsonText("json.json", s.replace(outputEventRegex, "")),
[]
);
}
export const customTypesMap = {
path: <Path>"/typesMap.json",
content: `{
@@ -353,12 +361,8 @@ namespace ts.projectSystem {
};
function getEvents() {
const outputEventRegex = /Content\-Length: [\d]+\r\n\r\n/;
return mapDefined(host.getOutput(), s => {
const e = convertToObject(
parseJsonText("json.json", s.replace(outputEventRegex, "")),
[]
);
const e = mapOutputToJson(s);
return (isArray(eventNames) ? eventNames.some(eventName => e.event === eventName) : e.event === eventNames) ? e as T : undefined;
});
}
@@ -10735,6 +10739,104 @@ declare class TestLib {
});
});
describe("tsserverProjectSystem with metadata in response", () => {
const metadata = "Extra Info";
function verifyOutput(host: TestServerHost, expectedResponse: protocol.Response) {
const output = host.getOutput().map(mapOutputToJson);
assert.deepEqual(output, [expectedResponse]);
host.clearOutput();
}
function verifyCommandWithMetadata<T extends server.protocol.Request, U = undefined>(session: TestSession, host: TestServerHost, command: Partial<T>, expectedResponseBody: U) {
command.seq = session.getSeq();
command.type = "request";
session.onMessage(JSON.stringify(command));
verifyOutput(host, expectedResponseBody ?
{ seq: 0, type: "response", command: command.command!, request_seq: command.seq, success: true, body: expectedResponseBody, metadata } :
{ seq: 0, type: "response", command: command.command!, request_seq: command.seq, success: false, message: "No content available." }
);
}
const aTs: File = { path: "/a.ts", content: `class c { prop = "hello"; foo() { return this.prop; } }` };
const tsconfig: File = {
path: "/tsconfig.json",
content: JSON.stringify({
compilerOptions: { plugins: [{ name: "myplugin" }] }
})
};
function createHostWithPlugin(files: ReadonlyArray<File>) {
const host = createServerHost(files);
host.require = (_initialPath, moduleName) => {
assert.equal(moduleName, "myplugin");
return {
module: () => ({
create(info: server.PluginCreateInfo) {
const proxy = Harness.LanguageService.makeDefaultProxy(info);
proxy.getCompletionsAtPosition = (filename, position, options) => {
const result = info.languageService.getCompletionsAtPosition(filename, position, options);
if (result) {
result.metadata = metadata;
}
return result;
};
return proxy;
}
}),
error: undefined
};
};
return host;
}
describe("With completion requests", () => {
const completionRequestArgs: protocol.CompletionsRequestArgs = {
file: aTs.path,
line: 1,
offset: aTs.content.indexOf("this.") + 1 + "this.".length
};
const expectedCompletionEntries: ReadonlyArray<protocol.CompletionEntry> = [
{ name: "foo", kind: ScriptElementKind.memberFunctionElement, kindModifiers: "", sortText: "0" },
{ name: "prop", kind: ScriptElementKind.memberVariableElement, kindModifiers: "", sortText: "0" }
];
it("can pass through metadata when the command returns array", () => {
const host = createHostWithPlugin([aTs, tsconfig]);
const session = createSession(host);
openFilesForSession([aTs], session);
verifyCommandWithMetadata<protocol.CompletionsRequest, ReadonlyArray<protocol.CompletionEntry>>(session, host, {
command: protocol.CommandTypes.Completions,
arguments: completionRequestArgs
}, expectedCompletionEntries);
});
it("can pass through metadata when the command returns object", () => {
const host = createHostWithPlugin([aTs, tsconfig]);
const session = createSession(host);
openFilesForSession([aTs], session);
verifyCommandWithMetadata<protocol.CompletionsRequest, protocol.CompletionInfo>(session, host, {
command: protocol.CommandTypes.CompletionInfo,
arguments: completionRequestArgs
}, {
isGlobalCompletion: false,
isMemberCompletion: true,
isNewIdentifierLocation: false,
entries: expectedCompletionEntries
});
});
it("returns undefined correctly", () => {
const aTs: File = { path: "/a.ts", content: `class c { prop = "hello"; foo() { const x = 0; } }` };
const host = createHostWithPlugin([aTs, tsconfig]);
const session = createSession(host);
openFilesForSession([aTs], session);
verifyCommandWithMetadata<protocol.CompletionsRequest>(session, host, {
command: protocol.CommandTypes.Completions,
arguments: { file: aTs.path, line: 1, offset: aTs.content.indexOf("x") + 1 }
}, /*expectedResponseBody*/ undefined);
});
});
});
function makeReferenceItem(file: File, isDefinition: boolean, text: string, lineText: string, options?: SpanFromSubstringOptions): protocol.ReferencesResponseItem {
return {
...protocolFileSpanFromSubstring(file, text, options),
@@ -7,11 +7,6 @@
"kind": "JSDocTag",
"pos": 63,
"end": 68,
"atToken": {
"kind": "AtToken",
"pos": 63,
"end": 64
},
"tagName": {
"kind": "Identifier",
"pos": 64,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 6,
"end": 64,
"atToken": {
"kind": "AtToken",
"pos": 6,
"end": 7
},
"tagName": {
"kind": "Identifier",
"pos": 7,
@@ -31,11 +26,6 @@
"kind": "JSDocParameterTag",
"pos": 34,
"end": 64,
"atToken": {
"kind": "AtToken",
"pos": 34,
"end": 35
},
"tagName": {
"kind": "Identifier",
"pos": 35,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 42,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 47,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTypeTag",
"pos": 8,
"end": 22,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 7,
"end": 59,
"atToken": {
"kind": "AtToken",
"pos": 7,
"end": 8
},
"tagName": {
"kind": "Identifier",
"pos": 8,
@@ -7,11 +7,6 @@
"kind": "JSDocTypeTag",
"pos": 8,
"end": 22,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocReturnTag",
"pos": 8,
"end": 15,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 32,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 57,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 59,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 64,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 29,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 44,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 21,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocReturnTag",
"pos": 8,
"end": 24,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocReturnTag",
"pos": 8,
"end": 24,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocReturnTag",
"pos": 8,
"end": 25,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 19,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 21,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 22,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 22,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 23,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTemplateTag",
"pos": 8,
"end": 24,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 34,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -41,11 +36,6 @@
"kind": "JSDocParameterTag",
"pos": 34,
"end": 58,
"atToken": {
"kind": "AtToken",
"pos": 34,
"end": 35
},
"tagName": {
"kind": "Identifier",
"pos": 35,
@@ -7,11 +7,6 @@
"kind": "JSDocParameterTag",
"pos": 8,
"end": 30,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -41,11 +36,6 @@
"kind": "JSDocParameterTag",
"pos": 30,
"end": 54,
"atToken": {
"kind": "AtToken",
"pos": 30,
"end": 31
},
"tagName": {
"kind": "Identifier",
"pos": 31,
@@ -7,11 +7,6 @@
"kind": "JSDocTypeTag",
"pos": 8,
"end": 22,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -7,11 +7,6 @@
"kind": "JSDocTypedefTag",
"pos": 8,
"end": 100,
"atToken": {
"kind": "AtToken",
"pos": 8,
"end": 9
},
"tagName": {
"kind": "Identifier",
"pos": 9,
@@ -39,11 +34,6 @@
"kind": "JSDocPropertyTag",
"pos": 47,
"end": 74,
"atToken": {
"kind": "AtToken",
"pos": 47,
"end": 48
},
"tagName": {
"kind": "Identifier",
"pos": 48,
@@ -73,11 +63,6 @@
"kind": "JSDocPropertyTag",
"pos": 74,
"end": 100,
"atToken": {
"kind": "AtToken",
"pos": 74,
"end": 75
},
"tagName": {
"kind": "Identifier",
"pos": 75,
@@ -11,7 +11,7 @@ function f1(x: Color | string) {
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color
>"number" : "number"
@@ -38,7 +38,7 @@ function f2(x: Color | string | string[]) {
if (typeof x === "object") {
>typeof x === "object" : boolean
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"object" : "object"
@@ -51,7 +51,7 @@ function f2(x: Color | string | string[]) {
}
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"number" : "number"
@@ -72,7 +72,7 @@ function f2(x: Color | string | string[]) {
}
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"string" : "string"
@@ -1,5 +1,5 @@
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts (2 errors) ====
@@ -7,4 +7,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): e
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
@@ -29,7 +29,7 @@ declare module "indirect" {
>"indirect" : typeof import("indirect")
export default typeof Foo.default;
>typeof Foo.default : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof Foo.default : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>Foo.default : number
>Foo : typeof Foo
>default : number
@@ -41,7 +41,7 @@ declare module "indirect2" {
>"indirect2" : typeof import("indirect2")
export = typeof Foo2;
>typeof Foo2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof Foo2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>Foo2 : number
}
@@ -1,11 +1,10 @@
tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement.
tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2531: Object is possibly 'null'.
tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
==== tests/cases/compiler/ambientWithStatements.ts (5 errors) ====
==== tests/cases/compiler/ambientWithStatements.ts (4 errors) ====
declare module M {
break;
~~~~~
@@ -17,8 +16,6 @@ tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' st
do { } while (true);
var x;
for (x in null) { }
~~~~
!!! error TS2531: Object is possibly 'null'.
if (true) { } else { }
1;
L: var y;
@@ -4,7 +4,7 @@ function f() {
return typeof class {} === "function";
>typeof class {} === "function" : boolean
>typeof class {} : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof class {} : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>class {} : typeof (Anonymous class)
>"function" : "function"
}
+404 -376
View File
@@ -73,7 +73,7 @@ declare namespace ts {
end: number;
}
type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind;
type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
enum SyntaxKind {
Unknown = 0,
@@ -85,337 +85,339 @@ declare namespace ts {
ShebangTrivia = 6,
ConflictMarkerTrivia = 7,
NumericLiteral = 8,
StringLiteral = 9,
JsxText = 10,
JsxTextAllWhiteSpaces = 11,
RegularExpressionLiteral = 12,
NoSubstitutionTemplateLiteral = 13,
TemplateHead = 14,
TemplateMiddle = 15,
TemplateTail = 16,
OpenBraceToken = 17,
CloseBraceToken = 18,
OpenParenToken = 19,
CloseParenToken = 20,
OpenBracketToken = 21,
CloseBracketToken = 22,
DotToken = 23,
DotDotDotToken = 24,
SemicolonToken = 25,
CommaToken = 26,
LessThanToken = 27,
LessThanSlashToken = 28,
GreaterThanToken = 29,
LessThanEqualsToken = 30,
GreaterThanEqualsToken = 31,
EqualsEqualsToken = 32,
ExclamationEqualsToken = 33,
EqualsEqualsEqualsToken = 34,
ExclamationEqualsEqualsToken = 35,
EqualsGreaterThanToken = 36,
PlusToken = 37,
MinusToken = 38,
AsteriskToken = 39,
AsteriskAsteriskToken = 40,
SlashToken = 41,
PercentToken = 42,
PlusPlusToken = 43,
MinusMinusToken = 44,
LessThanLessThanToken = 45,
GreaterThanGreaterThanToken = 46,
GreaterThanGreaterThanGreaterThanToken = 47,
AmpersandToken = 48,
BarToken = 49,
CaretToken = 50,
ExclamationToken = 51,
TildeToken = 52,
AmpersandAmpersandToken = 53,
BarBarToken = 54,
QuestionToken = 55,
ColonToken = 56,
AtToken = 57,
EqualsToken = 58,
PlusEqualsToken = 59,
MinusEqualsToken = 60,
AsteriskEqualsToken = 61,
AsteriskAsteriskEqualsToken = 62,
SlashEqualsToken = 63,
PercentEqualsToken = 64,
LessThanLessThanEqualsToken = 65,
GreaterThanGreaterThanEqualsToken = 66,
GreaterThanGreaterThanGreaterThanEqualsToken = 67,
AmpersandEqualsToken = 68,
BarEqualsToken = 69,
CaretEqualsToken = 70,
Identifier = 71,
BreakKeyword = 72,
CaseKeyword = 73,
CatchKeyword = 74,
ClassKeyword = 75,
ConstKeyword = 76,
ContinueKeyword = 77,
DebuggerKeyword = 78,
DefaultKeyword = 79,
DeleteKeyword = 80,
DoKeyword = 81,
ElseKeyword = 82,
EnumKeyword = 83,
ExportKeyword = 84,
ExtendsKeyword = 85,
FalseKeyword = 86,
FinallyKeyword = 87,
ForKeyword = 88,
FunctionKeyword = 89,
IfKeyword = 90,
ImportKeyword = 91,
InKeyword = 92,
InstanceOfKeyword = 93,
NewKeyword = 94,
NullKeyword = 95,
ReturnKeyword = 96,
SuperKeyword = 97,
SwitchKeyword = 98,
ThisKeyword = 99,
ThrowKeyword = 100,
TrueKeyword = 101,
TryKeyword = 102,
TypeOfKeyword = 103,
VarKeyword = 104,
VoidKeyword = 105,
WhileKeyword = 106,
WithKeyword = 107,
ImplementsKeyword = 108,
InterfaceKeyword = 109,
LetKeyword = 110,
PackageKeyword = 111,
PrivateKeyword = 112,
ProtectedKeyword = 113,
PublicKeyword = 114,
StaticKeyword = 115,
YieldKeyword = 116,
AbstractKeyword = 117,
AsKeyword = 118,
AnyKeyword = 119,
AsyncKeyword = 120,
AwaitKeyword = 121,
BooleanKeyword = 122,
ConstructorKeyword = 123,
DeclareKeyword = 124,
GetKeyword = 125,
InferKeyword = 126,
IsKeyword = 127,
KeyOfKeyword = 128,
ModuleKeyword = 129,
NamespaceKeyword = 130,
NeverKeyword = 131,
ReadonlyKeyword = 132,
RequireKeyword = 133,
NumberKeyword = 134,
ObjectKeyword = 135,
SetKeyword = 136,
StringKeyword = 137,
SymbolKeyword = 138,
TypeKeyword = 139,
UndefinedKeyword = 140,
UniqueKeyword = 141,
UnknownKeyword = 142,
FromKeyword = 143,
GlobalKeyword = 144,
OfKeyword = 145,
QualifiedName = 146,
ComputedPropertyName = 147,
TypeParameter = 148,
Parameter = 149,
Decorator = 150,
PropertySignature = 151,
PropertyDeclaration = 152,
MethodSignature = 153,
MethodDeclaration = 154,
Constructor = 155,
GetAccessor = 156,
SetAccessor = 157,
CallSignature = 158,
ConstructSignature = 159,
IndexSignature = 160,
TypePredicate = 161,
TypeReference = 162,
FunctionType = 163,
ConstructorType = 164,
TypeQuery = 165,
TypeLiteral = 166,
ArrayType = 167,
TupleType = 168,
OptionalType = 169,
RestType = 170,
UnionType = 171,
IntersectionType = 172,
ConditionalType = 173,
InferType = 174,
ParenthesizedType = 175,
ThisType = 176,
TypeOperator = 177,
IndexedAccessType = 178,
MappedType = 179,
LiteralType = 180,
ImportType = 181,
ObjectBindingPattern = 182,
ArrayBindingPattern = 183,
BindingElement = 184,
ArrayLiteralExpression = 185,
ObjectLiteralExpression = 186,
PropertyAccessExpression = 187,
ElementAccessExpression = 188,
CallExpression = 189,
NewExpression = 190,
TaggedTemplateExpression = 191,
TypeAssertionExpression = 192,
ParenthesizedExpression = 193,
FunctionExpression = 194,
ArrowFunction = 195,
DeleteExpression = 196,
TypeOfExpression = 197,
VoidExpression = 198,
AwaitExpression = 199,
PrefixUnaryExpression = 200,
PostfixUnaryExpression = 201,
BinaryExpression = 202,
ConditionalExpression = 203,
TemplateExpression = 204,
YieldExpression = 205,
SpreadElement = 206,
ClassExpression = 207,
OmittedExpression = 208,
ExpressionWithTypeArguments = 209,
AsExpression = 210,
NonNullExpression = 211,
MetaProperty = 212,
SyntheticExpression = 213,
TemplateSpan = 214,
SemicolonClassElement = 215,
Block = 216,
VariableStatement = 217,
EmptyStatement = 218,
ExpressionStatement = 219,
IfStatement = 220,
DoStatement = 221,
WhileStatement = 222,
ForStatement = 223,
ForInStatement = 224,
ForOfStatement = 225,
ContinueStatement = 226,
BreakStatement = 227,
ReturnStatement = 228,
WithStatement = 229,
SwitchStatement = 230,
LabeledStatement = 231,
ThrowStatement = 232,
TryStatement = 233,
DebuggerStatement = 234,
VariableDeclaration = 235,
VariableDeclarationList = 236,
FunctionDeclaration = 237,
ClassDeclaration = 238,
InterfaceDeclaration = 239,
TypeAliasDeclaration = 240,
EnumDeclaration = 241,
ModuleDeclaration = 242,
ModuleBlock = 243,
CaseBlock = 244,
NamespaceExportDeclaration = 245,
ImportEqualsDeclaration = 246,
ImportDeclaration = 247,
ImportClause = 248,
NamespaceImport = 249,
NamedImports = 250,
ImportSpecifier = 251,
ExportAssignment = 252,
ExportDeclaration = 253,
NamedExports = 254,
ExportSpecifier = 255,
MissingDeclaration = 256,
ExternalModuleReference = 257,
JsxElement = 258,
JsxSelfClosingElement = 259,
JsxOpeningElement = 260,
JsxClosingElement = 261,
JsxFragment = 262,
JsxOpeningFragment = 263,
JsxClosingFragment = 264,
JsxAttribute = 265,
JsxAttributes = 266,
JsxSpreadAttribute = 267,
JsxExpression = 268,
CaseClause = 269,
DefaultClause = 270,
HeritageClause = 271,
CatchClause = 272,
PropertyAssignment = 273,
ShorthandPropertyAssignment = 274,
SpreadAssignment = 275,
EnumMember = 276,
SourceFile = 277,
Bundle = 278,
UnparsedSource = 279,
InputFiles = 280,
JSDocTypeExpression = 281,
JSDocAllType = 282,
JSDocUnknownType = 283,
JSDocNullableType = 284,
JSDocNonNullableType = 285,
JSDocOptionalType = 286,
JSDocFunctionType = 287,
JSDocVariadicType = 288,
JSDocComment = 289,
JSDocTypeLiteral = 290,
JSDocSignature = 291,
JSDocTag = 292,
JSDocAugmentsTag = 293,
JSDocClassTag = 294,
JSDocCallbackTag = 295,
JSDocEnumTag = 296,
JSDocParameterTag = 297,
JSDocReturnTag = 298,
JSDocThisTag = 299,
JSDocTypeTag = 300,
JSDocTemplateTag = 301,
JSDocTypedefTag = 302,
JSDocPropertyTag = 303,
SyntaxList = 304,
NotEmittedStatement = 305,
PartiallyEmittedExpression = 306,
CommaListExpression = 307,
MergeDeclarationMarker = 308,
EndOfDeclarationMarker = 309,
Count = 310,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
LastCompoundAssignment = 70,
FirstReservedWord = 72,
LastReservedWord = 107,
FirstKeyword = 72,
LastKeyword = 145,
FirstFutureReservedWord = 108,
LastFutureReservedWord = 116,
FirstTypeNode = 161,
LastTypeNode = 181,
FirstPunctuation = 17,
LastPunctuation = 70,
BigIntLiteral = 9,
StringLiteral = 10,
JsxText = 11,
JsxTextAllWhiteSpaces = 12,
RegularExpressionLiteral = 13,
NoSubstitutionTemplateLiteral = 14,
TemplateHead = 15,
TemplateMiddle = 16,
TemplateTail = 17,
OpenBraceToken = 18,
CloseBraceToken = 19,
OpenParenToken = 20,
CloseParenToken = 21,
OpenBracketToken = 22,
CloseBracketToken = 23,
DotToken = 24,
DotDotDotToken = 25,
SemicolonToken = 26,
CommaToken = 27,
LessThanToken = 28,
LessThanSlashToken = 29,
GreaterThanToken = 30,
LessThanEqualsToken = 31,
GreaterThanEqualsToken = 32,
EqualsEqualsToken = 33,
ExclamationEqualsToken = 34,
EqualsEqualsEqualsToken = 35,
ExclamationEqualsEqualsToken = 36,
EqualsGreaterThanToken = 37,
PlusToken = 38,
MinusToken = 39,
AsteriskToken = 40,
AsteriskAsteriskToken = 41,
SlashToken = 42,
PercentToken = 43,
PlusPlusToken = 44,
MinusMinusToken = 45,
LessThanLessThanToken = 46,
GreaterThanGreaterThanToken = 47,
GreaterThanGreaterThanGreaterThanToken = 48,
AmpersandToken = 49,
BarToken = 50,
CaretToken = 51,
ExclamationToken = 52,
TildeToken = 53,
AmpersandAmpersandToken = 54,
BarBarToken = 55,
QuestionToken = 56,
ColonToken = 57,
AtToken = 58,
EqualsToken = 59,
PlusEqualsToken = 60,
MinusEqualsToken = 61,
AsteriskEqualsToken = 62,
AsteriskAsteriskEqualsToken = 63,
SlashEqualsToken = 64,
PercentEqualsToken = 65,
LessThanLessThanEqualsToken = 66,
GreaterThanGreaterThanEqualsToken = 67,
GreaterThanGreaterThanGreaterThanEqualsToken = 68,
AmpersandEqualsToken = 69,
BarEqualsToken = 70,
CaretEqualsToken = 71,
Identifier = 72,
BreakKeyword = 73,
CaseKeyword = 74,
CatchKeyword = 75,
ClassKeyword = 76,
ConstKeyword = 77,
ContinueKeyword = 78,
DebuggerKeyword = 79,
DefaultKeyword = 80,
DeleteKeyword = 81,
DoKeyword = 82,
ElseKeyword = 83,
EnumKeyword = 84,
ExportKeyword = 85,
ExtendsKeyword = 86,
FalseKeyword = 87,
FinallyKeyword = 88,
ForKeyword = 89,
FunctionKeyword = 90,
IfKeyword = 91,
ImportKeyword = 92,
InKeyword = 93,
InstanceOfKeyword = 94,
NewKeyword = 95,
NullKeyword = 96,
ReturnKeyword = 97,
SuperKeyword = 98,
SwitchKeyword = 99,
ThisKeyword = 100,
ThrowKeyword = 101,
TrueKeyword = 102,
TryKeyword = 103,
TypeOfKeyword = 104,
VarKeyword = 105,
VoidKeyword = 106,
WhileKeyword = 107,
WithKeyword = 108,
ImplementsKeyword = 109,
InterfaceKeyword = 110,
LetKeyword = 111,
PackageKeyword = 112,
PrivateKeyword = 113,
ProtectedKeyword = 114,
PublicKeyword = 115,
StaticKeyword = 116,
YieldKeyword = 117,
AbstractKeyword = 118,
AsKeyword = 119,
AnyKeyword = 120,
AsyncKeyword = 121,
AwaitKeyword = 122,
BooleanKeyword = 123,
ConstructorKeyword = 124,
DeclareKeyword = 125,
GetKeyword = 126,
InferKeyword = 127,
IsKeyword = 128,
KeyOfKeyword = 129,
ModuleKeyword = 130,
NamespaceKeyword = 131,
NeverKeyword = 132,
ReadonlyKeyword = 133,
RequireKeyword = 134,
NumberKeyword = 135,
ObjectKeyword = 136,
SetKeyword = 137,
StringKeyword = 138,
SymbolKeyword = 139,
TypeKeyword = 140,
UndefinedKeyword = 141,
UniqueKeyword = 142,
UnknownKeyword = 143,
FromKeyword = 144,
GlobalKeyword = 145,
BigIntKeyword = 146,
OfKeyword = 147,
QualifiedName = 148,
ComputedPropertyName = 149,
TypeParameter = 150,
Parameter = 151,
Decorator = 152,
PropertySignature = 153,
PropertyDeclaration = 154,
MethodSignature = 155,
MethodDeclaration = 156,
Constructor = 157,
GetAccessor = 158,
SetAccessor = 159,
CallSignature = 160,
ConstructSignature = 161,
IndexSignature = 162,
TypePredicate = 163,
TypeReference = 164,
FunctionType = 165,
ConstructorType = 166,
TypeQuery = 167,
TypeLiteral = 168,
ArrayType = 169,
TupleType = 170,
OptionalType = 171,
RestType = 172,
UnionType = 173,
IntersectionType = 174,
ConditionalType = 175,
InferType = 176,
ParenthesizedType = 177,
ThisType = 178,
TypeOperator = 179,
IndexedAccessType = 180,
MappedType = 181,
LiteralType = 182,
ImportType = 183,
ObjectBindingPattern = 184,
ArrayBindingPattern = 185,
BindingElement = 186,
ArrayLiteralExpression = 187,
ObjectLiteralExpression = 188,
PropertyAccessExpression = 189,
ElementAccessExpression = 190,
CallExpression = 191,
NewExpression = 192,
TaggedTemplateExpression = 193,
TypeAssertionExpression = 194,
ParenthesizedExpression = 195,
FunctionExpression = 196,
ArrowFunction = 197,
DeleteExpression = 198,
TypeOfExpression = 199,
VoidExpression = 200,
AwaitExpression = 201,
PrefixUnaryExpression = 202,
PostfixUnaryExpression = 203,
BinaryExpression = 204,
ConditionalExpression = 205,
TemplateExpression = 206,
YieldExpression = 207,
SpreadElement = 208,
ClassExpression = 209,
OmittedExpression = 210,
ExpressionWithTypeArguments = 211,
AsExpression = 212,
NonNullExpression = 213,
MetaProperty = 214,
SyntheticExpression = 215,
TemplateSpan = 216,
SemicolonClassElement = 217,
Block = 218,
VariableStatement = 219,
EmptyStatement = 220,
ExpressionStatement = 221,
IfStatement = 222,
DoStatement = 223,
WhileStatement = 224,
ForStatement = 225,
ForInStatement = 226,
ForOfStatement = 227,
ContinueStatement = 228,
BreakStatement = 229,
ReturnStatement = 230,
WithStatement = 231,
SwitchStatement = 232,
LabeledStatement = 233,
ThrowStatement = 234,
TryStatement = 235,
DebuggerStatement = 236,
VariableDeclaration = 237,
VariableDeclarationList = 238,
FunctionDeclaration = 239,
ClassDeclaration = 240,
InterfaceDeclaration = 241,
TypeAliasDeclaration = 242,
EnumDeclaration = 243,
ModuleDeclaration = 244,
ModuleBlock = 245,
CaseBlock = 246,
NamespaceExportDeclaration = 247,
ImportEqualsDeclaration = 248,
ImportDeclaration = 249,
ImportClause = 250,
NamespaceImport = 251,
NamedImports = 252,
ImportSpecifier = 253,
ExportAssignment = 254,
ExportDeclaration = 255,
NamedExports = 256,
ExportSpecifier = 257,
MissingDeclaration = 258,
ExternalModuleReference = 259,
JsxElement = 260,
JsxSelfClosingElement = 261,
JsxOpeningElement = 262,
JsxClosingElement = 263,
JsxFragment = 264,
JsxOpeningFragment = 265,
JsxClosingFragment = 266,
JsxAttribute = 267,
JsxAttributes = 268,
JsxSpreadAttribute = 269,
JsxExpression = 270,
CaseClause = 271,
DefaultClause = 272,
HeritageClause = 273,
CatchClause = 274,
PropertyAssignment = 275,
ShorthandPropertyAssignment = 276,
SpreadAssignment = 277,
EnumMember = 278,
SourceFile = 279,
Bundle = 280,
UnparsedSource = 281,
InputFiles = 282,
JSDocTypeExpression = 283,
JSDocAllType = 284,
JSDocUnknownType = 285,
JSDocNullableType = 286,
JSDocNonNullableType = 287,
JSDocOptionalType = 288,
JSDocFunctionType = 289,
JSDocVariadicType = 290,
JSDocComment = 291,
JSDocTypeLiteral = 292,
JSDocSignature = 293,
JSDocTag = 294,
JSDocAugmentsTag = 295,
JSDocClassTag = 296,
JSDocCallbackTag = 297,
JSDocEnumTag = 298,
JSDocParameterTag = 299,
JSDocReturnTag = 300,
JSDocThisTag = 301,
JSDocTypeTag = 302,
JSDocTemplateTag = 303,
JSDocTypedefTag = 304,
JSDocPropertyTag = 305,
SyntaxList = 306,
NotEmittedStatement = 307,
PartiallyEmittedExpression = 308,
CommaListExpression = 309,
MergeDeclarationMarker = 310,
EndOfDeclarationMarker = 311,
Count = 312,
FirstAssignment = 59,
LastAssignment = 71,
FirstCompoundAssignment = 60,
LastCompoundAssignment = 71,
FirstReservedWord = 73,
LastReservedWord = 108,
FirstKeyword = 73,
LastKeyword = 147,
FirstFutureReservedWord = 109,
LastFutureReservedWord = 117,
FirstTypeNode = 163,
LastTypeNode = 183,
FirstPunctuation = 18,
LastPunctuation = 71,
FirstToken = 0,
LastToken = 145,
LastToken = 147,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
LastLiteralToken = 13,
FirstTemplateToken = 13,
LastTemplateToken = 16,
FirstBinaryOperator = 27,
LastBinaryOperator = 70,
FirstNode = 146,
FirstJSDocNode = 281,
LastJSDocNode = 303,
FirstJSDocTagNode = 292,
LastJSDocTagNode = 303
LastLiteralToken = 14,
FirstTemplateToken = 14,
LastTemplateToken = 17,
FirstBinaryOperator = 28,
LastBinaryOperator = 71,
FirstNode = 148,
FirstJSDocNode = 283,
LastJSDocNode = 305,
FirstJSDocTagNode = 294,
LastJSDocTagNode = 305
}
enum NodeFlags {
None = 0,
@@ -502,7 +504,6 @@ declare namespace ts {
type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
type AtToken = Token<SyntaxKind.AtToken>;
type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
type PlusToken = Token<SyntaxKind.PlusToken>;
@@ -727,7 +728,7 @@ declare namespace ts {
_typeNodeBrand: any;
}
interface KeywordTypeNode extends TypeNode {
kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword;
kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword;
}
interface ImportTypeNode extends NodeWithTypeArguments {
kind: SyntaxKind.ImportType;
@@ -999,6 +1000,9 @@ declare namespace ts {
interface NumericLiteral extends LiteralExpression {
kind: SyntaxKind.NumericLiteral;
}
interface BigIntLiteral extends LiteralExpression {
kind: SyntaxKind.BigIntLiteral;
}
interface TemplateHead extends LiteralLikeNode {
kind: SyntaxKind.TemplateHead;
parent: TemplateExpression;
@@ -1546,7 +1550,6 @@ declare namespace ts {
}
interface JSDocTag extends Node {
parent: JSDoc | JSDocTypeLiteral;
atToken: AtToken;
tagName: Identifier;
comment?: string;
}
@@ -2164,44 +2167,47 @@ declare namespace ts {
Number = 8,
Boolean = 16,
Enum = 32,
StringLiteral = 64,
NumberLiteral = 128,
BooleanLiteral = 256,
EnumLiteral = 512,
ESSymbol = 1024,
UniqueESSymbol = 2048,
Void = 4096,
Undefined = 8192,
Null = 16384,
Never = 32768,
TypeParameter = 65536,
Object = 131072,
Union = 262144,
Intersection = 524288,
Index = 1048576,
IndexedAccess = 2097152,
Conditional = 4194304,
Substitution = 8388608,
NonPrimitive = 16777216,
Literal = 448,
Unit = 27072,
StringOrNumberLiteral = 192,
PossiblyFalsy = 29148,
StringLike = 68,
NumberLike = 168,
BooleanLike = 272,
EnumLike = 544,
ESSymbolLike = 3072,
VoidLike = 12288,
UnionOrIntersection = 786432,
StructuredType = 917504,
TypeVariable = 2162688,
InstantiableNonPrimitive = 14745600,
InstantiablePrimitive = 1048576,
Instantiable = 15794176,
StructuredOrInstantiable = 16711680,
Narrowable = 33492479,
NotUnionOrUnit = 16909315
BigInt = 64,
StringLiteral = 128,
NumberLiteral = 256,
BooleanLiteral = 512,
EnumLiteral = 1024,
BigIntLiteral = 2048,
ESSymbol = 4096,
UniqueESSymbol = 8192,
Void = 16384,
Undefined = 32768,
Null = 65536,
Never = 131072,
TypeParameter = 262144,
Object = 524288,
Union = 1048576,
Intersection = 2097152,
Index = 4194304,
IndexedAccess = 8388608,
Conditional = 16777216,
Substitution = 33554432,
NonPrimitive = 67108864,
Literal = 2944,
Unit = 109440,
StringOrNumberLiteral = 384,
PossiblyFalsy = 117724,
StringLike = 132,
NumberLike = 296,
BigIntLike = 2112,
BooleanLike = 528,
EnumLike = 1056,
ESSymbolLike = 12288,
VoidLike = 49152,
UnionOrIntersection = 3145728,
StructuredType = 3670016,
TypeVariable = 8650752,
InstantiableNonPrimitive = 58982400,
InstantiablePrimitive = 4194304,
Instantiable = 63176704,
StructuredOrInstantiable = 66846720,
Narrowable = 133970943,
NotUnionOrUnit = 67637251
}
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
@@ -2212,7 +2218,7 @@ declare namespace ts {
aliasTypeArguments?: ReadonlyArray<Type>;
}
interface LiteralType extends Type {
value: string | number;
value: string | number | PseudoBigInt;
freshType: LiteralType;
regularType: LiteralType;
}
@@ -2225,6 +2231,9 @@ declare namespace ts {
interface NumberLiteralType extends LiteralType {
value: number;
}
interface BigIntLiteralType extends LiteralType {
value: PseudoBigInt;
}
interface EnumType extends Type {
}
enum ObjectFlags {
@@ -2243,6 +2252,7 @@ declare namespace ts {
JsxAttributes = 4096,
MarkerType = 8192,
JSLiteral = 16384,
FreshLiteral = 32768,
ClassOrInterface = 3
}
interface ObjectType extends Type {
@@ -2451,6 +2461,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
@@ -3013,6 +3024,11 @@ declare namespace ts {
readonly importModuleSpecifierEnding?: "minimal" | "index" | "js";
readonly allowTextChangesInNewFiles?: boolean;
}
/** Represents a bigint literal value without requiring bigint support */
interface PseudoBigInt {
negative: boolean;
base10Value: string;
}
}
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
declare function clearTimeout(handle: any): void;
@@ -3295,6 +3311,7 @@ declare namespace ts {
}
declare namespace ts {
function isNumericLiteral(node: Node): node is NumericLiteral;
function isBigIntLiteral(node: Node): node is BigIntLiteral;
function isStringLiteral(node: Node): node is StringLiteral;
function isJsxText(node: Node): node is JsxText;
function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral;
@@ -3652,10 +3669,11 @@ declare namespace ts {
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: number): NumericLiteral;
function createLiteral(value: number | PseudoBigInt): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createBigIntLiteral(value: string): BigIntLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
function createIdentifier(text: string): Identifier;
@@ -4671,6 +4689,9 @@ declare namespace ts {
installPackage?(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
writeFile?(fileName: string, content: string): void;
}
type WithMetadata<T> = T & {
metadata?: unknown;
};
interface LanguageService {
cleanupSemanticCache(): void;
getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[];
@@ -4688,7 +4709,7 @@ declare namespace ts {
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata<CompletionInfo> | undefined;
getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined;
getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
@@ -5256,8 +5277,9 @@ declare namespace ts {
Whitespace = 4,
Identifier = 5,
NumberLiteral = 6,
StringLiteral = 7,
RegExpLiteral = 8
BigIntLiteral = 7,
StringLiteral = 8,
RegExpLiteral = 9
}
interface ClassificationResult {
finalLexState: EndOfLineState;
@@ -5382,6 +5404,7 @@ declare namespace ts {
identifier = "identifier",
keyword = "keyword",
numericLiteral = "number",
bigintLiteral = "bigint",
operator = "operator",
stringLiteral = "string",
whiteSpace = "whitespace",
@@ -5426,7 +5449,8 @@ declare namespace ts {
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24
jsxAttributeStringLiteralValue = 24,
bigintLiteral = 25
}
}
declare namespace ts {
@@ -5767,6 +5791,10 @@ declare namespace ts.server.protocol {
* Contains message body if success === true.
*/
body?: any;
/**
* Contains extra information that plugin can include to be passed on
*/
metadata?: unknown;
}
/**
* Arguments for FileRequest messages.
+400 -376
View File
@@ -73,7 +73,7 @@ declare namespace ts {
end: number;
}
type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind;
type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
enum SyntaxKind {
Unknown = 0,
@@ -85,337 +85,339 @@ declare namespace ts {
ShebangTrivia = 6,
ConflictMarkerTrivia = 7,
NumericLiteral = 8,
StringLiteral = 9,
JsxText = 10,
JsxTextAllWhiteSpaces = 11,
RegularExpressionLiteral = 12,
NoSubstitutionTemplateLiteral = 13,
TemplateHead = 14,
TemplateMiddle = 15,
TemplateTail = 16,
OpenBraceToken = 17,
CloseBraceToken = 18,
OpenParenToken = 19,
CloseParenToken = 20,
OpenBracketToken = 21,
CloseBracketToken = 22,
DotToken = 23,
DotDotDotToken = 24,
SemicolonToken = 25,
CommaToken = 26,
LessThanToken = 27,
LessThanSlashToken = 28,
GreaterThanToken = 29,
LessThanEqualsToken = 30,
GreaterThanEqualsToken = 31,
EqualsEqualsToken = 32,
ExclamationEqualsToken = 33,
EqualsEqualsEqualsToken = 34,
ExclamationEqualsEqualsToken = 35,
EqualsGreaterThanToken = 36,
PlusToken = 37,
MinusToken = 38,
AsteriskToken = 39,
AsteriskAsteriskToken = 40,
SlashToken = 41,
PercentToken = 42,
PlusPlusToken = 43,
MinusMinusToken = 44,
LessThanLessThanToken = 45,
GreaterThanGreaterThanToken = 46,
GreaterThanGreaterThanGreaterThanToken = 47,
AmpersandToken = 48,
BarToken = 49,
CaretToken = 50,
ExclamationToken = 51,
TildeToken = 52,
AmpersandAmpersandToken = 53,
BarBarToken = 54,
QuestionToken = 55,
ColonToken = 56,
AtToken = 57,
EqualsToken = 58,
PlusEqualsToken = 59,
MinusEqualsToken = 60,
AsteriskEqualsToken = 61,
AsteriskAsteriskEqualsToken = 62,
SlashEqualsToken = 63,
PercentEqualsToken = 64,
LessThanLessThanEqualsToken = 65,
GreaterThanGreaterThanEqualsToken = 66,
GreaterThanGreaterThanGreaterThanEqualsToken = 67,
AmpersandEqualsToken = 68,
BarEqualsToken = 69,
CaretEqualsToken = 70,
Identifier = 71,
BreakKeyword = 72,
CaseKeyword = 73,
CatchKeyword = 74,
ClassKeyword = 75,
ConstKeyword = 76,
ContinueKeyword = 77,
DebuggerKeyword = 78,
DefaultKeyword = 79,
DeleteKeyword = 80,
DoKeyword = 81,
ElseKeyword = 82,
EnumKeyword = 83,
ExportKeyword = 84,
ExtendsKeyword = 85,
FalseKeyword = 86,
FinallyKeyword = 87,
ForKeyword = 88,
FunctionKeyword = 89,
IfKeyword = 90,
ImportKeyword = 91,
InKeyword = 92,
InstanceOfKeyword = 93,
NewKeyword = 94,
NullKeyword = 95,
ReturnKeyword = 96,
SuperKeyword = 97,
SwitchKeyword = 98,
ThisKeyword = 99,
ThrowKeyword = 100,
TrueKeyword = 101,
TryKeyword = 102,
TypeOfKeyword = 103,
VarKeyword = 104,
VoidKeyword = 105,
WhileKeyword = 106,
WithKeyword = 107,
ImplementsKeyword = 108,
InterfaceKeyword = 109,
LetKeyword = 110,
PackageKeyword = 111,
PrivateKeyword = 112,
ProtectedKeyword = 113,
PublicKeyword = 114,
StaticKeyword = 115,
YieldKeyword = 116,
AbstractKeyword = 117,
AsKeyword = 118,
AnyKeyword = 119,
AsyncKeyword = 120,
AwaitKeyword = 121,
BooleanKeyword = 122,
ConstructorKeyword = 123,
DeclareKeyword = 124,
GetKeyword = 125,
InferKeyword = 126,
IsKeyword = 127,
KeyOfKeyword = 128,
ModuleKeyword = 129,
NamespaceKeyword = 130,
NeverKeyword = 131,
ReadonlyKeyword = 132,
RequireKeyword = 133,
NumberKeyword = 134,
ObjectKeyword = 135,
SetKeyword = 136,
StringKeyword = 137,
SymbolKeyword = 138,
TypeKeyword = 139,
UndefinedKeyword = 140,
UniqueKeyword = 141,
UnknownKeyword = 142,
FromKeyword = 143,
GlobalKeyword = 144,
OfKeyword = 145,
QualifiedName = 146,
ComputedPropertyName = 147,
TypeParameter = 148,
Parameter = 149,
Decorator = 150,
PropertySignature = 151,
PropertyDeclaration = 152,
MethodSignature = 153,
MethodDeclaration = 154,
Constructor = 155,
GetAccessor = 156,
SetAccessor = 157,
CallSignature = 158,
ConstructSignature = 159,
IndexSignature = 160,
TypePredicate = 161,
TypeReference = 162,
FunctionType = 163,
ConstructorType = 164,
TypeQuery = 165,
TypeLiteral = 166,
ArrayType = 167,
TupleType = 168,
OptionalType = 169,
RestType = 170,
UnionType = 171,
IntersectionType = 172,
ConditionalType = 173,
InferType = 174,
ParenthesizedType = 175,
ThisType = 176,
TypeOperator = 177,
IndexedAccessType = 178,
MappedType = 179,
LiteralType = 180,
ImportType = 181,
ObjectBindingPattern = 182,
ArrayBindingPattern = 183,
BindingElement = 184,
ArrayLiteralExpression = 185,
ObjectLiteralExpression = 186,
PropertyAccessExpression = 187,
ElementAccessExpression = 188,
CallExpression = 189,
NewExpression = 190,
TaggedTemplateExpression = 191,
TypeAssertionExpression = 192,
ParenthesizedExpression = 193,
FunctionExpression = 194,
ArrowFunction = 195,
DeleteExpression = 196,
TypeOfExpression = 197,
VoidExpression = 198,
AwaitExpression = 199,
PrefixUnaryExpression = 200,
PostfixUnaryExpression = 201,
BinaryExpression = 202,
ConditionalExpression = 203,
TemplateExpression = 204,
YieldExpression = 205,
SpreadElement = 206,
ClassExpression = 207,
OmittedExpression = 208,
ExpressionWithTypeArguments = 209,
AsExpression = 210,
NonNullExpression = 211,
MetaProperty = 212,
SyntheticExpression = 213,
TemplateSpan = 214,
SemicolonClassElement = 215,
Block = 216,
VariableStatement = 217,
EmptyStatement = 218,
ExpressionStatement = 219,
IfStatement = 220,
DoStatement = 221,
WhileStatement = 222,
ForStatement = 223,
ForInStatement = 224,
ForOfStatement = 225,
ContinueStatement = 226,
BreakStatement = 227,
ReturnStatement = 228,
WithStatement = 229,
SwitchStatement = 230,
LabeledStatement = 231,
ThrowStatement = 232,
TryStatement = 233,
DebuggerStatement = 234,
VariableDeclaration = 235,
VariableDeclarationList = 236,
FunctionDeclaration = 237,
ClassDeclaration = 238,
InterfaceDeclaration = 239,
TypeAliasDeclaration = 240,
EnumDeclaration = 241,
ModuleDeclaration = 242,
ModuleBlock = 243,
CaseBlock = 244,
NamespaceExportDeclaration = 245,
ImportEqualsDeclaration = 246,
ImportDeclaration = 247,
ImportClause = 248,
NamespaceImport = 249,
NamedImports = 250,
ImportSpecifier = 251,
ExportAssignment = 252,
ExportDeclaration = 253,
NamedExports = 254,
ExportSpecifier = 255,
MissingDeclaration = 256,
ExternalModuleReference = 257,
JsxElement = 258,
JsxSelfClosingElement = 259,
JsxOpeningElement = 260,
JsxClosingElement = 261,
JsxFragment = 262,
JsxOpeningFragment = 263,
JsxClosingFragment = 264,
JsxAttribute = 265,
JsxAttributes = 266,
JsxSpreadAttribute = 267,
JsxExpression = 268,
CaseClause = 269,
DefaultClause = 270,
HeritageClause = 271,
CatchClause = 272,
PropertyAssignment = 273,
ShorthandPropertyAssignment = 274,
SpreadAssignment = 275,
EnumMember = 276,
SourceFile = 277,
Bundle = 278,
UnparsedSource = 279,
InputFiles = 280,
JSDocTypeExpression = 281,
JSDocAllType = 282,
JSDocUnknownType = 283,
JSDocNullableType = 284,
JSDocNonNullableType = 285,
JSDocOptionalType = 286,
JSDocFunctionType = 287,
JSDocVariadicType = 288,
JSDocComment = 289,
JSDocTypeLiteral = 290,
JSDocSignature = 291,
JSDocTag = 292,
JSDocAugmentsTag = 293,
JSDocClassTag = 294,
JSDocCallbackTag = 295,
JSDocEnumTag = 296,
JSDocParameterTag = 297,
JSDocReturnTag = 298,
JSDocThisTag = 299,
JSDocTypeTag = 300,
JSDocTemplateTag = 301,
JSDocTypedefTag = 302,
JSDocPropertyTag = 303,
SyntaxList = 304,
NotEmittedStatement = 305,
PartiallyEmittedExpression = 306,
CommaListExpression = 307,
MergeDeclarationMarker = 308,
EndOfDeclarationMarker = 309,
Count = 310,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
LastCompoundAssignment = 70,
FirstReservedWord = 72,
LastReservedWord = 107,
FirstKeyword = 72,
LastKeyword = 145,
FirstFutureReservedWord = 108,
LastFutureReservedWord = 116,
FirstTypeNode = 161,
LastTypeNode = 181,
FirstPunctuation = 17,
LastPunctuation = 70,
BigIntLiteral = 9,
StringLiteral = 10,
JsxText = 11,
JsxTextAllWhiteSpaces = 12,
RegularExpressionLiteral = 13,
NoSubstitutionTemplateLiteral = 14,
TemplateHead = 15,
TemplateMiddle = 16,
TemplateTail = 17,
OpenBraceToken = 18,
CloseBraceToken = 19,
OpenParenToken = 20,
CloseParenToken = 21,
OpenBracketToken = 22,
CloseBracketToken = 23,
DotToken = 24,
DotDotDotToken = 25,
SemicolonToken = 26,
CommaToken = 27,
LessThanToken = 28,
LessThanSlashToken = 29,
GreaterThanToken = 30,
LessThanEqualsToken = 31,
GreaterThanEqualsToken = 32,
EqualsEqualsToken = 33,
ExclamationEqualsToken = 34,
EqualsEqualsEqualsToken = 35,
ExclamationEqualsEqualsToken = 36,
EqualsGreaterThanToken = 37,
PlusToken = 38,
MinusToken = 39,
AsteriskToken = 40,
AsteriskAsteriskToken = 41,
SlashToken = 42,
PercentToken = 43,
PlusPlusToken = 44,
MinusMinusToken = 45,
LessThanLessThanToken = 46,
GreaterThanGreaterThanToken = 47,
GreaterThanGreaterThanGreaterThanToken = 48,
AmpersandToken = 49,
BarToken = 50,
CaretToken = 51,
ExclamationToken = 52,
TildeToken = 53,
AmpersandAmpersandToken = 54,
BarBarToken = 55,
QuestionToken = 56,
ColonToken = 57,
AtToken = 58,
EqualsToken = 59,
PlusEqualsToken = 60,
MinusEqualsToken = 61,
AsteriskEqualsToken = 62,
AsteriskAsteriskEqualsToken = 63,
SlashEqualsToken = 64,
PercentEqualsToken = 65,
LessThanLessThanEqualsToken = 66,
GreaterThanGreaterThanEqualsToken = 67,
GreaterThanGreaterThanGreaterThanEqualsToken = 68,
AmpersandEqualsToken = 69,
BarEqualsToken = 70,
CaretEqualsToken = 71,
Identifier = 72,
BreakKeyword = 73,
CaseKeyword = 74,
CatchKeyword = 75,
ClassKeyword = 76,
ConstKeyword = 77,
ContinueKeyword = 78,
DebuggerKeyword = 79,
DefaultKeyword = 80,
DeleteKeyword = 81,
DoKeyword = 82,
ElseKeyword = 83,
EnumKeyword = 84,
ExportKeyword = 85,
ExtendsKeyword = 86,
FalseKeyword = 87,
FinallyKeyword = 88,
ForKeyword = 89,
FunctionKeyword = 90,
IfKeyword = 91,
ImportKeyword = 92,
InKeyword = 93,
InstanceOfKeyword = 94,
NewKeyword = 95,
NullKeyword = 96,
ReturnKeyword = 97,
SuperKeyword = 98,
SwitchKeyword = 99,
ThisKeyword = 100,
ThrowKeyword = 101,
TrueKeyword = 102,
TryKeyword = 103,
TypeOfKeyword = 104,
VarKeyword = 105,
VoidKeyword = 106,
WhileKeyword = 107,
WithKeyword = 108,
ImplementsKeyword = 109,
InterfaceKeyword = 110,
LetKeyword = 111,
PackageKeyword = 112,
PrivateKeyword = 113,
ProtectedKeyword = 114,
PublicKeyword = 115,
StaticKeyword = 116,
YieldKeyword = 117,
AbstractKeyword = 118,
AsKeyword = 119,
AnyKeyword = 120,
AsyncKeyword = 121,
AwaitKeyword = 122,
BooleanKeyword = 123,
ConstructorKeyword = 124,
DeclareKeyword = 125,
GetKeyword = 126,
InferKeyword = 127,
IsKeyword = 128,
KeyOfKeyword = 129,
ModuleKeyword = 130,
NamespaceKeyword = 131,
NeverKeyword = 132,
ReadonlyKeyword = 133,
RequireKeyword = 134,
NumberKeyword = 135,
ObjectKeyword = 136,
SetKeyword = 137,
StringKeyword = 138,
SymbolKeyword = 139,
TypeKeyword = 140,
UndefinedKeyword = 141,
UniqueKeyword = 142,
UnknownKeyword = 143,
FromKeyword = 144,
GlobalKeyword = 145,
BigIntKeyword = 146,
OfKeyword = 147,
QualifiedName = 148,
ComputedPropertyName = 149,
TypeParameter = 150,
Parameter = 151,
Decorator = 152,
PropertySignature = 153,
PropertyDeclaration = 154,
MethodSignature = 155,
MethodDeclaration = 156,
Constructor = 157,
GetAccessor = 158,
SetAccessor = 159,
CallSignature = 160,
ConstructSignature = 161,
IndexSignature = 162,
TypePredicate = 163,
TypeReference = 164,
FunctionType = 165,
ConstructorType = 166,
TypeQuery = 167,
TypeLiteral = 168,
ArrayType = 169,
TupleType = 170,
OptionalType = 171,
RestType = 172,
UnionType = 173,
IntersectionType = 174,
ConditionalType = 175,
InferType = 176,
ParenthesizedType = 177,
ThisType = 178,
TypeOperator = 179,
IndexedAccessType = 180,
MappedType = 181,
LiteralType = 182,
ImportType = 183,
ObjectBindingPattern = 184,
ArrayBindingPattern = 185,
BindingElement = 186,
ArrayLiteralExpression = 187,
ObjectLiteralExpression = 188,
PropertyAccessExpression = 189,
ElementAccessExpression = 190,
CallExpression = 191,
NewExpression = 192,
TaggedTemplateExpression = 193,
TypeAssertionExpression = 194,
ParenthesizedExpression = 195,
FunctionExpression = 196,
ArrowFunction = 197,
DeleteExpression = 198,
TypeOfExpression = 199,
VoidExpression = 200,
AwaitExpression = 201,
PrefixUnaryExpression = 202,
PostfixUnaryExpression = 203,
BinaryExpression = 204,
ConditionalExpression = 205,
TemplateExpression = 206,
YieldExpression = 207,
SpreadElement = 208,
ClassExpression = 209,
OmittedExpression = 210,
ExpressionWithTypeArguments = 211,
AsExpression = 212,
NonNullExpression = 213,
MetaProperty = 214,
SyntheticExpression = 215,
TemplateSpan = 216,
SemicolonClassElement = 217,
Block = 218,
VariableStatement = 219,
EmptyStatement = 220,
ExpressionStatement = 221,
IfStatement = 222,
DoStatement = 223,
WhileStatement = 224,
ForStatement = 225,
ForInStatement = 226,
ForOfStatement = 227,
ContinueStatement = 228,
BreakStatement = 229,
ReturnStatement = 230,
WithStatement = 231,
SwitchStatement = 232,
LabeledStatement = 233,
ThrowStatement = 234,
TryStatement = 235,
DebuggerStatement = 236,
VariableDeclaration = 237,
VariableDeclarationList = 238,
FunctionDeclaration = 239,
ClassDeclaration = 240,
InterfaceDeclaration = 241,
TypeAliasDeclaration = 242,
EnumDeclaration = 243,
ModuleDeclaration = 244,
ModuleBlock = 245,
CaseBlock = 246,
NamespaceExportDeclaration = 247,
ImportEqualsDeclaration = 248,
ImportDeclaration = 249,
ImportClause = 250,
NamespaceImport = 251,
NamedImports = 252,
ImportSpecifier = 253,
ExportAssignment = 254,
ExportDeclaration = 255,
NamedExports = 256,
ExportSpecifier = 257,
MissingDeclaration = 258,
ExternalModuleReference = 259,
JsxElement = 260,
JsxSelfClosingElement = 261,
JsxOpeningElement = 262,
JsxClosingElement = 263,
JsxFragment = 264,
JsxOpeningFragment = 265,
JsxClosingFragment = 266,
JsxAttribute = 267,
JsxAttributes = 268,
JsxSpreadAttribute = 269,
JsxExpression = 270,
CaseClause = 271,
DefaultClause = 272,
HeritageClause = 273,
CatchClause = 274,
PropertyAssignment = 275,
ShorthandPropertyAssignment = 276,
SpreadAssignment = 277,
EnumMember = 278,
SourceFile = 279,
Bundle = 280,
UnparsedSource = 281,
InputFiles = 282,
JSDocTypeExpression = 283,
JSDocAllType = 284,
JSDocUnknownType = 285,
JSDocNullableType = 286,
JSDocNonNullableType = 287,
JSDocOptionalType = 288,
JSDocFunctionType = 289,
JSDocVariadicType = 290,
JSDocComment = 291,
JSDocTypeLiteral = 292,
JSDocSignature = 293,
JSDocTag = 294,
JSDocAugmentsTag = 295,
JSDocClassTag = 296,
JSDocCallbackTag = 297,
JSDocEnumTag = 298,
JSDocParameterTag = 299,
JSDocReturnTag = 300,
JSDocThisTag = 301,
JSDocTypeTag = 302,
JSDocTemplateTag = 303,
JSDocTypedefTag = 304,
JSDocPropertyTag = 305,
SyntaxList = 306,
NotEmittedStatement = 307,
PartiallyEmittedExpression = 308,
CommaListExpression = 309,
MergeDeclarationMarker = 310,
EndOfDeclarationMarker = 311,
Count = 312,
FirstAssignment = 59,
LastAssignment = 71,
FirstCompoundAssignment = 60,
LastCompoundAssignment = 71,
FirstReservedWord = 73,
LastReservedWord = 108,
FirstKeyword = 73,
LastKeyword = 147,
FirstFutureReservedWord = 109,
LastFutureReservedWord = 117,
FirstTypeNode = 163,
LastTypeNode = 183,
FirstPunctuation = 18,
LastPunctuation = 71,
FirstToken = 0,
LastToken = 145,
LastToken = 147,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
LastLiteralToken = 13,
FirstTemplateToken = 13,
LastTemplateToken = 16,
FirstBinaryOperator = 27,
LastBinaryOperator = 70,
FirstNode = 146,
FirstJSDocNode = 281,
LastJSDocNode = 303,
FirstJSDocTagNode = 292,
LastJSDocTagNode = 303
LastLiteralToken = 14,
FirstTemplateToken = 14,
LastTemplateToken = 17,
FirstBinaryOperator = 28,
LastBinaryOperator = 71,
FirstNode = 148,
FirstJSDocNode = 283,
LastJSDocNode = 305,
FirstJSDocTagNode = 294,
LastJSDocTagNode = 305
}
enum NodeFlags {
None = 0,
@@ -502,7 +504,6 @@ declare namespace ts {
type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
type AtToken = Token<SyntaxKind.AtToken>;
type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
type PlusToken = Token<SyntaxKind.PlusToken>;
@@ -727,7 +728,7 @@ declare namespace ts {
_typeNodeBrand: any;
}
interface KeywordTypeNode extends TypeNode {
kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword;
kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword;
}
interface ImportTypeNode extends NodeWithTypeArguments {
kind: SyntaxKind.ImportType;
@@ -999,6 +1000,9 @@ declare namespace ts {
interface NumericLiteral extends LiteralExpression {
kind: SyntaxKind.NumericLiteral;
}
interface BigIntLiteral extends LiteralExpression {
kind: SyntaxKind.BigIntLiteral;
}
interface TemplateHead extends LiteralLikeNode {
kind: SyntaxKind.TemplateHead;
parent: TemplateExpression;
@@ -1546,7 +1550,6 @@ declare namespace ts {
}
interface JSDocTag extends Node {
parent: JSDoc | JSDocTypeLiteral;
atToken: AtToken;
tagName: Identifier;
comment?: string;
}
@@ -2164,44 +2167,47 @@ declare namespace ts {
Number = 8,
Boolean = 16,
Enum = 32,
StringLiteral = 64,
NumberLiteral = 128,
BooleanLiteral = 256,
EnumLiteral = 512,
ESSymbol = 1024,
UniqueESSymbol = 2048,
Void = 4096,
Undefined = 8192,
Null = 16384,
Never = 32768,
TypeParameter = 65536,
Object = 131072,
Union = 262144,
Intersection = 524288,
Index = 1048576,
IndexedAccess = 2097152,
Conditional = 4194304,
Substitution = 8388608,
NonPrimitive = 16777216,
Literal = 448,
Unit = 27072,
StringOrNumberLiteral = 192,
PossiblyFalsy = 29148,
StringLike = 68,
NumberLike = 168,
BooleanLike = 272,
EnumLike = 544,
ESSymbolLike = 3072,
VoidLike = 12288,
UnionOrIntersection = 786432,
StructuredType = 917504,
TypeVariable = 2162688,
InstantiableNonPrimitive = 14745600,
InstantiablePrimitive = 1048576,
Instantiable = 15794176,
StructuredOrInstantiable = 16711680,
Narrowable = 33492479,
NotUnionOrUnit = 16909315
BigInt = 64,
StringLiteral = 128,
NumberLiteral = 256,
BooleanLiteral = 512,
EnumLiteral = 1024,
BigIntLiteral = 2048,
ESSymbol = 4096,
UniqueESSymbol = 8192,
Void = 16384,
Undefined = 32768,
Null = 65536,
Never = 131072,
TypeParameter = 262144,
Object = 524288,
Union = 1048576,
Intersection = 2097152,
Index = 4194304,
IndexedAccess = 8388608,
Conditional = 16777216,
Substitution = 33554432,
NonPrimitive = 67108864,
Literal = 2944,
Unit = 109440,
StringOrNumberLiteral = 384,
PossiblyFalsy = 117724,
StringLike = 132,
NumberLike = 296,
BigIntLike = 2112,
BooleanLike = 528,
EnumLike = 1056,
ESSymbolLike = 12288,
VoidLike = 49152,
UnionOrIntersection = 3145728,
StructuredType = 3670016,
TypeVariable = 8650752,
InstantiableNonPrimitive = 58982400,
InstantiablePrimitive = 4194304,
Instantiable = 63176704,
StructuredOrInstantiable = 66846720,
Narrowable = 133970943,
NotUnionOrUnit = 67637251
}
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
@@ -2212,7 +2218,7 @@ declare namespace ts {
aliasTypeArguments?: ReadonlyArray<Type>;
}
interface LiteralType extends Type {
value: string | number;
value: string | number | PseudoBigInt;
freshType: LiteralType;
regularType: LiteralType;
}
@@ -2225,6 +2231,9 @@ declare namespace ts {
interface NumberLiteralType extends LiteralType {
value: number;
}
interface BigIntLiteralType extends LiteralType {
value: PseudoBigInt;
}
interface EnumType extends Type {
}
enum ObjectFlags {
@@ -2243,6 +2252,7 @@ declare namespace ts {
JsxAttributes = 4096,
MarkerType = 8192,
JSLiteral = 16384,
FreshLiteral = 32768,
ClassOrInterface = 3
}
interface ObjectType extends Type {
@@ -2451,6 +2461,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
@@ -3013,6 +3024,11 @@ declare namespace ts {
readonly importModuleSpecifierEnding?: "minimal" | "index" | "js";
readonly allowTextChangesInNewFiles?: boolean;
}
/** Represents a bigint literal value without requiring bigint support */
interface PseudoBigInt {
negative: boolean;
base10Value: string;
}
}
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
declare function clearTimeout(handle: any): void;
@@ -3295,6 +3311,7 @@ declare namespace ts {
}
declare namespace ts {
function isNumericLiteral(node: Node): node is NumericLiteral;
function isBigIntLiteral(node: Node): node is BigIntLiteral;
function isStringLiteral(node: Node): node is StringLiteral;
function isJsxText(node: Node): node is JsxText;
function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral;
@@ -3652,10 +3669,11 @@ declare namespace ts {
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: number): NumericLiteral;
function createLiteral(value: number | PseudoBigInt): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createBigIntLiteral(value: string): BigIntLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
function createIdentifier(text: string): Identifier;
@@ -4671,6 +4689,9 @@ declare namespace ts {
installPackage?(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
writeFile?(fileName: string, content: string): void;
}
type WithMetadata<T> = T & {
metadata?: unknown;
};
interface LanguageService {
cleanupSemanticCache(): void;
getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[];
@@ -4688,7 +4709,7 @@ declare namespace ts {
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined;
getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata<CompletionInfo> | undefined;
getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined;
getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
@@ -5256,8 +5277,9 @@ declare namespace ts {
Whitespace = 4,
Identifier = 5,
NumberLiteral = 6,
StringLiteral = 7,
RegExpLiteral = 8
BigIntLiteral = 7,
StringLiteral = 8,
RegExpLiteral = 9
}
interface ClassificationResult {
finalLexState: EndOfLineState;
@@ -5382,6 +5404,7 @@ declare namespace ts {
identifier = "identifier",
keyword = "keyword",
numericLiteral = "number",
bigintLiteral = "bigint",
operator = "operator",
stringLiteral = "string",
whiteSpace = "whitespace",
@@ -5426,7 +5449,8 @@ declare namespace ts {
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24
jsxAttributeStringLiteralValue = 24,
bigintLiteral = 25
}
}
declare namespace ts {
@@ -1,10 +1,10 @@
tests/cases/compiler/arithmeticOnInvalidTypes.ts(3,9): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
==== tests/cases/compiler/arithmeticOnInvalidTypes.ts (7 errors) ====
@@ -15,16 +15,16 @@ tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
var z2 = x - y;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
var z3 = x * y;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
var z4 = x / y;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
@@ -1,10 +1,10 @@
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(2,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
==== tests/cases/compiler/arithmeticOnInvalidTypes2.ts (7 errors) ====
@@ -14,18 +14,18 @@ tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
var z2 = a - b;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
var z3 = a * b;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
var z4 = a / b;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
return a;
};
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -6,7 +6,7 @@ function isNumber(x: any): x is number {
return typeof x === "number";
>typeof x === "number" : boolean
>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : any
>"number" : "number"
}
@@ -1,13 +1,36 @@
tests/cases/compiler/baseConstraintOfDecorator.ts(2,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
tests/cases/compiler/baseConstraintOfDecorator.ts(2,40): error TS2507: Type 'TFunction' is not a constructor function type.
tests/cases/compiler/baseConstraintOfDecorator.ts(12,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TFunction' is not a constructor function type.
==== tests/cases/compiler/baseConstraintOfDecorator.ts (2 errors) ====
==== tests/cases/compiler/baseConstraintOfDecorator.ts (4 errors) ====
export function classExtender<TFunction>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
return class decoratorFunc extends superClass {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2507: Type 'TFunction' is not a constructor function type.
!!! related TS2735 tests/cases/compiler/baseConstraintOfDecorator.ts:1:31: Did you mean for 'TFunction' to be constrained to type 'new (...args: any[]) => unknown'?
constructor(...args: any[]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
super(...args);
~~~~~~~~~~~~~~~~~~~~~~~~~~~
_instanceModifier(this, args);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
~~~~~~~~~
};
~~~~~~
!!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
}
class MyClass { private x; }
export function classExtender2<TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
return class decoratorFunc extends superClass {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2507: Type 'TFunction' is not a constructor function type.
!!! related TS2735 tests/cases/compiler/baseConstraintOfDecorator.ts:11:32: Did you mean for 'TFunction' to be constrained to type 'new (...args: any[]) => MyClass'?
constructor(...args: any[]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
super(...args);
@@ -7,6 +7,16 @@ export function classExtender<TFunction>(superClass: TFunction, _instanceModifie
}
};
}
class MyClass { private x; }
export function classExtender2<TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
return class decoratorFunc extends superClass {
constructor(...args: any[]) {
super(...args);
_instanceModifier(this, args);
}
};
}
//// [baseConstraintOfDecorator.js]
@@ -41,3 +51,24 @@ function classExtender(superClass, _instanceModifier) {
}(superClass));
}
exports.classExtender = classExtender;
var MyClass = /** @class */ (function () {
function MyClass() {
}
return MyClass;
}());
function classExtender2(superClass, _instanceModifier) {
return /** @class */ (function (_super) {
__extends(decoratorFunc, _super);
function decoratorFunc() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_instanceModifier(_this, args);
return _this;
}
return decoratorFunc;
}(superClass));
}
exports.classExtender2 = classExtender2;
@@ -27,3 +27,37 @@ export function classExtender<TFunction>(superClass: TFunction, _instanceModifie
};
}
class MyClass { private x; }
>MyClass : Symbol(MyClass, Decl(baseConstraintOfDecorator.ts, 7, 1))
>x : Symbol(MyClass.x, Decl(baseConstraintOfDecorator.ts, 9, 15))
export function classExtender2<TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
>classExtender2 : Symbol(classExtender2, Decl(baseConstraintOfDecorator.ts, 9, 28))
>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 10, 31))
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 10, 54))
>MyClass : Symbol(MyClass, Decl(baseConstraintOfDecorator.ts, 7, 1))
>superClass : Symbol(superClass, Decl(baseConstraintOfDecorator.ts, 10, 85))
>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 10, 31))
>_instanceModifier : Symbol(_instanceModifier, Decl(baseConstraintOfDecorator.ts, 10, 107))
>instance : Symbol(instance, Decl(baseConstraintOfDecorator.ts, 10, 128))
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 10, 142))
>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 10, 31))
return class decoratorFunc extends superClass {
>decoratorFunc : Symbol(decoratorFunc, Decl(baseConstraintOfDecorator.ts, 11, 10))
>superClass : Symbol(superClass, Decl(baseConstraintOfDecorator.ts, 10, 85))
constructor(...args: any[]) {
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20))
super(...args);
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20))
_instanceModifier(this, args);
>_instanceModifier : Symbol(_instanceModifier, Decl(baseConstraintOfDecorator.ts, 10, 107))
>this : Symbol(decoratorFunc, Decl(baseConstraintOfDecorator.ts, 11, 10))
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20))
}
};
}
@@ -29,3 +29,38 @@ export function classExtender<TFunction>(superClass: TFunction, _instanceModifie
};
}
class MyClass { private x; }
>MyClass : MyClass
>x : any
export function classExtender2<TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
>classExtender2 : <TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void) => TFunction
>args : string[]
>superClass : TFunction
>_instanceModifier : (instance: any, args: any[]) => void
>instance : any
>args : any[]
return class decoratorFunc extends superClass {
>class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : typeof decoratorFunc
>decoratorFunc : typeof decoratorFunc
>superClass : TFunction
constructor(...args: any[]) {
>args : any[]
super(...args);
>super(...args) : void
>super : any
>...args : any
>args : any[]
_instanceModifier(this, args);
>_instanceModifier(this, args) : void
>_instanceModifier : (instance: any, args: any[]) => void
>this : this
>args : any[]
}
};
}
@@ -0,0 +1,59 @@
tests/cases/compiler/a.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/a.ts(8,11): error TS2538: Type '1n' cannot be used as an index type.
tests/cases/compiler/a.ts(14,1): error TS2322: Type '123n' is not assignable to type 'string | number | symbol'.
tests/cases/compiler/a.ts(19,12): error TS2538: Type 'bigint' cannot be used as an index type.
tests/cases/compiler/b.ts(2,12): error TS1136: Property assignment expected.
tests/cases/compiler/b.ts(2,14): error TS1005: ';' expected.
tests/cases/compiler/b.ts(2,19): error TS1128: Declaration or statement expected.
tests/cases/compiler/b.ts(3,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/compiler/b.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/compiler/a.ts (4 errors) ====
interface BigIntIndex<E> {
[index: bigint]: E; // should error
~~~~~
!!! error TS1023: An index signature parameter type must be 'string' or 'number'.
}
const arr: number[] = [1, 2, 3];
let num: number = arr[1];
num = arr["1"];
num = arr[1n]; // should error
~~
!!! error TS2538: Type '1n' cannot be used as an index type.
let key: keyof any; // should be type "string | number | symbol"
key = 123;
key = "abc";
key = Symbol();
key = 123n; // should error
~~~
!!! error TS2322: Type '123n' is not assignable to type 'string | number | symbol'.
// Show correct usage of bigint index: explicitly convert to string
const bigNum: bigint = 0n;
const typedArray = new Uint8Array(3);
typedArray[bigNum] = 0xAA; // should error
~~~~~~
!!! error TS2538: Type 'bigint' cannot be used as an index type.
typedArray[String(bigNum)] = 0xAA;
typedArray["1"] = 0xBB;
typedArray[2] = 0xCC;
// {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown
==== tests/cases/compiler/b.ts (5 errors) ====
// BigInt cannot be used as an object literal property
const a = {1n: 123};
~~
!!! error TS1136: Property assignment expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1128: Declaration or statement expected.
const b = {[1n]: 456};
~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
const c = {[bigNum]: 789};
~~~~~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
+59
View File
@@ -0,0 +1,59 @@
//// [tests/cases/compiler/bigintIndex.ts] ////
//// [a.ts]
interface BigIntIndex<E> {
[index: bigint]: E; // should error
}
const arr: number[] = [1, 2, 3];
let num: number = arr[1];
num = arr["1"];
num = arr[1n]; // should error
let key: keyof any; // should be type "string | number | symbol"
key = 123;
key = "abc";
key = Symbol();
key = 123n; // should error
// Show correct usage of bigint index: explicitly convert to string
const bigNum: bigint = 0n;
const typedArray = new Uint8Array(3);
typedArray[bigNum] = 0xAA; // should error
typedArray[String(bigNum)] = 0xAA;
typedArray["1"] = 0xBB;
typedArray[2] = 0xCC;
// {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown
//// [b.ts]
// BigInt cannot be used as an object literal property
const a = {1n: 123};
const b = {[1n]: 456};
const c = {[bigNum]: 789};
//// [a.js]
const arr = [1, 2, 3];
let num = arr[1];
num = arr["1"];
num = arr[1n]; // should error
let key; // should be type "string | number | symbol"
key = 123;
key = "abc";
key = Symbol();
key = 123n; // should error
// Show correct usage of bigint index: explicitly convert to string
const bigNum = 0n;
const typedArray = new Uint8Array(3);
typedArray[bigNum] = 0xAA; // should error
typedArray[String(bigNum)] = 0xAA;
typedArray["1"] = 0xBB;
typedArray[2] = 0xCC;
// {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown
//// [b.js]
// BigInt cannot be used as an object literal property
const a = {};
1n;
123;
;
const b = { [1n]: 456 };
const c = { [bigNum]: 789 };
@@ -0,0 +1,79 @@
=== tests/cases/compiler/a.ts ===
interface BigIntIndex<E> {
>BigIntIndex : Symbol(BigIntIndex, Decl(a.ts, 0, 0))
>E : Symbol(E, Decl(a.ts, 0, 22))
[index: bigint]: E; // should error
>index : Symbol(index, Decl(a.ts, 1, 5))
>E : Symbol(E, Decl(a.ts, 0, 22))
}
const arr: number[] = [1, 2, 3];
>arr : Symbol(arr, Decl(a.ts, 4, 5))
let num: number = arr[1];
>num : Symbol(num, Decl(a.ts, 5, 3))
>arr : Symbol(arr, Decl(a.ts, 4, 5))
num = arr["1"];
>num : Symbol(num, Decl(a.ts, 5, 3))
>arr : Symbol(arr, Decl(a.ts, 4, 5))
num = arr[1n]; // should error
>num : Symbol(num, Decl(a.ts, 5, 3))
>arr : Symbol(arr, Decl(a.ts, 4, 5))
let key: keyof any; // should be type "string | number | symbol"
>key : Symbol(key, Decl(a.ts, 9, 3))
key = 123;
>key : Symbol(key, Decl(a.ts, 9, 3))
key = "abc";
>key : Symbol(key, Decl(a.ts, 9, 3))
key = Symbol();
>key : Symbol(key, Decl(a.ts, 9, 3))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --))
key = 123n; // should error
>key : Symbol(key, Decl(a.ts, 9, 3))
// Show correct usage of bigint index: explicitly convert to string
const bigNum: bigint = 0n;
>bigNum : Symbol(bigNum, Decl(a.ts, 16, 5))
const typedArray = new Uint8Array(3);
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
typedArray[bigNum] = 0xAA; // should error
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
>bigNum : Symbol(bigNum, Decl(a.ts, 16, 5))
typedArray[String(bigNum)] = 0xAA;
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 2 more)
>bigNum : Symbol(bigNum, Decl(a.ts, 16, 5))
typedArray["1"] = 0xBB;
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
typedArray[2] = 0xCC;
>typedArray : Symbol(typedArray, Decl(a.ts, 17, 5))
// {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown
=== tests/cases/compiler/b.ts ===
// BigInt cannot be used as an object literal property
const a = {1n: 123};
>a : Symbol(a, Decl(b.ts, 1, 5))
const b = {[1n]: 456};
>b : Symbol(b, Decl(b.ts, 2, 5))
>[1n] : Symbol([1n], Decl(b.ts, 2, 11))
const c = {[bigNum]: 789};
>c : Symbol(c, Decl(b.ts, 3, 5))
>[bigNum] : Symbol([bigNum], Decl(b.ts, 3, 11))
>bigNum : Symbol(bigNum, Decl(a.ts, 16, 5))
+121
View File
@@ -0,0 +1,121 @@
=== tests/cases/compiler/a.ts ===
interface BigIntIndex<E> {
[index: bigint]: E; // should error
>index : bigint
}
const arr: number[] = [1, 2, 3];
>arr : number[]
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
let num: number = arr[1];
>num : number
>arr[1] : number
>arr : number[]
>1 : 1
num = arr["1"];
>num = arr["1"] : any
>num : number
>arr["1"] : any
>arr : number[]
>"1" : "1"
num = arr[1n]; // should error
>num = arr[1n] : any
>num : number
>arr[1n] : any
>arr : number[]
>1n : 1n
let key: keyof any; // should be type "string | number | symbol"
>key : string | number | symbol
key = 123;
>key = 123 : 123
>key : string | number | symbol
>123 : 123
key = "abc";
>key = "abc" : "abc"
>key : string | number | symbol
>"abc" : "abc"
key = Symbol();
>key = Symbol() : symbol
>key : string | number | symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
key = 123n; // should error
>key = 123n : 123n
>key : string | number | symbol
>123n : 123n
// Show correct usage of bigint index: explicitly convert to string
const bigNum: bigint = 0n;
>bigNum : bigint
>0n : 0n
const typedArray = new Uint8Array(3);
>typedArray : Uint8Array
>new Uint8Array(3) : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>3 : 3
typedArray[bigNum] = 0xAA; // should error
>typedArray[bigNum] = 0xAA : 170
>typedArray[bigNum] : any
>typedArray : Uint8Array
>bigNum : bigint
>0xAA : 170
typedArray[String(bigNum)] = 0xAA;
>typedArray[String(bigNum)] = 0xAA : 170
>typedArray[String(bigNum)] : any
>typedArray : Uint8Array
>String(bigNum) : string
>String : StringConstructor
>bigNum : bigint
>0xAA : 170
typedArray["1"] = 0xBB;
>typedArray["1"] = 0xBB : 187
>typedArray["1"] : any
>typedArray : Uint8Array
>"1" : "1"
>0xBB : 187
typedArray[2] = 0xCC;
>typedArray[2] = 0xCC : 204
>typedArray[2] : number
>typedArray : Uint8Array
>2 : 2
>0xCC : 204
// {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown
=== tests/cases/compiler/b.ts ===
// BigInt cannot be used as an object literal property
const a = {1n: 123};
>a : {}
>{ : {}
>1n : 1n
>123 : 123
const b = {[1n]: 456};
>b : {}
>{[1n]: 456} : {}
>[1n] : number
>1n : 1n
>456 : 456
const c = {[bigNum]: 789};
>c : {}
>{[bigNum]: 789} : {}
>[bigNum] : number
>bigNum : bigint
>789 : 789
@@ -0,0 +1,83 @@
tests/cases/compiler/bigintWithLib.ts(4,1): error TS2350: Only a void function can be called with the 'new' keyword.
tests/cases/compiler/bigintWithLib.ts(16,33): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
Property 'byteLength' is missing in type 'number[]'.
tests/cases/compiler/bigintWithLib.ts(21,13): error TS2540: Cannot assign to 'length' because it is a constant or a read-only property.
tests/cases/compiler/bigintWithLib.ts(28,35): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
tests/cases/compiler/bigintWithLib.ts(33,13): error TS2540: Cannot assign to 'length' because it is a constant or a read-only property.
tests/cases/compiler/bigintWithLib.ts(40,25): error TS2345: Argument of type '-1' is not assignable to parameter of type 'bigint'.
tests/cases/compiler/bigintWithLib.ts(43,26): error TS2345: Argument of type '123' is not assignable to parameter of type 'bigint'.
==== tests/cases/compiler/bigintWithLib.ts (7 errors) ====
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
bigintVal = BigInt("456");
new BigInt(123); // should error
~~~~~~~~~~~~~~~
!!! error TS2350: Only a void function can be called with the 'new' keyword.
bigintVal = BigInt.asIntN(8, 0xFFFFn);
bigintVal = BigInt.asUintN(8, 0xFFFFn);
bigintVal = bigintVal.valueOf();
let stringVal: string = bigintVal.toString();
stringVal = bigintVal.toString(2);
stringVal = bigintVal.toLocaleString();
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
bigIntArray = new BigInt64Array(10);
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
~~~~~~~~~
!!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
!!! error TS2345: Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
!!! error TS2345: Property 'byteLength' is missing in type 'number[]'.
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
let len: number = bigIntArray.length;
bigIntArray.length = 10; // should error
~~~~~~
!!! error TS2540: Cannot assign to 'length' because it is a constant or a read-only property.
let arrayBufferLike: ArrayBufferView = bigIntArray;
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
bigUintArray = new BigUint64Array(10);
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
~~~~~~~~~
!!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
!!! error TS2345: Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
len = bigIntArray.length;
bigIntArray.length = 10; // should error
~~~~~~
!!! error TS2540: Cannot assign to 'length' because it is a constant or a read-only property.
arrayBufferLike = bigIntArray;
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
dataView.setBigInt64(1, -1n, true);
dataView.setBigInt64(1, -1); // should error
~~
!!! error TS2345: Argument of type '-1' is not assignable to parameter of type 'bigint'.
dataView.setBigUint64(2, 123n);
dataView.setBigUint64(2, 123n, true);
dataView.setBigUint64(2, 123); // should error
~~~
!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'bigint'.
bigintVal = dataView.getBigInt64(1);
bigintVal = dataView.getBigInt64(1, true);
bigintVal = dataView.getBigUint64(2);
bigintVal = dataView.getBigUint64(2, true);
// Test emitted declarations files
const w = 12n; // should emit as const w = 12n
const x = -12n; // should emit as const x = -12n
const y: 12n = 12n; // should emit type 12n
let z = 12n; // should emit type bigint in declaration file
+119
View File
@@ -0,0 +1,119 @@
//// [bigintWithLib.ts]
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
bigintVal = BigInt("456");
new BigInt(123); // should error
bigintVal = BigInt.asIntN(8, 0xFFFFn);
bigintVal = BigInt.asUintN(8, 0xFFFFn);
bigintVal = bigintVal.valueOf();
let stringVal: string = bigintVal.toString();
stringVal = bigintVal.toString(2);
stringVal = bigintVal.toLocaleString();
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
bigIntArray = new BigInt64Array(10);
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
let len: number = bigIntArray.length;
bigIntArray.length = 10; // should error
let arrayBufferLike: ArrayBufferView = bigIntArray;
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
bigUintArray = new BigUint64Array(10);
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
len = bigIntArray.length;
bigIntArray.length = 10; // should error
arrayBufferLike = bigIntArray;
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
dataView.setBigInt64(1, -1n, true);
dataView.setBigInt64(1, -1); // should error
dataView.setBigUint64(2, 123n);
dataView.setBigUint64(2, 123n, true);
dataView.setBigUint64(2, 123); // should error
bigintVal = dataView.getBigInt64(1);
bigintVal = dataView.getBigInt64(1, true);
bigintVal = dataView.getBigUint64(2);
bigintVal = dataView.getBigUint64(2, true);
// Test emitted declarations files
const w = 12n; // should emit as const w = 12n
const x = -12n; // should emit as const x = -12n
const y: 12n = 12n; // should emit type 12n
let z = 12n; // should emit type bigint in declaration file
//// [bigintWithLib.js]
// Test BigInt functions
let bigintVal = BigInt(123);
bigintVal = BigInt("456");
new BigInt(123); // should error
bigintVal = BigInt.asIntN(8, 0xffffn);
bigintVal = BigInt.asUintN(8, 0xffffn);
bigintVal = bigintVal.valueOf();
let stringVal = bigintVal.toString();
stringVal = bigintVal.toString(2);
stringVal = bigintVal.toLocaleString();
// Test BigInt64Array
let bigIntArray = new BigInt64Array();
bigIntArray = new BigInt64Array(10);
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
let len = bigIntArray.length;
bigIntArray.length = 10; // should error
let arrayBufferLike = bigIntArray;
// Test BigUint64Array
let bigUintArray = new BigUint64Array();
bigUintArray = new BigUint64Array(10);
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
len = bigIntArray.length;
bigIntArray.length = 10; // should error
arrayBufferLike = bigIntArray;
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
dataView.setBigInt64(1, -1n, true);
dataView.setBigInt64(1, -1); // should error
dataView.setBigUint64(2, 123n);
dataView.setBigUint64(2, 123n, true);
dataView.setBigUint64(2, 123); // should error
bigintVal = dataView.getBigInt64(1);
bigintVal = dataView.getBigInt64(1, true);
bigintVal = dataView.getBigUint64(2);
bigintVal = dataView.getBigUint64(2, true);
// Test emitted declarations files
const w = 12n; // should emit as const w = 12n
const x = -12n; // should emit as const x = -12n
const y = 12n; // should emit type 12n
let z = 12n; // should emit type bigint in declaration file
//// [bigintWithLib.d.ts]
declare let bigintVal: bigint;
declare let stringVal: string;
declare let bigIntArray: BigInt64Array;
declare let len: number;
declare let arrayBufferLike: ArrayBufferView;
declare let bigUintArray: BigUint64Array;
declare const dataView: DataView;
declare const w = 12n;
declare const x = -12n;
declare const y: 12n;
declare let z: bigint;
@@ -0,0 +1,219 @@
=== tests/cases/compiler/bigintWithLib.ts ===
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>BigInt : Symbol(BigInt, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = BigInt("456");
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>BigInt : Symbol(BigInt, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
new BigInt(123); // should error
>BigInt : Symbol(BigInt, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = BigInt.asIntN(8, 0xFFFFn);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>BigInt.asIntN : Symbol(BigIntConstructor.asIntN, Decl(lib.esnext.bigint.d.ts, --, --))
>BigInt : Symbol(BigInt, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>asIntN : Symbol(BigIntConstructor.asIntN, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = BigInt.asUintN(8, 0xFFFFn);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>BigInt.asUintN : Symbol(BigIntConstructor.asUintN, Decl(lib.esnext.bigint.d.ts, --, --))
>BigInt : Symbol(BigInt, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>asUintN : Symbol(BigIntConstructor.asUintN, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = bigintVal.valueOf();
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>bigintVal.valueOf : Symbol(BigInt.valueOf, Decl(lib.esnext.bigint.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>valueOf : Symbol(BigInt.valueOf, Decl(lib.esnext.bigint.d.ts, --, --))
let stringVal: string = bigintVal.toString();
>stringVal : Symbol(stringVal, Decl(bigintWithLib.ts, 7, 3))
>bigintVal.toString : Symbol(BigInt.toString, Decl(lib.esnext.bigint.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>toString : Symbol(BigInt.toString, Decl(lib.esnext.bigint.d.ts, --, --))
stringVal = bigintVal.toString(2);
>stringVal : Symbol(stringVal, Decl(bigintWithLib.ts, 7, 3))
>bigintVal.toString : Symbol(BigInt.toString, Decl(lib.esnext.bigint.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>toString : Symbol(BigInt.toString, Decl(lib.esnext.bigint.d.ts, --, --))
stringVal = bigintVal.toLocaleString();
>stringVal : Symbol(stringVal, Decl(bigintWithLib.ts, 7, 3))
>bigintVal.toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.esnext.bigint.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.esnext.bigint.d.ts, --, --))
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray = new BigInt64Array(10);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
let len: number = bigIntArray.length;
>len : Symbol(len, Decl(bigintWithLib.ts, 19, 3))
>bigIntArray.length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray.length = 10; // should error
>bigIntArray.length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
let arrayBufferLike: ArrayBufferView = bigIntArray;
>arrayBufferLike : Symbol(arrayBufferLike, Decl(bigintWithLib.ts, 21, 3))
>ArrayBufferView : Symbol(ArrayBufferView, Decl(lib.es5.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigUintArray = new BigUint64Array(10);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithLib.ts, 24, 3))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
len = bigIntArray.length;
>len : Symbol(len, Decl(bigintWithLib.ts, 19, 3))
>bigIntArray.length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
bigIntArray.length = 10; // should error
>bigIntArray.length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
>length : Symbol(BigInt64Array.length, Decl(lib.esnext.bigint.d.ts, --, --))
arrayBufferLike = bigIntArray;
>arrayBufferLike : Symbol(arrayBufferLike, Decl(bigintWithLib.ts, 21, 3))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithLib.ts, 12, 3))
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>DataView : Symbol(DataView, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
dataView.setBigInt64(1, -1n);
>dataView.setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
dataView.setBigInt64(1, -1n, true);
>dataView.setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
dataView.setBigInt64(1, -1); // should error
>dataView.setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigInt64 : Symbol(DataView.setBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
dataView.setBigUint64(2, 123n);
>dataView.setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
dataView.setBigUint64(2, 123n, true);
>dataView.setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
dataView.setBigUint64(2, 123); // should error
>dataView.setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>setBigUint64 : Symbol(DataView.setBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = dataView.getBigInt64(1);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>dataView.getBigInt64 : Symbol(DataView.getBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>getBigInt64 : Symbol(DataView.getBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = dataView.getBigInt64(1, true);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>dataView.getBigInt64 : Symbol(DataView.getBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>getBigInt64 : Symbol(DataView.getBigInt64, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = dataView.getBigUint64(2);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>dataView.getBigUint64 : Symbol(DataView.getBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>getBigUint64 : Symbol(DataView.getBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
bigintVal = dataView.getBigUint64(2, true);
>bigintVal : Symbol(bigintVal, Decl(bigintWithLib.ts, 1, 3))
>dataView.getBigUint64 : Symbol(DataView.getBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
>dataView : Symbol(dataView, Decl(bigintWithLib.ts, 36, 5))
>getBigUint64 : Symbol(DataView.getBigUint64, Decl(lib.esnext.bigint.d.ts, --, --))
// Test emitted declarations files
const w = 12n; // should emit as const w = 12n
>w : Symbol(w, Decl(bigintWithLib.ts, 49, 5))
const x = -12n; // should emit as const x = -12n
>x : Symbol(x, Decl(bigintWithLib.ts, 50, 5))
const y: 12n = 12n; // should emit type 12n
>y : Symbol(y, Decl(bigintWithLib.ts, 51, 5))
let z = 12n; // should emit type bigint in declaration file
>z : Symbol(z, Decl(bigintWithLib.ts, 52, 3))
@@ -0,0 +1,352 @@
=== tests/cases/compiler/bigintWithLib.ts ===
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
>bigintVal : bigint
>BigInt(123) : bigint
>BigInt : BigIntConstructor
>123 : 123
bigintVal = BigInt("456");
>bigintVal = BigInt("456") : bigint
>bigintVal : bigint
>BigInt("456") : bigint
>BigInt : BigIntConstructor
>"456" : "456"
new BigInt(123); // should error
>new BigInt(123) : any
>BigInt : BigIntConstructor
>123 : 123
bigintVal = BigInt.asIntN(8, 0xFFFFn);
>bigintVal = BigInt.asIntN(8, 0xFFFFn) : bigint
>bigintVal : bigint
>BigInt.asIntN(8, 0xFFFFn) : bigint
>BigInt.asIntN : (bits: number, int: bigint) => bigint
>BigInt : BigIntConstructor
>asIntN : (bits: number, int: bigint) => bigint
>8 : 8
>0xFFFFn : 65535n
bigintVal = BigInt.asUintN(8, 0xFFFFn);
>bigintVal = BigInt.asUintN(8, 0xFFFFn) : bigint
>bigintVal : bigint
>BigInt.asUintN(8, 0xFFFFn) : bigint
>BigInt.asUintN : (bits: number, int: bigint) => bigint
>BigInt : BigIntConstructor
>asUintN : (bits: number, int: bigint) => bigint
>8 : 8
>0xFFFFn : 65535n
bigintVal = bigintVal.valueOf();
>bigintVal = bigintVal.valueOf() : bigint
>bigintVal : bigint
>bigintVal.valueOf() : bigint
>bigintVal.valueOf : () => bigint
>bigintVal : bigint
>valueOf : () => bigint
let stringVal: string = bigintVal.toString();
>stringVal : string
>bigintVal.toString() : string
>bigintVal.toString : (radix?: number) => string
>bigintVal : bigint
>toString : (radix?: number) => string
stringVal = bigintVal.toString(2);
>stringVal = bigintVal.toString(2) : string
>stringVal : string
>bigintVal.toString(2) : string
>bigintVal.toString : (radix?: number) => string
>bigintVal : bigint
>toString : (radix?: number) => string
>2 : 2
stringVal = bigintVal.toLocaleString();
>stringVal = bigintVal.toLocaleString() : string
>stringVal : string
>bigintVal.toLocaleString() : string
>bigintVal.toLocaleString : () => string
>bigintVal : bigint
>toLocaleString : () => string
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
>bigIntArray : BigInt64Array
>new BigInt64Array() : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
bigIntArray = new BigInt64Array(10);
>bigIntArray = new BigInt64Array(10) : BigInt64Array
>bigIntArray : BigInt64Array
>new BigInt64Array(10) : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>10 : 10
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
>bigIntArray = new BigInt64Array([1n, 2n, 3n]) : BigInt64Array
>bigIntArray : BigInt64Array
>new BigInt64Array([1n, 2n, 3n]) : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>[1n, 2n, 3n] : bigint[]
>1n : 1n
>2n : 2n
>3n : 3n
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
>bigIntArray = new BigInt64Array([1, 2, 3]) : any
>bigIntArray : BigInt64Array
>new BigInt64Array([1, 2, 3]) : any
>BigInt64Array : BigInt64ArrayConstructor
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
>bigIntArray = new BigInt64Array(new ArrayBuffer(80)) : BigInt64Array
>bigIntArray : BigInt64Array
>new BigInt64Array(new ArrayBuffer(80)) : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
>bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8) : BigInt64Array
>bigIntArray : BigInt64Array
>new BigInt64Array(new ArrayBuffer(80), 8) : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
>8 : 8
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
>bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3) : BigInt64Array
>bigIntArray : BigInt64Array
>new BigInt64Array(new ArrayBuffer(80), 8, 3) : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
>8 : 8
>3 : 3
let len: number = bigIntArray.length;
>len : number
>bigIntArray.length : number
>bigIntArray : BigInt64Array
>length : number
bigIntArray.length = 10; // should error
>bigIntArray.length = 10 : 10
>bigIntArray.length : any
>bigIntArray : BigInt64Array
>length : any
>10 : 10
let arrayBufferLike: ArrayBufferView = bigIntArray;
>arrayBufferLike : ArrayBufferView
>bigIntArray : BigInt64Array
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
>bigUintArray : BigUint64Array
>new BigUint64Array() : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
bigUintArray = new BigUint64Array(10);
>bigUintArray = new BigUint64Array(10) : BigUint64Array
>bigUintArray : BigUint64Array
>new BigUint64Array(10) : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>10 : 10
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
>bigUintArray = new BigUint64Array([1n, 2n, 3n]) : BigUint64Array
>bigUintArray : BigUint64Array
>new BigUint64Array([1n, 2n, 3n]) : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>[1n, 2n, 3n] : bigint[]
>1n : 1n
>2n : 2n
>3n : 3n
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
>bigUintArray = new BigUint64Array([1, 2, 3]) : any
>bigUintArray : BigUint64Array
>new BigUint64Array([1, 2, 3]) : any
>BigUint64Array : BigUint64ArrayConstructor
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
>bigUintArray = new BigUint64Array(new ArrayBuffer(80)) : BigUint64Array
>bigUintArray : BigUint64Array
>new BigUint64Array(new ArrayBuffer(80)) : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
>bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8) : BigUint64Array
>bigUintArray : BigUint64Array
>new BigUint64Array(new ArrayBuffer(80), 8) : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
>8 : 8
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
>bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3) : BigUint64Array
>bigUintArray : BigUint64Array
>new BigUint64Array(new ArrayBuffer(80), 8, 3) : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
>8 : 8
>3 : 3
len = bigIntArray.length;
>len = bigIntArray.length : number
>len : number
>bigIntArray.length : number
>bigIntArray : BigInt64Array
>length : number
bigIntArray.length = 10; // should error
>bigIntArray.length = 10 : 10
>bigIntArray.length : any
>bigIntArray : BigInt64Array
>length : any
>10 : 10
arrayBufferLike = bigIntArray;
>arrayBufferLike = bigIntArray : BigInt64Array
>arrayBufferLike : ArrayBufferView
>bigIntArray : BigInt64Array
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
>dataView : DataView
>new DataView(new ArrayBuffer(80)) : DataView
>DataView : DataViewConstructor
>new ArrayBuffer(80) : ArrayBuffer
>ArrayBuffer : ArrayBufferConstructor
>80 : 80
dataView.setBigInt64(1, -1n);
>dataView.setBigInt64(1, -1n) : void
>dataView.setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>1 : 1
>-1n : -1n
>1n : 1n
dataView.setBigInt64(1, -1n, true);
>dataView.setBigInt64(1, -1n, true) : void
>dataView.setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>1 : 1
>-1n : -1n
>1n : 1n
>true : true
dataView.setBigInt64(1, -1); // should error
>dataView.setBigInt64(1, -1) : void
>dataView.setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigInt64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>1 : 1
>-1 : -1
>1 : 1
dataView.setBigUint64(2, 123n);
>dataView.setBigUint64(2, 123n) : void
>dataView.setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>2 : 2
>123n : 123n
dataView.setBigUint64(2, 123n, true);
>dataView.setBigUint64(2, 123n, true) : void
>dataView.setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>2 : 2
>123n : 123n
>true : true
dataView.setBigUint64(2, 123); // should error
>dataView.setBigUint64(2, 123) : void
>dataView.setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>dataView : DataView
>setBigUint64 : (byteOffset: number, value: bigint, littleEndian?: boolean) => void
>2 : 2
>123 : 123
bigintVal = dataView.getBigInt64(1);
>bigintVal = dataView.getBigInt64(1) : bigint
>bigintVal : bigint
>dataView.getBigInt64(1) : bigint
>dataView.getBigInt64 : (byteOffset: number, littleEndian?: boolean) => bigint
>dataView : DataView
>getBigInt64 : (byteOffset: number, littleEndian?: boolean) => bigint
>1 : 1
bigintVal = dataView.getBigInt64(1, true);
>bigintVal = dataView.getBigInt64(1, true) : bigint
>bigintVal : bigint
>dataView.getBigInt64(1, true) : bigint
>dataView.getBigInt64 : (byteOffset: number, littleEndian?: boolean) => bigint
>dataView : DataView
>getBigInt64 : (byteOffset: number, littleEndian?: boolean) => bigint
>1 : 1
>true : true
bigintVal = dataView.getBigUint64(2);
>bigintVal = dataView.getBigUint64(2) : bigint
>bigintVal : bigint
>dataView.getBigUint64(2) : bigint
>dataView.getBigUint64 : (byteOffset: number, littleEndian?: boolean) => bigint
>dataView : DataView
>getBigUint64 : (byteOffset: number, littleEndian?: boolean) => bigint
>2 : 2
bigintVal = dataView.getBigUint64(2, true);
>bigintVal = dataView.getBigUint64(2, true) : bigint
>bigintVal : bigint
>dataView.getBigUint64(2, true) : bigint
>dataView.getBigUint64 : (byteOffset: number, littleEndian?: boolean) => bigint
>dataView : DataView
>getBigUint64 : (byteOffset: number, littleEndian?: boolean) => bigint
>2 : 2
>true : true
// Test emitted declarations files
const w = 12n; // should emit as const w = 12n
>w : 12n
>12n : 12n
const x = -12n; // should emit as const x = -12n
>x : -12n
>-12n : -12n
>12n : 12n
const y: 12n = 12n; // should emit type 12n
>y : 12n
>12n : 12n
let z = 12n; // should emit type bigint in declaration file
>z : bigint
>12n : 12n
@@ -0,0 +1,191 @@
tests/cases/compiler/bigintWithoutLib.ts(4,25): error TS2304: Cannot find name 'BigInt'.
tests/cases/compiler/bigintWithoutLib.ts(5,13): error TS2304: Cannot find name 'BigInt'.
tests/cases/compiler/bigintWithoutLib.ts(6,5): error TS2304: Cannot find name 'BigInt'.
tests/cases/compiler/bigintWithoutLib.ts(7,13): error TS2304: Cannot find name 'BigInt'.
tests/cases/compiler/bigintWithoutLib.ts(7,30): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(8,13): error TS2304: Cannot find name 'BigInt'.
tests/cases/compiler/bigintWithoutLib.ts(8,31): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(9,1): error TS2322: Type 'Object' is not assignable to type 'bigint'.
tests/cases/compiler/bigintWithoutLib.ts(11,13): error TS2554: Expected 0 arguments, but got 1.
tests/cases/compiler/bigintWithoutLib.ts(15,18): error TS2304: Cannot find name 'BigInt64Array'.
tests/cases/compiler/bigintWithoutLib.ts(15,38): error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
tests/cases/compiler/bigintWithoutLib.ts(16,19): error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
tests/cases/compiler/bigintWithoutLib.ts(17,19): error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
tests/cases/compiler/bigintWithoutLib.ts(17,34): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(17,38): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(17,42): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(18,19): error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
tests/cases/compiler/bigintWithoutLib.ts(19,19): error TS2304: Cannot find name 'BigInt64Array'.
tests/cases/compiler/bigintWithoutLib.ts(20,19): error TS2304: Cannot find name 'BigInt64Array'.
tests/cases/compiler/bigintWithoutLib.ts(21,19): error TS2304: Cannot find name 'BigInt64Array'.
tests/cases/compiler/bigintWithoutLib.ts(27,19): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(27,40): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(28,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(29,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(29,36): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(29,40): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(29,44): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(30,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(31,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(32,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(33,20): error TS2304: Cannot find name 'BigUint64Array'.
tests/cases/compiler/bigintWithoutLib.ts(40,10): error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(40,26): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(41,10): error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(41,26): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(42,10): error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(43,10): error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(43,26): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(44,10): error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(44,26): error TS2737: BigInt literals are not available when targetting lower than ESNext.
tests/cases/compiler/bigintWithoutLib.ts(45,10): error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(46,22): error TS2339: Property 'getBigInt64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(47,22): error TS2339: Property 'getBigInt64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(48,22): error TS2339: Property 'getBigUint64' does not exist on type 'DataView'.
tests/cases/compiler/bigintWithoutLib.ts(49,22): error TS2339: Property 'getBigUint64' does not exist on type 'DataView'.
==== tests/cases/compiler/bigintWithoutLib.ts (45 errors) ====
// Every line should error because these builtins are not declared
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
~~~~~~
!!! error TS2304: Cannot find name 'BigInt'.
bigintVal = BigInt("456");
~~~~~~
!!! error TS2304: Cannot find name 'BigInt'.
new BigInt(123);
~~~~~~
!!! error TS2304: Cannot find name 'BigInt'.
bigintVal = BigInt.asIntN(8, 0xFFFFn);
~~~~~~
!!! error TS2304: Cannot find name 'BigInt'.
~~~~~~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
bigintVal = BigInt.asUintN(8, 0xFFFFn);
~~~~~~
!!! error TS2304: Cannot find name 'BigInt'.
~~~~~~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
bigintVal = bigintVal.valueOf(); // should error - bigintVal inferred as {}
~~~~~~~~~
!!! error TS2322: Type 'Object' is not assignable to type 'bigint'.
let stringVal: string = bigintVal.toString(); // should not error - bigintVal inferred as {}
stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {}
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 0 arguments, but got 1.
stringVal = bigintVal.toLocaleString(); // should not error - bigintVal inferred as {}
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigInt64Array'.
~~~~~~~~~~~~~
!!! error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
!!! related TS2728 tests/cases/compiler/bigintWithoutLib.ts:15:5: 'bigIntArray' is declared here.
bigIntArray = new BigInt64Array(10);
~~~~~~~~~~~~~
!!! error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
!!! related TS2728 tests/cases/compiler/bigintWithoutLib.ts:15:5: 'bigIntArray' is declared here.
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
~~~~~~~~~~~~~
!!! error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
!!! related TS2728 tests/cases/compiler/bigintWithoutLib.ts:15:5: 'bigIntArray' is declared here.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
bigIntArray = new BigInt64Array([1, 2, 3]);
~~~~~~~~~~~~~
!!! error TS2552: Cannot find name 'BigInt64Array'. Did you mean 'bigIntArray'?
!!! related TS2728 tests/cases/compiler/bigintWithoutLib.ts:15:5: 'bigIntArray' is declared here.
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigInt64Array'.
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigInt64Array'.
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigInt64Array'.
let len: number = bigIntArray.length;
bigIntArray.length = 10;
let arrayBufferLike: ArrayBufferView = bigIntArray;
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
bigUintArray = new BigUint64Array(10);
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
bigUintArray = new BigUint64Array([1, 2, 3]);
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'BigUint64Array'.
len = bigIntArray.length;
bigIntArray.length = 10;
arrayBufferLike = bigIntArray;
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
~~~~~~~~~~~
!!! error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
dataView.setBigInt64(1, -1n, true);
~~~~~~~~~~~
!!! error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
dataView.setBigInt64(1, -1);
~~~~~~~~~~~
!!! error TS2339: Property 'setBigInt64' does not exist on type 'DataView'.
dataView.setBigUint64(2, 123n);
~~~~~~~~~~~~
!!! error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
~~~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
dataView.setBigUint64(2, 123n, true);
~~~~~~~~~~~~
!!! error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
~~~~
!!! error TS2737: BigInt literals are not available when targetting lower than ESNext.
dataView.setBigUint64(2, 123);
~~~~~~~~~~~~
!!! error TS2339: Property 'setBigUint64' does not exist on type 'DataView'.
bigintVal = dataView.getBigInt64(1);
~~~~~~~~~~~
!!! error TS2339: Property 'getBigInt64' does not exist on type 'DataView'.
bigintVal = dataView.getBigInt64(1, true);
~~~~~~~~~~~
!!! error TS2339: Property 'getBigInt64' does not exist on type 'DataView'.
bigintVal = dataView.getBigUint64(2);
~~~~~~~~~~~~
!!! error TS2339: Property 'getBigUint64' does not exist on type 'DataView'.
bigintVal = dataView.getBigUint64(2, true);
~~~~~~~~~~~~
!!! error TS2339: Property 'getBigUint64' does not exist on type 'DataView'.
@@ -0,0 +1,97 @@
//// [bigintWithoutLib.ts]
// Every line should error because these builtins are not declared
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
bigintVal = BigInt("456");
new BigInt(123);
bigintVal = BigInt.asIntN(8, 0xFFFFn);
bigintVal = BigInt.asUintN(8, 0xFFFFn);
bigintVal = bigintVal.valueOf(); // should error - bigintVal inferred as {}
let stringVal: string = bigintVal.toString(); // should not error - bigintVal inferred as {}
stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {}
stringVal = bigintVal.toLocaleString(); // should not error - bigintVal inferred as {}
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
bigIntArray = new BigInt64Array(10);
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
bigIntArray = new BigInt64Array([1, 2, 3]);
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
let len: number = bigIntArray.length;
bigIntArray.length = 10;
let arrayBufferLike: ArrayBufferView = bigIntArray;
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
bigUintArray = new BigUint64Array(10);
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
bigUintArray = new BigUint64Array([1, 2, 3]);
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
len = bigIntArray.length;
bigIntArray.length = 10;
arrayBufferLike = bigIntArray;
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
dataView.setBigInt64(1, -1n, true);
dataView.setBigInt64(1, -1);
dataView.setBigUint64(2, 123n);
dataView.setBigUint64(2, 123n, true);
dataView.setBigUint64(2, 123);
bigintVal = dataView.getBigInt64(1);
bigintVal = dataView.getBigInt64(1, true);
bigintVal = dataView.getBigUint64(2);
bigintVal = dataView.getBigUint64(2, true);
//// [bigintWithoutLib.js]
// Every line should error because these builtins are not declared
// Test BigInt functions
var bigintVal = BigInt(123);
bigintVal = BigInt("456");
new BigInt(123);
bigintVal = BigInt.asIntN(8, 0xffffn);
bigintVal = BigInt.asUintN(8, 0xffffn);
bigintVal = bigintVal.valueOf(); // should error - bigintVal inferred as {}
var stringVal = bigintVal.toString(); // should not error - bigintVal inferred as {}
stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {}
stringVal = bigintVal.toLocaleString(); // should not error - bigintVal inferred as {}
// Test BigInt64Array
var bigIntArray = new BigInt64Array();
bigIntArray = new BigInt64Array(10);
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
bigIntArray = new BigInt64Array([1, 2, 3]);
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
var len = bigIntArray.length;
bigIntArray.length = 10;
var arrayBufferLike = bigIntArray;
// Test BigUint64Array
var bigUintArray = new BigUint64Array();
bigUintArray = new BigUint64Array(10);
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
bigUintArray = new BigUint64Array([1, 2, 3]);
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
len = bigIntArray.length;
bigIntArray.length = 10;
arrayBufferLike = bigIntArray;
// Test added DataView methods
var dataView = new DataView(new ArrayBuffer(80));
dataView.setBigInt64(1, -1n);
dataView.setBigInt64(1, -1n, true);
dataView.setBigInt64(1, -1);
dataView.setBigUint64(2, 123n);
dataView.setBigUint64(2, 123n, true);
dataView.setBigUint64(2, 123);
bigintVal = dataView.getBigInt64(1);
bigintVal = dataView.getBigInt64(1, true);
bigintVal = dataView.getBigUint64(2);
bigintVal = dataView.getBigUint64(2, true);
@@ -0,0 +1,154 @@
=== tests/cases/compiler/bigintWithoutLib.ts ===
// Every line should error because these builtins are not declared
// Test BigInt functions
let bigintVal: bigint = BigInt(123);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
bigintVal = BigInt("456");
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
new BigInt(123);
bigintVal = BigInt.asIntN(8, 0xFFFFn);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
bigintVal = BigInt.asUintN(8, 0xFFFFn);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
bigintVal = bigintVal.valueOf(); // should error - bigintVal inferred as {}
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>bigintVal.valueOf : Symbol(Object.valueOf, Decl(lib.es5.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>valueOf : Symbol(Object.valueOf, Decl(lib.es5.d.ts, --, --))
let stringVal: string = bigintVal.toString(); // should not error - bigintVal inferred as {}
>stringVal : Symbol(stringVal, Decl(bigintWithoutLib.ts, 9, 3))
>bigintVal.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {}
>stringVal : Symbol(stringVal, Decl(bigintWithoutLib.ts, 9, 3))
>bigintVal.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
stringVal = bigintVal.toLocaleString(); // should not error - bigintVal inferred as {}
>stringVal : Symbol(stringVal, Decl(bigintWithoutLib.ts, 9, 3))
>bigintVal.toLocaleString : Symbol(Object.toLocaleString, Decl(lib.es5.d.ts, --, --))
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>toLocaleString : Symbol(Object.toLocaleString, Decl(lib.es5.d.ts, --, --))
// Test BigInt64Array
let bigIntArray: BigInt64Array = new BigInt64Array();
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray = new BigInt64Array(10);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray = new BigInt64Array([1n, 2n, 3n]);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray = new BigInt64Array([1, 2, 3]);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray = new BigInt64Array(new ArrayBuffer(80));
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3);
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
let len: number = bigIntArray.length;
>len : Symbol(len, Decl(bigintWithoutLib.ts, 21, 3))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray.length = 10;
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
let arrayBufferLike: ArrayBufferView = bigIntArray;
>arrayBufferLike : Symbol(arrayBufferLike, Decl(bigintWithoutLib.ts, 23, 3))
>ArrayBufferView : Symbol(ArrayBufferView, Decl(lib.es5.d.ts, --, --))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
// Test BigUint64Array
let bigUintArray: BigUint64Array = new BigUint64Array();
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
bigUintArray = new BigUint64Array(10);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
bigUintArray = new BigUint64Array([1n, 2n, 3n]);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
bigUintArray = new BigUint64Array([1, 2, 3]);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
>bigUintArray : Symbol(bigUintArray, Decl(bigintWithoutLib.ts, 26, 3))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
len = bigIntArray.length;
>len : Symbol(len, Decl(bigintWithoutLib.ts, 21, 3))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
bigIntArray.length = 10;
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
arrayBufferLike = bigIntArray;
>arrayBufferLike : Symbol(arrayBufferLike, Decl(bigintWithoutLib.ts, 23, 3))
>bigIntArray : Symbol(bigIntArray, Decl(bigintWithoutLib.ts, 14, 3))
// Test added DataView methods
const dataView = new DataView(new ArrayBuffer(80));
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
>DataView : Symbol(DataView, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
dataView.setBigInt64(1, -1n);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
dataView.setBigInt64(1, -1n, true);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
dataView.setBigInt64(1, -1);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
dataView.setBigUint64(2, 123n);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
dataView.setBigUint64(2, 123n, true);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
dataView.setBigUint64(2, 123);
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
bigintVal = dataView.getBigInt64(1);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
bigintVal = dataView.getBigInt64(1, true);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
bigintVal = dataView.getBigUint64(2);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
bigintVal = dataView.getBigUint64(2, true);
>bigintVal : Symbol(bigintVal, Decl(bigintWithoutLib.ts, 3, 3))
>dataView : Symbol(dataView, Decl(bigintWithoutLib.ts, 38, 5))
Loaded 100 of 390 files, more files were not shown because too many files have changed in this diff. Show more