diff --git a/lib/lib.es2020.intl.d.ts b/lib/lib.es2020.intl.d.ts index 25c6aa1b8f272..1ec4628bb94dd 100644 --- a/lib/lib.es2020.intl.d.ts +++ b/lib/lib.es2020.intl.d.ts @@ -74,239 +74,6 @@ declare namespace Intl { */ type RelativeTimeFormatStyle = "long" | "short" | "narrow"; - /** - * Unicode Calendar Identifier - * - * [Reference](http://unicode.org/reports/tr35/#UnicodeCalendarIdentifier) - * - * [Source](https://github.com/unicode-org/cldr/blob/b805d0b/common/bcp47/calendar.xml) - */ - type Calendar = - // Thai Buddhist calendar - | "buddhist" - // Traditional Chinese calendar - | "chinese" - // Coptic calendar - | "coptic" - // Traditional Korean calendar - | "dangi" - // Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) - | "ethiopic-amete-alem" | "ethioaa" - // Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) - | "ethiopic" - // Gregorian calendar - | "gregorian" - // Gregorian calendar (alias) - | "gregory" - // Traditional Hebrew calendar - | "hebrew" - // Indian calendar - | "indian" - // Islamic calendar - | "islamic" - // Islamic calendar, Umm al-Qura - | "islamic-umalqura" - // Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) - | "islamic-tbla" - // Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) - | "islamic-civil" - | "islamicc" // Deprecated alias - // Islamic calendar, Saudi Arabia sighting - | "islamic-rgsa" - // ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) - | "iso8601" - // Japanese Imperial calendar - | "japanese" - // Persian calendar - | "persian" - // Republic of China calendar - | "roc" - ; - - /** - * Unicode Number System Identifier - * - * [Reference](http://unicode.org/reports/tr35/#UnicodeNumberSystemIdentifier) - * - * [Source](https://github.com/unicode-org/cldr/blob/be7a953/common/bcp47/number.xml) - */ - type NumberingSystem = - // Adlam digits - | "adlm" - // Ahom digits - | "ahom" - // Arabic-Indic digits - | "arab" - // Extended Arabic-Indic digits - | "arabext" - // Armenian upper case numerals — algorithmic - | "armn" - // Armenian lower case numerals — algorithmic - | "armnlow" - // Balinese digits - | "bali" - // Bengali digits - | "beng" - // Bhaiksuki digits - | "bhks" - // Brahmi digits - | "brah" - // Chakma digits - | "cakm" - // Cham digits - | "cham" - // Cyrillic numerals — algorithmic - | "cyrl" - // Devanagari digits - | "deva" - // Dives Akuru digits - | "diak" - // Ethiopic numerals — algorithmic - | "ethi" - // Financial numerals — may be algorithmic - | "finance" - // Full width digits - | "fullwide" - // Georgian numerals — algorithmic - | "geor" - // Gunjala Gondi digits - | "gong" - // Masaram Gondi digits - | "gonm" - // Greek upper case numerals — algorithmic - | "grek" - // Greek lower case numerals — algorithmic - | "greklow" - // Gujarati digits - | "gujr" - // Gurmukhi digits - | "guru" - // Han-character day-of-month numbering for lunar/other traditional calendars" - | "hanidays" - // Positional decimal system using Chinese number ideographs as digits - | "hanidec" - // Simplified Chinese numerals — algorithmic - | "hans" - // Simplified Chinese financial numerals — algorithmic - | "hansfin" - // Traditional Chinese numerals — algorithmic - | "hant" - // Traditional Chinese financial numerals — algorithmic - | "hantfin" - // Hebrew numerals — algorithmic - | "hebr" - // Pahawh Hmong digits - | "hmng" - // Nyiakeng Puachue Hmong digits - | "hmnp" - // Javanese digits - | "java" - // Japanese numerals — algorithmic - | "jpan" - // Japanese financial numerals — algorithmic - | "jpanfin" - // Japanese first-year Gannen numbering for Japanese calendar - | "jpanyear" - // Kayah Li digits - | "kali" - // Khmer digits - | "khmr" - // Kannada digits - | "knda" - // Tai Tham Hora (secular) digits - | "lana" - // Tai Tham Tham (ecclesiastical) digits - | "lanatham" - // Lao digits - | "laoo" - // Latin digits - | "latn" - // Lepcha digits - | "lepc" - // Limbu digits - | "limb" - // Mathematical bold digits - | "mathbold" - // Mathematical double-struck digits - | "mathdbl" - // Mathematical monospace digits - | "mathmono" - // Mathematical sans-serif bold digits - | "mathsanb" - // Mathematical sans-serif digits - | "mathsans" - // Malayalam digits - | "mlym" - // Modi digits - | "modi" - // Mongolian digits - | "mong" - // Mro digits - | "mroo" - // Meetei Mayek digits - | "mtei" - // Myanmar digits - | "mymr" - // Myanmar Shan digits - | "mymrshan" - // Myanmar Tai Laing digits - | "mymrtlng" - // Native digits - | "native" - // Newa digits - | "newa" - // N'Ko digits - | "nkoo" - // Ol Chiki digits - | "olck" - // Oriya digits - | "orya" - // Osmanya digits - | "osma" - // Hanifi Rohingya digits - | "rohg" - // Roman upper case numerals — algorithmic - | "roman" - // Roman lowercase numerals — algorithmic - | "romanlow" - // Saurashtra digits - | "saur" - // Sharada digits - | "shrd" - // Khudawadi digits - | "sind" - // Sinhala Lith digits - | "sinh" - // Sora_Sompeng digits - | "sora" - // Sundanese digits - | "sund" - // Takri digits - | "takr" - // New Tai Lue digits - | "talu" - // Tamil numerals — algorithmic - | "taml" - // Modern Tamil decimal digits - | "tamldec" - // Telugu digits - | "telu" - // Thai digits - | "thai" - // Tirhuta digits - | "tirh" - // Tibetan digits - | "tibt" - // Traditional numerals — may be algorithmic - | "traditional" | "traditio" - // Vai digits - | "vaii" - // Warang Citi digits - | "wara" - // Wancho digits - | "wcho" - ; - /** * An object with some or all of properties of `options` parameter * of `Intl.RelativeTimeFormat` constructor. @@ -534,9 +301,9 @@ declare namespace Intl { interface DateTimeFormatOptions { dateStyle?: "full" | "long" | "medium" | "short"; timeStyle?: "full" | "long" | "medium" | "short"; - calendar?: Calendar; + calendar?: string; dayPeriod?: "narrow" | "short" | "long"; - numberingSystem?: NumberingSystem; + numberingSystem?: string; hourCycle?: "h11" | "h12" | "h23" | "h24"; fractionalSecondDigits?: 0 | 1 | 2 | 3; } diff --git a/lib/tsc.js b/lib/tsc.js index f40025ec38f85..b036dfa0fb34f 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -46050,7 +46050,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -46060,7 +46060,7 @@ var ts; flags & 256 && includes & 8 || flags & 2048 && includes & 64 || flags & 8192 && includes & 4096 || - flags & 32768 && includes & 16384 || + reduceVoidUndefined && flags & 32768 && includes & 16384 || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -46121,7 +46121,7 @@ var ts; } if (unionReduction & (1 | 2)) { if (includes & (2944 | 8192) || includes & 16384 && includes & 32768) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2)); } if (includes & 128 && includes & 134217728) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -53172,7 +53172,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -62908,7 +62917,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/lib/tsserver.js b/lib/tsserver.js index 78378cc6eb926..eecb6de986cea 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -55677,7 +55677,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -55687,7 +55687,7 @@ var ts; flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55755,7 +55755,7 @@ var ts; } if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -63776,7 +63776,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -75193,7 +75202,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ee3a343724bd9..2f427b2a31f99 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -55871,7 +55871,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -55881,7 +55881,7 @@ var ts; flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55949,7 +55949,7 @@ var ts; } if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -63970,7 +63970,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -75387,7 +75396,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/lib/typescript.js b/lib/typescript.js index 4ccac1a141ac4..fde2172def3b7 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -55871,7 +55871,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -55881,7 +55881,7 @@ var ts; flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55949,7 +55949,7 @@ var ts; } if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -63970,7 +63970,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -75387,7 +75396,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 9d3d0a2f68f64..77c96789eb5f9 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -55871,7 +55871,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -55881,7 +55881,7 @@ var ts; flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55949,7 +55949,7 @@ var ts; } if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -63970,7 +63970,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -75387,7 +75396,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index f33fba5875463..dac9612324cfb 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -55666,7 +55666,7 @@ var ts; } return true; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; @@ -55676,7 +55676,7 @@ var ts; flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55744,7 +55744,7 @@ var ts; } if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes); + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); @@ -63765,7 +63765,16 @@ var ts; var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; - var prop = getPropertyOfType(type, ts.isPrivateIdentifier(name) ? ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText); + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } return prop && getExplicitTypeOfSymbol(prop, diagnostic); } return undefined; @@ -75182,7 +75191,9 @@ var ts; : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var possiblyFalsy = getFalsyFlags(type); diff --git a/package.json b/package.json index 7588a51cfc211..a31d5c9b770a2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.2.1-rc", + "version": "4.2.2", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [