|
| 1 | +//// { compiler: { }, order: 3 } |
| 2 | + |
| 3 | +// Les messages d'erreur TypeScript peuvent être un peu verbeux... |
| 4 | +// Avec la version 3.7, nous avons corrigé quelques cas qui |
| 5 | +// généraient des messages d'erreurs très longs. |
| 6 | + |
| 7 | +// Propriétés imbriquées |
| 8 | + |
| 9 | +let a = { b: { c: { d: { e: "string" } } } }; |
| 10 | +let b = { b: { c: { d: { e: 12 } } } }; |
| 11 | + |
| 12 | +a = b; |
| 13 | + |
| 14 | +// Auparavant, c'était deux lignes de code par propriété imbriquée, ce qui |
| 15 | +// a rapidement amené les gens à lire |
| 16 | +// uniquement la première et dernière ligne des messages d'erreur. |
| 17 | + |
| 18 | +// Maintenant elles sont en ligne. :tada: |
| 19 | + |
| 20 | +// Auparavant avec la version 3.6: |
| 21 | +// |
| 22 | +// Type '{ b: { c: { d: { e: number; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: string; }; }; }; }'. |
| 23 | +// Types of property 'b' are incompatible. |
| 24 | +// Type '{ c: { d: { e: number; }; }; }' is not assignable to type '{ c: { d: { e: string; }; }; }'. |
| 25 | +// Types of property 'c' are incompatible. |
| 26 | +// Type '{ d: { e: number; }; }' is not assignable to type '{ d: { e: string; }; }'. |
| 27 | +// Types of property 'd' are incompatible. |
| 28 | +// Type '{ e: number; }' is not assignable to type '{ e: string; }'. |
| 29 | +// Types of property 'e' are incompatible. |
| 30 | +// Type 'number' is not assignable to type 'string' |
| 31 | + |
| 32 | +// Ça peut aussi marcher avec des objets de types différents |
| 33 | +// et toujours donner un message d'erreur utile et concis. |
| 34 | + |
| 35 | +class ExampleClass { |
| 36 | + state = "ok"; |
| 37 | +} |
| 38 | + |
| 39 | +class OtherClass { |
| 40 | + state = 12; |
| 41 | +} |
| 42 | + |
| 43 | +let x = { a: { b: { c: { d: { e: { f: ExampleClass } } } } } }; |
| 44 | +let y = { a: { b: { c: { d: { e: { f: OtherClass } } } } } }; |
| 45 | +x = y; |
| 46 | + |
| 47 | +// Auparavant avec la version 3.6: |
| 48 | +// |
| 49 | +// Type '{ a: { b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }; }'. |
| 50 | +// Types of property 'a' are incompatible. |
| 51 | +// Type '{ b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }'. |
| 52 | +// Types of property 'b' are incompatible. |
| 53 | +// Type '{ c: { d: { e: { f: typeof OtherClass; }; }; }; }' is not assignable to type '{ c: { d: { e: { f: typeof ExampleClass; }; }; }; }'. |
| 54 | +// Types of property 'c' are incompatible. |
| 55 | +// Type '{ d: { e: { f: typeof OtherClass; }; }; }' is not assignable to type '{ d: { e: { f: typeof ExampleClass; }; }; }'. |
| 56 | +// Types of property 'd' are incompatible. |
| 57 | +// Type '{ e: { f: typeof OtherClass; }; }' is not assignable to type '{ e: { f: typeof ExampleClass; }; }'. |
| 58 | +// Types of property 'e' are incompatible. |
| 59 | +// Type '{ f: typeof OtherClass; }' is not assignable to type '{ f: typeof ExampleClass; }'. |
| 60 | +// Types of property 'f' are incompatible. |
| 61 | +// Type 'typeof OtherClass' is not assignable to type 'typeof ExampleClass'. |
| 62 | +// Type 'OtherClass' is not assignable to type 'ExampleClass'. |
| 63 | +// Types of property 'state' are incompatible. |
| 64 | +// Type 'number' is not assignable to type 'string' |
0 commit comments