typescript 1.3有时会给出错误类型的错误匹配错误

时间:2014-11-17 18:44:35

标签: typescript webstorm

当我使用运行tsc的WebStorm文件观察器编译时,我有时会得到以下内容:

../paragraph/paragraph.ts(193,29): error TS2345: Argument of type 'TYPE' is not assignable to parameter of type 'TYPE'.
../paragraph/paragraph.ts(255,75): error TS2345: Argument of type 'Paragraph' is not assignable to parameter of type 'Paragraph'.
../paragraph/tab.ts(241,37): error TS2345: Argument of type 'ArrayList<TabAttributes>' is not assignable to parameter of type 'ArrayList<TabAttributes>'.
  Type 'TabAttributes' is not assignable to type 'TabAttributes'.

我得到了其中的20个。当我使用VS2013编译时,没问题。当我运行代码时,没问题。但编译器似乎扼杀了一堆这样的东西。这只在我们升级到typescript 1.3时才开始发生。

澄清:当我使用VisualStudio进行构建时,我没有从typescript编译中得到任何错误或警告。当WebStorm编译时,我有时会得到它。但是WebStorm只是将编译器输出传回显示器。

发生了什么事?

更新 - 这是DOS框中的输出编译:

C:\src\jenova\Dev\Merge\AutoTagWeb\client\scripts\layout\document\elements\parag
raph>tsc --target ES5 --module amd --sourcemap paragraph.ts
../../../document/elements/paragraph/line.ts(127,41): error TS2339: Property 'LI
NE' does not exist on type 'typeof TYPE'.
../../../document/elements/position.ts(75,40): error TS2339: Property 'POSITION'
 does not exist on type 'typeof TYPE'.
../../../document/elements/position.ts(184,59): error TS2339: Property 'ABSOLUTE
_POSITION' does not exist on type 'typeof TYPE'.
../../../document/elements/position.ts(193,40): error TS2339: Property 'ABSOLUTE
_POSITION' does not exist on type 'typeof TYPE'.
../../../document/elements/run/run.ts(57,40): error TS2339: Property 'RUN_ELEMEN
T' does not exist on type 'typeof TYPE'.
../../../document/list-body.ts(537,41): error TS2339: Property 'LINE' does not e
xist on type 'typeof TYPE'.
../../../final-format.ts(719,62): error TS2339: Property 'LINE' does not exist o
n type 'typeof TYPE'.
../../../handlers/para-handler.ts(510,52): error TS2339: Property 'RUN_ELEMENT'
does not exist on type 'typeof TYPE'.
../../../handlers/para-handler.ts(522,51): error TS2339: Property 'BLOCK' does n
ot exist on type 'typeof TYPE'.
../../../handlers/para-handler.ts(565,52): error TS2339: Property 'RUN_ELEMENT'
does not exist on type 'typeof TYPE'.
../../../handlers/para-handler.ts(570,52): error TS2339: Property 'BLOCK' does n
ot exist on type 'typeof TYPE'.
../../../handlers/text-handler.ts(63,42): error TS2339: Property 'RUN_ELEMENT' d
oes not exist on type 'typeof TYPE'.
../../../handlers/text-handler.ts(99,42): error TS2339: Property 'LINE' does not
 exist on type 'typeof TYPE'.
../../../handlers/text-handler.ts(108,41): error TS2339: Property 'BLOCK' does n
ot exist on type 'typeof TYPE'.
../../../handlers/text-handler.ts(561,39): error TS2339: Property 'POSITION' doe
s not exist on type 'typeof TYPE'.
../../../handlers/text-handler.ts(571,39): error TS2339: Property 'LINE' does no
t exist on type 'typeof TYPE'.
../../elements/paragraph/line.ts(127,41): error TS2339: Property 'LINE' does not
 exist on type 'typeof TYPE'.
../../elements/position.ts(75,40): error TS2339: Property 'POSITION' does not ex
ist on type 'typeof TYPE'.
../../elements/position.ts(184,59): error TS2339: Property 'ABSOLUTE_POSITION' d
oes not exist on type 'typeof TYPE'.
../../elements/position.ts(193,40): error TS2339: Property 'ABSOLUTE_POSITION' d
oes not exist on type 'typeof TYPE'.
../../elements/run/run.ts(57,40): error TS2339: Property 'RUN_ELEMENT' does not
exist on type 'typeof TYPE'.
../../list-body.ts(537,41): error TS2339: Property 'LINE' does not exist on type
 'typeof TYPE'.
../paragraph/line.ts(127,41): error TS2339: Property 'LINE' does not exist on ty
pe 'typeof TYPE'.
../paragraph/paragraph-properties.ts(429,14): error TS2421: Class 'ParagraphProp
ertyValues' incorrectly implements interface 'IParagraphPropertyValues':
  Types of property 'parent' are incompatible:
    Type 'Paragraph' is not assignable to type 'IParagraph':
      Types of property 'type' are incompatible:
        Type 'TYPE' is not assignable to type 'TYPE'.
../paragraph/paragraph.ts(94,14): error TS2416: Class 'Paragraph' incorrectly ex
tends base class 'Line':
  Types of property 'isType' are incompatible:
    Type '(type: TYPE) => boolean' is not assignable to type '(type: TYPE) => bo
olean':
      Types of parameters 'type' and 'type' are incompatible:
        Type 'TYPE' is not assignable to type 'TYPE'.
../paragraph/paragraph.ts(94,14): error TS2421: Class 'Paragraph' incorrectly im
plements interface 'IParagraph':
  Types of property 'props' are incompatible:
    Type 'ParagraphPropertyValues' is not assignable to type 'IParagraphProperty
Values'.
../paragraph/paragraph.ts(193,29): error TS2345: Argument of type 'TYPE' is not
assignable to parameter of type 'TYPE'.
../paragraph/paragraph.ts(230,13): error TS2323: Type 'Paragraph' is not assigna
ble to type 'IParagraph'.
../paragraph/paragraph.ts(248,34): error TS2353: Neither type 'IParagraphPropert
yValues' nor type 'ParagraphPropertyValues' is assignable to the other:
  Property 'className' is missing in type 'IParagraphPropertyValues'.
../paragraph/paragraph.ts(255,75): error TS2345: Argument of type 'Paragraph' is
 not assignable to parameter of type 'Paragraph'.
../paragraph/paragraph.ts(274,22): error TS2345: Argument of type 'Paragraph' is
 not assignable to parameter of type 'Line'.
../paragraph/paragraph.ts(306,30): error TS2345: Argument of type 'Paragraph' is
 not assignable to parameter of type 'IParagraph'.
../paragraph/paragraph.ts(385,13): error TS2365: Operator '!==' cannot be applie
d to types 'SUFFIX' and 'SUFFIX'.
../paragraph/paragraph.ts(386,17): error TS2365: Operator '===' cannot be applie
d to types 'SUFFIX' and 'SUFFIX'.
../paragraph/paragraph.ts(562,41): error TS2345: Argument of type 'Paragraph' is
 not assignable to parameter of type 'Line'.
../paragraph/paragraph.ts(602,28): error TS2353: Neither type 'Element' nor type
 'RunProperties' is assignable to the other:
  Types of property 'type' are incompatible:
    Type 'TYPE' is not assignable to type 'TYPE'.
../paragraph/paragraph.ts(619,36): error TS2345: Argument of type 'RunProperties
' is not assignable to parameter of type 'Element[]'.
../paragraph/paragraph.ts(622,51): error TS2345: Argument of type 'RunProperties
' is not assignable to parameter of type 'Element[]'.
../paragraph/paragraph.ts(636,15): error TS2353: Neither type 'Element' nor type
 'RunPropertyValues' is assignable to the other:
  Property 'parent' is missing in type 'Element'.
../paragraph/paragraph.ts(695,16): error TS2353: Neither type 'Element' nor type
 'Paragraph' is assignable to the other:
  Property 'docHeader' is missing in type 'Element'.
../paragraph/tab.ts(241,37): error TS2345: Argument of type 'ArrayList<TabAttrib
utes>' is not assignable to parameter of type 'ArrayList<TabAttributes>'.
  Type 'TabAttributes' is not assignable to type 'TabAttributes'.
../paragraph/tab.ts(295,60): error TS2345: Argument of type 'ArrayList<TabAttrib
utes>' is not assignable to parameter of type 'ArrayList<TabAttributes>'.
  Type 'TabAttributes' is not assignable to type 'TabAttributes'.
../position.ts(75,40): error TS2339: Property 'POSITION' does not exist on type
'typeof TYPE'.
../position.ts(184,59): error TS2339: Property 'ABSOLUTE_POSITION' does not exis
t on type 'typeof TYPE'.
../position.ts(193,40): error TS2339: Property 'ABSOLUTE_POSITION' does not exis
t on type 'typeof TYPE'.
../run/run-properties.ts(729,46): error TS2345: Argument of type 'REGION' is not
 assignable to parameter of type 'REGION'.
../run/run.ts(57,40): error TS2339: Property 'RUN_ELEMENT' does not exist on typ
e 'typeof TYPE'.
../section.ts(395,59): error TS2345: Argument of type 'Section' is not assignabl
e to parameter of type 'Section'.
../section.ts(792,67): error TS2345: Argument of type 'Section' is not assignabl
e to parameter of type 'Section'.
../table/table.ts(133,16): error TS2353: Neither type 'Element' nor type 'Row' i
s assignable to the other:
  Property 'props' is missing in type 'Element'.
line.ts(127,41): error TS2339: Property 'LINE' does not exist on type 'typeof TY
PE'.
paragraph-properties.ts(429,14): error TS2421: Class 'ParagraphPropertyValues' i
ncorrectly implements interface 'IParagraphPropertyValues':
  Types of property 'parent' are incompatible:
    Type 'Paragraph' is not assignable to type 'IParagraph':
      Types of property 'type' are incompatible:
        Type 'TYPE' is not assignable to type 'TYPE'.
paragraph.ts(94,14): error TS2416: Class 'Paragraph' incorrectly extends base cl
ass 'Line':
  Types of property 'isType' are incompatible:
    Type '(type: TYPE) => boolean' is not assignable to type '(type: TYPE) => bo
olean':
      Types of parameters 'type' and 'type' are incompatible:
        Type 'TYPE' is not assignable to type 'TYPE'.
paragraph.ts(94,14): error TS2421: Class 'Paragraph' incorrectly implements inte
rface 'IParagraph':
  Types of property 'props' are incompatible:
    Type 'ParagraphPropertyValues' is not assignable to type 'IParagraphProperty
Values'.
paragraph.ts(193,29): error TS2345: Argument of type 'TYPE' is not assignable to
 parameter of type 'TYPE'.
paragraph.ts(230,13): error TS2323: Type 'Paragraph' is not assignable to type '
IParagraph'.
paragraph.ts(248,34): error TS2353: Neither type 'IParagraphPropertyValues' nor
type 'ParagraphPropertyValues' is assignable to the other:
  Property 'className' is missing in type 'IParagraphPropertyValues'.
paragraph.ts(255,75): error TS2345: Argument of type 'Paragraph' is not assignab
le to parameter of type 'Paragraph'.
paragraph.ts(274,22): error TS2345: Argument of type 'Paragraph' is not assignab
le to parameter of type 'Line'.
paragraph.ts(306,30): error TS2345: Argument of type 'Paragraph' is not assignab
le to parameter of type 'IParagraph'.
paragraph.ts(385,13): error TS2365: Operator '!==' cannot be applied to types 'S
UFFIX' and 'SUFFIX'.
paragraph.ts(386,17): error TS2365: Operator '===' cannot be applied to types 'S
UFFIX' and 'SUFFIX'.
paragraph.ts(562,41): error TS2345: Argument of type 'Paragraph' is not assignab
le to parameter of type 'Line'.
paragraph.ts(602,28): error TS2352: Neither type 'Element' nor type 'RunProperti
es' is assignable to the other.
paragraph.ts(619,36): error TS2345: Argument of type 'RunProperties' is not assi
gnable to parameter of type 'Element[]'.
paragraph.ts(622,51): error TS2345: Argument of type 'RunProperties' is not assi
gnable to parameter of type 'Element[]'.
paragraph.ts(636,15): error TS2352: Neither type 'Element' nor type 'RunProperty
Values' is assignable to the other.
paragraph.ts(695,16): error TS2353: Neither type 'Element' nor type 'Paragraph'
is assignable to the other:
  Property 'docHeader' is missing in type 'Element'.
tab.ts(241,37): error TS2345: Argument of type 'ArrayList<TabAttributes>' is not
 assignable to parameter of type 'ArrayList<TabAttributes>'.
  Type 'TabAttributes' is not assignable to type 'TabAttributes'.
tab.ts(295,60): error TS2345: Argument of type 'ArrayList<TabAttributes>' is not
 assignable to parameter of type 'ArrayList<TabAttributes>'.
  Type 'TabAttributes' is not assignable to type 'TabAttributes'.

1 个答案:

答案 0 :(得分:3)

当我更新到1.3时,我已经遇到了完全相同的问题,经过一段时间的挖掘后我才得到答案。

1.3编译器显然不喜欢相对路径,因此您必须仅对所有编译器参数使用绝对路径。

特别针对我的问题是TypeScript文件观察程序参数中的$FileName$(相对路径)宏。
将其更改为$FilePath$(绝对路径)会修复它。