David Thielen
David Thielen

Reputation: 32926

typescript 1.3 sometimes giving false type mis-match errors

I am getting the following sometimes when I compile using a WebStorm file watcher which runs tsc:

../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'.

I'm getting about 20 of these. When I compile using VS2013, no problem. When I run the code, no problem. But the compiler seems to choke on a bunch of this stuff. This only started happening when we upgraded to typescript 1.3.

Clarification: When I do a build all using VisualStudio, I get no errors or warnings from the typescript compile. When WebStorm compiles, I sometimes get it. But WebStorm is just passing the compiler output back to the display.

What's going on?

Update - here's the output compiling in a DOS box:

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'.

Upvotes: 4

Views: 5171

Answers (1)

Acidic
Acidic

Reputation: 6282

I've had the exact same issue when I updated to 1.3, after digging for quite some time I've come across the answer.

The 1.3 compiler apparently doesn't like relative paths, so you must use only absolute paths for all compiler arguments.

The problem specifically for me was the $FileName$ (relative path) macro in the TypeScript file watcher arguments.
Changing it to $FilePath$ (absolute path) fixed it.

Upvotes: 3

Related Questions