diff --git a/tsc/internal/checker/checker.go b/tsc/internal/checker/checker.go index 148cf5fde47dd..bd09f1f554e83 100644 --- a/tsc/internal/checker/checker.go +++ b/tsc/internal/checker/checker.go @@ -11830,7 +11830,12 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType * } func (c *Checker) getSuggestedLibForNonExistentProperty(missingProperty string, containingType *Type) string { - container := c.getApparentType(containingType).symbol + t := c.getApparentType(containingType) + if isTupleType(t) { + // Tuple types have no symbol; use their Array or ReadonlyArray base. + t = core.IfElse(t.TargetTupleType().readonly, c.globalReadonlyArrayType, c.globalArrayType) + } + container := t.symbol if container != nil { featureMap := getFeatureMap() if typeFeatures, ok := featureMap[container.Name()]; ok { diff --git a/tsc/internal/checker/utilities.go b/tsc/internal/checker/utilities.go index 3a7e9993ba879..bacce8f971823 100644 --- a/tsc/internal/checker/utilities.go +++ b/tsc/internal/checker/utilities.go @@ -1421,6 +1421,14 @@ var getFeatureMap = sync.OnceValue(func() map[string][]FeatureMapEntry { {lib: "es2022", props: []string{"at"}}, {lib: "es2023", props: []string{"findLastIndex", "findLast", "toReversed", "toSorted", "toSpliced", "with"}}, }, + "ReadonlyArray": { + {lib: "es5", props: []string{}}, + {lib: "es2015", props: []string{"find", "findIndex", "entries", "keys", "values"}}, + {lib: "es2016", props: []string{"includes"}}, + {lib: "es2019", props: []string{"flat", "flatMap"}}, + {lib: "es2022", props: []string{"at"}}, + {lib: "es2023", props: []string{"findLastIndex", "findLast", "toReversed", "toSorted", "toSpliced", "with"}}, + }, "Iterator": { {lib: "es2015", props: []string{}}, }, @@ -1525,6 +1533,9 @@ var getFeatureMap = sync.OnceValue(func() map[string][]FeatureMapEntry { "getOrInsertComputed", }}, }, + "ReadonlyMap": { + {lib: "es2015", props: []string{"entries", "keys", "values"}}, + }, "MapConstructor": { {lib: "es2024", props: []string{"groupBy"}}, }, @@ -1540,6 +1551,18 @@ var getFeatureMap = sync.OnceValue(func() map[string][]FeatureMapEntry { "isDisjointFrom", }}, }, + "ReadonlySet": { + {lib: "es2015", props: []string{"entries", "keys", "values"}}, + {lib: "es2025", props: []string{ + "union", + "intersection", + "difference", + "symmetricDifference", + "isSubsetOf", + "isSupersetOf", + "isDisjointFrom", + }}, + }, "PromiseConstructor": { {lib: "es2015", props: []string{"all", "race", "reject", "resolve"}}, {lib: "es2020", props: []string{"allSettled"}}, diff --git a/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=es2015).errors.txt b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=es2015).errors.txt new file mode 100644 index 0000000000000..1db537a5cabd0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=es2015).errors.txt @@ -0,0 +1,132 @@ +doYouNeedToChangeYourTargetLibraryReadonly.ts(7,7): error TS2550: Property 'includes' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(8,7): error TS2550: Property 'flat' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(9,7): error TS2550: Property 'flatMap' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(10,7): error TS2550: Property 'at' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(11,7): error TS2550: Property 'findLastIndex' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(12,7): error TS2550: Property 'findLast' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(13,7): error TS2550: Property 'toReversed' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(14,7): error TS2550: Property 'toSorted' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(15,7): error TS2550: Property 'toSpliced' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(16,7): error TS2550: Property 'with' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(19,15): error TS2550: Property 'toReversed' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(20,22): error TS2550: Property 'toReversed' does not exist on type 'readonly [1, 2, 3]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(23,7): error TS2550: Property 'toReversed' does not exist on type '[number, string]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(26,11): error TS2550: Property 'toReversed' does not exist on type 'T'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(38,5): error TS2550: Property 'union' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(39,5): error TS2550: Property 'intersection' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(40,5): error TS2550: Property 'difference' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(41,5): error TS2550: Property 'symmetricDifference' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(42,5): error TS2550: Property 'isSubsetOf' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(43,5): error TS2550: Property 'isSupersetOf' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(44,5): error TS2550: Property 'isDisjointFrom' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. +doYouNeedToChangeYourTargetLibraryReadonly.ts(46,7): error TS2339: Property 'fill' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(47,7): error TS2339: Property 'copyWithin' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(48,7): error TS2339: Property 'notAnArrayMethod' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(49,5): error TS2339: Property 'getOrInsert' does not exist on type 'ReadonlyMap'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(50,5): error TS2339: Property 'getOrInsertComputed' does not exist on type 'ReadonlyMap'. + + +==== doYouNeedToChangeYourTargetLibraryReadonly.ts (26 errors) ==== + declare const array: ReadonlyArray; + array.find; + array.findIndex; + array.entries; + array.keys; + array.values; + array.includes; + ~~~~~~~~ +!!! error TS2550: Property 'includes' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later. + array.flat; + ~~~~ +!!! error TS2550: Property 'flat' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. + array.flatMap; + ~~~~~~~ +!!! error TS2550: Property 'flatMap' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later. + array.at; + ~~ +!!! error TS2550: Property 'at' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. + array.findLastIndex; + ~~~~~~~~~~~~~ +!!! error TS2550: Property 'findLastIndex' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + array.findLast; + ~~~~~~~~ +!!! error TS2550: Property 'findLast' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + array.toReversed; + ~~~~~~~~~~ +!!! error TS2550: Property 'toReversed' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + array.toSorted; + ~~~~~~~~ +!!! error TS2550: Property 'toSorted' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + array.toSpliced; + ~~~~~~~~~ +!!! error TS2550: Property 'toSpliced' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + array.with; + ~~~~ +!!! error TS2550: Property 'with' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + + declare const readonlyArray: readonly number[]; + readonlyArray.toReversed; + ~~~~~~~~~~ +!!! error TS2550: Property 'toReversed' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + ([1, 2, 3] as const).toReversed(); + ~~~~~~~~~~ +!!! error TS2550: Property 'toReversed' does not exist on type 'readonly [1, 2, 3]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + + declare const tuple: [number, string]; + tuple.toReversed; + ~~~~~~~~~~ +!!! error TS2550: Property 'toReversed' does not exist on type '[number, string]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + + function f(value: T) { + value.toReversed; + ~~~~~~~~~~ +!!! error TS2550: Property 'toReversed' does not exist on type 'T'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. + } + + declare const map: ReadonlyMap; + map.entries; + map.keys; + map.values; + + declare const set: ReadonlySet; + set.entries; + set.keys; + set.values; + set.union; + ~~~~~ +!!! error TS2550: Property 'union' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.intersection; + ~~~~~~~~~~~~ +!!! error TS2550: Property 'intersection' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.difference; + ~~~~~~~~~~ +!!! error TS2550: Property 'difference' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.symmetricDifference; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2550: Property 'symmetricDifference' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.isSubsetOf; + ~~~~~~~~~~ +!!! error TS2550: Property 'isSubsetOf' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.isSupersetOf; + ~~~~~~~~~~~~ +!!! error TS2550: Property 'isSupersetOf' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + set.isDisjointFrom; + ~~~~~~~~~~~~~~ +!!! error TS2550: Property 'isDisjointFrom' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2025' or later. + + array.fill; + ~~~~ +!!! error TS2339: Property 'fill' does not exist on type 'readonly number[]'. + array.copyWithin; + ~~~~~~~~~~ +!!! error TS2339: Property 'copyWithin' does not exist on type 'readonly number[]'. + array.notAnArrayMethod; + ~~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'notAnArrayMethod' does not exist on type 'readonly number[]'. + map.getOrInsert; + ~~~~~~~~~~~ +!!! error TS2339: Property 'getOrInsert' does not exist on type 'ReadonlyMap'. + map.getOrInsertComputed; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'getOrInsertComputed' does not exist on type 'ReadonlyMap'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=esnext).errors.txt b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=esnext).errors.txt new file mode 100644 index 0000000000000..d80c84d68d9ae --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonly(target=esnext).errors.txt @@ -0,0 +1,69 @@ +doYouNeedToChangeYourTargetLibraryReadonly.ts(46,7): error TS2339: Property 'fill' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(47,7): error TS2339: Property 'copyWithin' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(48,7): error TS2339: Property 'notAnArrayMethod' does not exist on type 'readonly number[]'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(49,5): error TS2339: Property 'getOrInsert' does not exist on type 'ReadonlyMap'. +doYouNeedToChangeYourTargetLibraryReadonly.ts(50,5): error TS2339: Property 'getOrInsertComputed' does not exist on type 'ReadonlyMap'. + + +==== doYouNeedToChangeYourTargetLibraryReadonly.ts (5 errors) ==== + declare const array: ReadonlyArray; + array.find; + array.findIndex; + array.entries; + array.keys; + array.values; + array.includes; + array.flat; + array.flatMap; + array.at; + array.findLastIndex; + array.findLast; + array.toReversed; + array.toSorted; + array.toSpliced; + array.with; + + declare const readonlyArray: readonly number[]; + readonlyArray.toReversed; + ([1, 2, 3] as const).toReversed(); + + declare const tuple: [number, string]; + tuple.toReversed; + + function f(value: T) { + value.toReversed; + } + + declare const map: ReadonlyMap; + map.entries; + map.keys; + map.values; + + declare const set: ReadonlySet; + set.entries; + set.keys; + set.values; + set.union; + set.intersection; + set.difference; + set.symmetricDifference; + set.isSubsetOf; + set.isSupersetOf; + set.isDisjointFrom; + + array.fill; + ~~~~ +!!! error TS2339: Property 'fill' does not exist on type 'readonly number[]'. + array.copyWithin; + ~~~~~~~~~~ +!!! error TS2339: Property 'copyWithin' does not exist on type 'readonly number[]'. + array.notAnArrayMethod; + ~~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'notAnArrayMethod' does not exist on type 'readonly number[]'. + map.getOrInsert; + ~~~~~~~~~~~ +!!! error TS2339: Property 'getOrInsert' does not exist on type 'ReadonlyMap'. + map.getOrInsertComputed; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'getOrInsertComputed' does not exist on type 'ReadonlyMap'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.errors.txt b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.errors.txt new file mode 100644 index 0000000000000..bd9878a3ad7a1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.errors.txt @@ -0,0 +1,58 @@ +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(2,7): error TS2550: Property 'find' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(3,7): error TS2550: Property 'findIndex' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(4,7): error TS2550: Property 'entries' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(5,7): error TS2550: Property 'keys' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(6,7): error TS2550: Property 'values' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(9,5): error TS2550: Property 'entries' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(10,5): error TS2550: Property 'keys' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(11,5): error TS2550: Property 'values' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(14,5): error TS2550: Property 'entries' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(15,5): error TS2550: Property 'keys' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(16,5): error TS2550: Property 'values' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts(18,22): error TS2339: Property 'fill' does not exist on type 'readonly [1, 2, 3]'. + + +==== doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts (12 errors) ==== + declare const array: ReadonlyArray; + array.find; + ~~~~ +!!! error TS2550: Property 'find' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + array.findIndex; + ~~~~~~~~~ +!!! error TS2550: Property 'findIndex' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + array.entries; + ~~~~~~~ +!!! error TS2550: Property 'entries' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + array.keys; + ~~~~ +!!! error TS2550: Property 'keys' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + array.values; + ~~~~~~ +!!! error TS2550: Property 'values' does not exist on type 'readonly number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + + declare const map: ReadonlyMap; + map.entries; + ~~~~~~~ +!!! error TS2550: Property 'entries' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + map.keys; + ~~~~ +!!! error TS2550: Property 'keys' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + map.values; + ~~~~~~ +!!! error TS2550: Property 'values' does not exist on type 'ReadonlyMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + + declare const set: ReadonlySet; + set.entries; + ~~~~~~~ +!!! error TS2550: Property 'entries' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + set.keys; + ~~~~ +!!! error TS2550: Property 'keys' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + set.values; + ~~~~~~ +!!! error TS2550: Property 'values' does not exist on type 'ReadonlySet'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + + ([1, 2, 3] as const).fill; + ~~~~ +!!! error TS2339: Property 'fill' does not exist on type 'readonly [1, 2, 3]'. + \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonly.ts b/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonly.ts new file mode 100644 index 0000000000000..29df9d9416c11 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonly.ts @@ -0,0 +1,54 @@ +// @target: es2015, esnext +// @noEmit: true +// @noTypesAndSymbols: true + +declare const array: ReadonlyArray; +array.find; +array.findIndex; +array.entries; +array.keys; +array.values; +array.includes; +array.flat; +array.flatMap; +array.at; +array.findLastIndex; +array.findLast; +array.toReversed; +array.toSorted; +array.toSpliced; +array.with; + +declare const readonlyArray: readonly number[]; +readonlyArray.toReversed; +([1, 2, 3] as const).toReversed(); + +declare const tuple: [number, string]; +tuple.toReversed; + +function f(value: T) { + value.toReversed; +} + +declare const map: ReadonlyMap; +map.entries; +map.keys; +map.values; + +declare const set: ReadonlySet; +set.entries; +set.keys; +set.values; +set.union; +set.intersection; +set.difference; +set.symmetricDifference; +set.isSubsetOf; +set.isSupersetOf; +set.isDisjointFrom; + +array.fill; +array.copyWithin; +array.notAnArrayMethod; +map.getOrInsert; +map.getOrInsertComputed; diff --git a/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts b/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts new file mode 100644 index 0000000000000..56f21d178cc96 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryReadonlyES2015.ts @@ -0,0 +1,23 @@ +// @target: es2015 +// @lib: es5, es2015.collection +// @noEmit: true +// @noTypesAndSymbols: true + +declare const array: ReadonlyArray; +array.find; +array.findIndex; +array.entries; +array.keys; +array.values; + +declare const map: ReadonlyMap; +map.entries; +map.keys; +map.values; + +declare const set: ReadonlySet; +set.entries; +set.keys; +set.values; + +([1, 2, 3] as const).fill;