Created
May 18, 2018 12:48
-
-
Save tlaitinen/0531dd0963da5e7ccaa70f5bcd641c5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as t from 'io-ts'; | |
| import {DateFromISOString} from 'io-ts-types/lib/Date/DateFromISOString'; | |
| const Type = t.type({ | |
| time: DateFromISOString | |
| }); | |
| console.log(Type.decode({time:'2018-05-18T12:43:55.709Z'})); | |
| function decode<T>(type:t.Type<T>) { | |
| console.log(type.decode({time:'2018-05-18T12:43:55.709Z'})); | |
| } | |
| decode(Type); | |
| /* | |
| TSError: ⨯ Unable to compile TypeScript | |
| test.ts (14,8): Argument of type 'InterfaceType<{ time: DateFromISOStringType; }, TypeOfProps<{ time: DateFromISOStringType; }>, Ou...' is not assignable to parameter of type 'Type<TypeOfProps<{ time: DateFromISOStringType; }>, TypeOfProps<{ time: DateFromISOStringType; }>...'. | |
| Types of property 'encode' are incompatible. | |
| Type 'Encode<TypeOfProps<{ time: DateFromISOStringType; }>, OutputOfProps<{ time: DateFromISOStringType...' is not assignable to type 'Encode<TypeOfProps<{ time: DateFromISOStringType; }>, TypeOfProps<{ time: DateFromISOStringType; ...'. | |
| Type 'OutputOfProps<{ time: DateFromISOStringType; }>' is not assignable to type 'TypeOfProps<{ time: DateFromISOStringType; }>'. | |
| Types of property 'time' are incompatible. | |
| Type 'string' is not assignable to type 'Date'. (2345) | |
| at getOutput (/home/tero/node-v9.4.0-linux-x64/lib/node_modules/ts-node/src/index.ts:330:15) | |
| at Object.compile (/home/tero/node-v9.4.0-linux-x64/lib/node_modules/ts-node/src/index.ts:516:11) | |
| at Module.m._compile (/home/tero/node-v9.4.0-linux-x64/lib/node_modules/ts-node/src/index.ts:403:43) | |
| at Module._extensions..js (module.js:671:10) | |
| at Object.require.extensions.(anonymous function) [as .ts] (/home/tero/node-v9.4.0-linux-x64/lib/node_modules/ts-node/src/index.ts:406:12) | |
| at Module.load (module.js:573:32) | |
| at tryModuleLoad (module.js:513:12) | |
| at Function.Module._load (module.js:505:3) | |
| at Function.Module.runMain (module.js:701:10) | |
| at Object.<anonymous> (/home/tero/node-v9.4.0-linux-x64/lib/node_modules/ts-node/src/bin.ts:145:12) | |
| */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment