@@ -2,10 +2,12 @@ import {
2
2
AiAlreadyDeclaredVariableError ,
3
3
AiCanNotAssignToImmutableVariableError ,
4
4
AiCanNotCallError ,
5
+ AiCanNotReadPropertyError ,
5
6
AiInvalidArgumentError ,
6
7
AiMissingArgumentError ,
7
8
AiNotAssignableTypeError ,
8
9
AiTypeErrorKind ,
10
+ AiUnDeclaredVariableError ,
9
11
} from "../../errors/AiTypeError.js" ;
10
12
import { TypeError } from "../../index.js" ;
11
13
import { I18nLocalizerResult , I18nMessage , I18nMessages } from "../core.js" ;
@@ -31,6 +33,12 @@ export const typeErrorMessage = {
31
33
CanNotAssignToImmutableVariable ( name : string ) {
32
34
return `変数\`${ name } \`は不変なので、新たに代入することはできません。` ;
33
35
} ,
36
+ UnDeclaredVariable ( name : string ) {
37
+ return `変数\`${ name } \`は定義されていません。` ;
38
+ } ,
39
+ CanNotReadProperty ( target : string , name : string ) {
40
+ return `型\`${ target } \`から\`${ name } \`プロパティを読み取れません。` ;
41
+ } ,
34
42
} satisfies I18nMessage < keyof typeof AiTypeErrorKind > ,
35
43
} satisfies I18nMessages ;
36
44
@@ -52,6 +60,10 @@ export const typeErrorLocalizer = (
52
60
return [ "typing.MissingArgumentError" , [ error . pos , error . expectType ] ] ;
53
61
} else if ( error instanceof AiCanNotAssignToImmutableVariableError ) {
54
62
return [ "typing.CanNotAssignToImmutableVariable" , [ error . name ] ] ;
63
+ } else if ( error instanceof AiUnDeclaredVariableError ) {
64
+ return [ "typing.UnDeclaredVariable" , [ error . name ] ] ;
65
+ } else if ( error instanceof AiCanNotReadPropertyError ) {
66
+ return [ "typing.CanNotReadProperty" , [ error . targetType , error . name ] ] ;
55
67
}
56
68
57
69
switch ( error . kind ) {
@@ -71,9 +83,15 @@ export const typeErrorLocalizer = (
71
83
] ;
72
84
73
85
case AiTypeErrorKind . MissingArgumentError :
74
- return [ "typing.MissingArgumentError" , [ - 1 , "<:unknown:>" ] ] ;
86
+ return [ "typing.MissingArgumentError" , [ NaN , "<:unknown:>" ] ] ;
75
87
76
88
case AiTypeErrorKind . CanNotAssignToImmutableVariable :
77
89
return [ "typing.CanNotAssignToImmutableVariable" , [ "<:unknown:>" ] ] ;
90
+
91
+ case AiTypeErrorKind . UnDeclaredVariable :
92
+ return [ "typing.UnDeclaredVariable" , [ "<:unknown:>" ] ] ;
93
+
94
+ case AiTypeErrorKind . CanNotReadProperty :
95
+ return [ "typing.CanNotReadProperty" , [ "<:unknown:>" , "<:unknown:>" ] ] ;
78
96
}
79
97
} ;
0 commit comments