Skip to content

Commit

Permalink
Upgrade TypeScript to v5.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Sep 20, 2023
1 parent d714aad commit 817ce9f
Show file tree
Hide file tree
Showing 24 changed files with 11 additions and 176 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2459,7 +2459,7 @@
"tsx": "^3.12.1",
"typedoc": "^0.23.23",
"typedoc-plugin-missing-exports": "^1.0.0",
"typescript": "^4.7.4",
"typescript": "^5.2.2",
"vitest": "^0.34.3",
"world-countries": "^1.8.1"
},
Expand Down
2 changes: 0 additions & 2 deletions src/differenceInCalendarWeeks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('differenceInCalendarWeeks', () => {
new Date(2014, 6 /* Jul */, 8, 18, 0),
new Date(2014, 5 /* Jun */, 29, 6, 0),
{
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -42,7 +41,6 @@ describe('differenceInCalendarWeeks', () => {
new Date(2014, 5 /* Jun */, 29, 6, 0),
{
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
2 changes: 0 additions & 2 deletions src/endOfWeek/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('endOfWeek', () => {
it('allows to specify which day is the first day of the week in locale', () => {
const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0)
const result = endOfWeek(date, {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -41,7 +40,6 @@ describe('endOfWeek', () => {
const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0)
const result = endOfWeek(date, {
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
24 changes: 0 additions & 24 deletions src/format/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,30 +754,6 @@ describe('format', () => {
})
assert(result === 'It works!')
})

it("throws `RangeError` if `options.locale` doesn't have `localize` property", () => {
const customLocale = {
formatLong: {},
}
const block = () =>
format(date, 'yyyy-MM-dd', {
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})

it("throws `RangeError` if `options.locale` doesn't have `formatLong` property", () => {
const customLocale = {
localize: {},
}
const block = () =>
format(date, 'yyyy-MM-dd', {
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})
})

it('throws RangeError exception if the format string contains an unescaped latin alphabet character', () => {
Expand Down
18 changes: 0 additions & 18 deletions src/formatDistance/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,30 +234,12 @@ describe('formatDistance', () => {
{
includeSeconds: true,
addSuffix: true,
// @ts-expect-error
locale: customLocale,
}
)

assert(result === 'It works!')
})

describe('does not contain `formatDistance` property', () => {
it('throws `RangeError`', () => {
const customLocale = {}
const block = () =>
formatDistance(
new Date(1986, 3, 4, 10, 32, 0),
new Date(1986, 3, 4, 10, 32, 3),
{
includeSeconds: true,
// @ts-expect-error
locale: customLocale,
}
)
assert.throws(block, RangeError)
})
})
})

it('throws RangeError if the first date is `Invalid Date`', () => {
Expand Down
18 changes: 0 additions & 18 deletions src/formatDistanceStrict/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,30 +400,12 @@ describe('formatDistanceStrict', () => {
new Date(1986, 3, 4, 10, 32, 25),
{
addSuffix: true,
// @ts-expect-error
locale: customLocale,
}
)

assert(result === 'It works!')
})

describe('does not contain `formatDistance` property', () => {
it('throws `RangeError`', () => {
const customLocale = {}
const block = () =>
formatDistanceStrict(
new Date(1986, 3, 4, 10, 32, 0),
new Date(1986, 3, 4, 10, 37, 0),
{
unit: 'minute',
// @ts-expect-error
locale: customLocale,
}
)
assert.throws(block, RangeError)
})
})
})

describe('edge cases', () => {
Expand Down
14 changes: 0 additions & 14 deletions src/formatDistanceToNow/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,11 @@ describe('formatDistanceToNow', () => {

const result = formatDistanceToNow(new Date(1986, 3, 4, 11, 32, 0), {
addSuffix: true,
// @ts-expect-error
locale: customLocale,
})

assert(result === 'It works!')
})

describe('does not contain `distanceInWords` property', () => {
it('throws `RangeError`', function () {
const customLocale = {}
const block = () =>
formatDistanceToNow(new Date(1986, 3, 4, 10, 32, 0), {
includeSeconds: true,
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})
})
})

it('throws RangeError if the passed date is `Invalid Date`', function () {
Expand Down
14 changes: 0 additions & 14 deletions src/formatDistanceToNowStrict/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,12 @@ describe('formatDistanceToNowStrict', () => {
new Date(1986, 3, 4, 10, 31, 45),
{
addSuffix: true,
// @ts-expect-error
locale: customLocale,
}
)

assert(result === 'It works!')
})

describe('does not contain `formatDistance` property', () => {
it('throws `RangeError`', () => {
const customLocale = {}
const block = () =>
formatDistanceToNowStrict(new Date(1986, 3, 4, 10, 37, 0), {
unit: 'minute',
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})
})
})

describe('edge cases', () => {
Expand Down
43 changes: 0 additions & 43 deletions src/formatRelative/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,48 +126,5 @@ describe('formatRelative', () => {
)
assert(result === 'It works perfectly!')
})

it("throws `RangeError` if `options.locale` doesn't have `localize` property", () => {
const customLocale = {
formatLong: {},
formatRelative: () => {
return ''
},
}
const block = () =>
formatRelative(new Date(2017, 0, 1), baseDate, {
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})

it("throws `RangeError` if `options.locale` doesn't have `formatLong` property", () => {
const customLocale = {
localize: {},
formatRelative: () => {
return ''
},
}
const block = () =>
formatRelative(new Date(2017, 0, 1), baseDate, {
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})

it("throws `RangeError` if `options.locale` doesn't have `formatRelative` property", () => {
const customLocale = {
localize: {},
formatLong: {},
}
const block = () =>
formatRelative(new Date(2017, 0, 1), baseDate, {
// @ts-expect-error
locale: customLocale,
})
assert.throws(block, RangeError)
})
})
})
2 changes: 0 additions & 2 deletions src/getWeek/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('getWeek', () => {
it('allows to specify `weekStartsOn` and `firstWeekContainsDate` in locale', () => {
const date = new Date(2005, 0 /* Jan */, 2)
const result = getWeek(date, {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1, firstWeekContainsDate: 4 },
},
Expand All @@ -44,7 +43,6 @@ describe('getWeek', () => {
const result = getWeek(date, {
weekStartsOn: 1,
firstWeekContainsDate: 4,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0, firstWeekContainsDate: 1 },
},
Expand Down
2 changes: 0 additions & 2 deletions src/getWeekOfMonth/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('getWeekOfMonth', () => {

it('allows to specify which day is the first day of the week in locale', () => {
const result = getWeekOfMonth(new Date(2017, 9 /* Oct */, 31), {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -53,7 +52,6 @@ describe('getWeekOfMonth', () => {
it('`options.weekStartsOn` overwrites the first day of the week specified in locale', () => {
const result = getWeekOfMonth(new Date(2017, 10 /* Nov */, 13), {
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
2 changes: 0 additions & 2 deletions src/getWeekYear/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('getWeekYear', () => {
it('allows to specify `weekStartsOn` and `firstWeekContainsDate` in locale', () => {
const date = new Date(2004, 11 /* Dec */, 26)
const result = getWeekYear(date, {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1, firstWeekContainsDate: 4 },
},
Expand All @@ -44,7 +43,6 @@ describe('getWeekYear', () => {
const result = getWeekYear(date, {
weekStartsOn: 1,
firstWeekContainsDate: 4,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0, firstWeekContainsDate: 1 },
},
Expand Down
2 changes: 0 additions & 2 deletions src/getWeeksInMonth/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('getWeeksInMonth', () => {

it('allows to specify which day is the first day of the week in locale', () => {
const result = getWeeksInMonth(new Date(2015, 1 /* Feb */, 8, 18, 0), {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -30,7 +29,6 @@ describe('getWeeksInMonth', () => {
it('`options.weekStartsOn` overwrites the first day of the week specified in locale', () => {
const result = getWeeksInMonth(new Date(2015, 1 /* Feb */, 8, 18, 0), {
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
8 changes: 4 additions & 4 deletions src/intlFormatDistance/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,11 @@ describe('intlFormatDistance', () => {

it('checks unit', () => {
assert.throws(
// @ts-ignore: the value doesnt match one of the Unit values from '../types.ts'
intlFormatDistance.bind(
null,
new Date(1986, 3, 4, 10, 30, 0),
new Date(1986, 3, 4, 10, 30, 0),
// @ts-ignore: the value doesnt match one of the Unit values from '../types.ts'
{ unit: 'wrongValue' }
),
RangeError
Expand All @@ -780,11 +780,11 @@ describe('intlFormatDistance', () => {

it('checks localeMatcher', () => {
assert.throws(
// @ts-expect-error
intlFormatDistance.bind(
null,
new Date(1986, 3, 4, 10, 30, 0),
new Date(1986, 3, 4, 10, 30, 0),
// @ts-expect-error
{ localeMatcher: 'wrongValue' }
),
RangeError
Expand All @@ -793,11 +793,11 @@ describe('intlFormatDistance', () => {

it('checks numeric', () => {
assert.throws(
// @ts-expect-error
intlFormatDistance.bind(
null,
new Date(1986, 3, 4, 10, 30, 0),
new Date(1986, 3, 4, 10, 30, 0),
// @ts-expect-error
{ numeric: 'wrongValue' }
),
RangeError
Expand All @@ -806,11 +806,11 @@ describe('intlFormatDistance', () => {

it('checks style', () => {
assert.throws(
// @ts-expect-error
intlFormatDistance.bind(
null,
new Date(1986, 3, 4, 10, 30, 0),
new Date(1986, 3, 4, 10, 30, 0),
// @ts-expect-error
{ style: 'wrongValue' }
),
RangeError
Expand Down
2 changes: 0 additions & 2 deletions src/isSameWeek/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('isSameWeek', () => {
new Date(2014, 7 /* Aug */, 31),
new Date(2014, 8 /* Sep */, 4),
{
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -50,7 +49,6 @@ describe('isSameWeek', () => {
new Date(2014, 8 /* Sep */, 4),
{
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
2 changes: 0 additions & 2 deletions src/lastDayOfWeek/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('lastDayOfWeek', () => {
it('allows to specify which day is the first day of the week in locale', () => {
const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0)
const result = lastDayOfWeek(date, {
// @ts-expect-error
locale: {
options: { weekStartsOn: 1 },
},
Expand All @@ -32,7 +31,6 @@ describe('lastDayOfWeek', () => {
const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0)
const result = lastDayOfWeek(date, {
weekStartsOn: 1,
// @ts-expect-error
locale: {
options: { weekStartsOn: 0 },
},
Expand Down
9 changes: 0 additions & 9 deletions src/parse/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2287,15 +2287,6 @@ describe('parse', () => {
})
assert.deepStrictEqual(result, new Date(-2017, 0 /* Jan */, 1))
})

it('throws `RangeError` if `options.locale` does not contain `match` property', () => {
const block = () =>
parse('2016-11-25 04 AM', 'yyyy-MM-dd hh a', referenceDate, {
// @ts-expect-error
locale: {},
})
assert.throws(block, RangeError)
})
})

it('accepts a timestamp as `referenceDate`', () => {
Expand Down
Loading

0 comments on commit 817ce9f

Please sign in to comment.