Skip to content

Commit 6093e0c

Browse files
authored
move "development" TS version to TS3.9, use @ts-expect-error in CI whenever possible (#811)
1 parent 01e8518 commit 6093e0c

18 files changed

+215
-160
lines changed

.travis.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,46 @@ env:
44
- TYPESCRIPT_VERSION=next
55
- TYPESCRIPT_VERSION=4.0
66
- TYPESCRIPT_VERSION=3.9
7-
- TYPESCRIPT_VERSION=3.8
8-
- TYPESCRIPT_VERSION=3.7
9-
- TYPESCRIPT_VERSION=3.6
10-
- TYPESCRIPT_VERSION=3.5
117
install:
128
- npm ci --ignore-scripts
139
- npm install typescript@$TYPESCRIPT_VERSION
1410
script: npm run prepare
11+
12+
jobs:
13+
include:
14+
- env:
15+
- TYPESCRIPT_VERSION=3.8
16+
install:
17+
- npm ci --ignore-scripts
18+
- npm install typescript@$TYPESCRIPT_VERSION
19+
- sed -i -e 's/"cd type-tests.*"/"true"/' package.json
20+
- sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*
21+
- mv type-tests/types.test.disabled.ts type-tests/types.test.ts
22+
script: npm run prepare
23+
- env:
24+
- TYPESCRIPT_VERSION=3.7
25+
install:
26+
- npm ci --ignore-scripts
27+
- npm install typescript@$TYPESCRIPT_VERSION
28+
- sed -i -e 's/"cd type-tests.*"/"true"/' package.json
29+
- sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*
30+
- mv type-tests/types.test.disabled.ts type-tests/types.test.ts
31+
script: npm run prepare
32+
- env:
33+
- TYPESCRIPT_VERSION=3.6
34+
install:
35+
- npm ci --ignore-scripts
36+
- npm install typescript@$TYPESCRIPT_VERSION
37+
- sed -i -e 's/"cd type-tests.*"/"true"/' package.json
38+
- sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*
39+
- mv type-tests/types.test.disabled.ts type-tests/types.test.ts
40+
script: npm run prepare
41+
- env:
42+
- TYPESCRIPT_VERSION=3.5
43+
install:
44+
- npm ci --ignore-scripts
45+
- npm install typescript@$TYPESCRIPT_VERSION
46+
- sed -i -e 's/"cd type-tests.*"/"true"/' package.json
47+
- sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*
48+
- mv type-tests/types.test.disabled.ts type-tests/types.test.ts
49+
script: npm run prepare

package-lock.json

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"rollup-plugin-strip-code": "^0.2.6",
4141
"tsdx": "^0.11.0",
4242
"tslib": "^1.10.0",
43-
"typescript": "^3.8.2",
43+
"typescript": "^3.9.7",
4444
"typings-tester": "^0.3.2"
4545
},
4646
"scripts": {
@@ -50,8 +50,9 @@
5050
"format": "prettier --write \"src/**/*.ts\" \"**/*.md\"",
5151
"format:check": "prettier --list-different \"src/**/*.ts\" \"docs/*/**.md\"",
5252
"lint": "tsdx lint src",
53-
"prepare": "npm run lint && npm run format:check && npm test && npm run build-ci",
54-
"test": "tsdx test"
53+
"prepare": "npm run lint && npm run format:check && npm test && npm run type-tests && npm run build-ci",
54+
"test": "tsdx test",
55+
"type-tests": "cd type-tests/files && tsc"
5556
},
5657
"files": [
5758
"dist/*.js",

src/createSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ActionReducerMapBuilder,
1313
executeReducerBuilderCallback
1414
} from './mapBuilders'
15-
import { Omit, NoInfer } from './tsHelpers'
15+
import { NoInfer } from './tsHelpers'
1616

1717
/**
1818
* An action creator attached to a slice.

src/entities/state_selectors.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ describe('Entity State Selectors', () => {
100100
})
101101

102102
it('should type single entity from Dictionary as entity type or undefined', () => {
103-
const singleEntity: Selector<
104-
EntityState<BookModel>,
105-
BookModel | undefined
106-
> = createSelector(selectors.selectEntities, entities => entities[0])
103+
expectType<Selector<EntityState<BookModel>, BookModel | undefined>>(
104+
createSelector(selectors.selectEntities, entities => entities[0])
105+
)
107106
})
108107

109108
it('should create a selector for selecting the list of models', () => {
@@ -126,3 +125,7 @@ describe('Entity State Selectors', () => {
126125
})
127126
})
128127
})
128+
129+
function expectType<T>(t: T) {
130+
return t
131+
}

src/entities/unsorted_state_adapter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('Unsorted State Adapter', () => {
124124
})
125125

126126
it('should let you add remove an entity from the state', () => {
127-
const withOneEntity = adapter.addOne(state, TheGreatGatsby)
127+
/* const withOneEntity = */ adapter.addOne(state, TheGreatGatsby)
128128

129129
const withoutOne = adapter.removeOne(state, TheGreatGatsby.id)
130130

src/entities/utils.spec.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ describe('Entity utils', () => {
1717
it('should not warn when key does exist', () => {
1818
const spy = spyOn(console, 'warn')
1919

20-
const key = selectIdValue(AClockworkOrange, book => book.id)
20+
selectIdValue(AClockworkOrange, book => book.id)
2121

2222
expect(spy).not.toHaveBeenCalled()
2323
})
2424

2525
it('should warn when key does not exist in dev mode', () => {
2626
const spy = spyOn(console, 'warn')
2727

28-
const key = selectIdValue(AClockworkOrange, (book: any) => book.foo)
28+
selectIdValue(AClockworkOrange, (book: any) => book.foo)
2929

3030
expect(spy).toHaveBeenCalled()
3131
})
@@ -34,10 +34,7 @@ describe('Entity utils', () => {
3434
const spy = spyOn(console, 'warn')
3535

3636
const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined }
37-
const key = selectIdValue(
38-
undefinedAClockworkOrange,
39-
(book: any) => book.id
40-
)
37+
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id)
4138

4239
expect(spy).toHaveBeenCalled()
4340
})
@@ -46,7 +43,7 @@ describe('Entity utils', () => {
4643
process.env.NODE_ENV = 'production'
4744
const spy = spyOn(console, 'warn')
4845

49-
const key = selectIdValue(AClockworkOrange, (book: any) => book.foo)
46+
selectIdValue(AClockworkOrange, (book: any) => book.foo)
5047

5148
expect(spy).not.toHaveBeenCalled()
5249
})
@@ -56,10 +53,7 @@ describe('Entity utils', () => {
5653
const spy = spyOn(console, 'warn')
5754

5855
const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined }
59-
const key = selectIdValue(
60-
undefinedAClockworkOrange,
61-
(book: any) => book.id
62-
)
56+
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id)
6357

6458
expect(spy).not.toHaveBeenCalled()
6559
})

src/tsHelpers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,3 @@ type UnionToIntersection<U> = (U extends any
9898
* @internal
9999
*/
100100
export type NoInfer<T> = [T][T extends any ? 0 : never]
101-
102-
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>

0 commit comments

Comments
 (0)