facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.09k stars 1.86k forks source link

Unicode in type-at-pos is broken #8013

Open goodmind opened 5 years ago

goodmind commented 5 years ago

Flow version: 0.105.0

const d: {'фу-бар': number} = {}

Expected behavior

{ 'фу-бар': number }

Actual behavior

{ "\u0444\u0443-\u0431\u0430\u0440": number }
goodmind commented 5 years ago

Color is off in errors too image But error message itself is fine

Cannot assign object literal to d because property фу-бар is missing in object literal [1] but exists in object
type [2].
mroch commented 5 years ago

I was looking into a related issue recently. this is because Flow reports locations in UTF8 but JS counts in Unicode code units. I started adding an encoding flag, so that you can choose; the CLI would default to UTF8, and flow_parser.js and flow.js would default to UCS2/UTF16.

mroch commented 5 years ago

actually this could be a separate place that uses the wrong encoding, but I think the fixes will be similar.