In a Javascript file that is checked by flow, we may see code like this (from create-react-app/packages/react-error-overlay/src/utils/parseCompileError.js)
exporttypeErrorLocation={|fileName: string,lineNumber: number,colNumber?: number,|}functionparseCompileError(message: string): ?ErrorLocation{constlines: Array<string> = message.split('\n');
for (let i = 0; i <lines.length;i++){// ...................returnfileName&&lineNumber ? { fileName, lineNumber, colNumber } : null;}This behaves badly when the typescript compiler compiles it with checkJs on:
Expected behavior:
- Errors on the type declaration and all the type annotations.
- However, ErrorLocation should be declared as a type alias, and message, lines, etc should all have their declared types.
- If they are used incorrectly, they should have errors.
Actual behavior:
- Errors on the type declaration and all the type annotations.
In the language service:
2. message, lines, etc have the correct types, but ErrorLocation is type any.
3. If they are used incorrectly, they have errors.
In batch compilation:
2. No errors show up except those from (1), even if there are lots of other javascript files without type annotations.
In a Javascript file that is checked by flow, we may see code like this (from create-react-app/packages/react-error-overlay/src/utils/parseCompileError.js)
This behaves badly when the typescript compiler compiles it with checkJs on:
Expected behavior:
Actual behavior:
In the language service:
2. message, lines, etc have the correct types, but ErrorLocation is type any.
3. If they are used incorrectly, they have errors.
In batch compilation:
2. No errors show up except those from (1), even if there are lots of other javascript files without type annotations.