TypeScript: Replacement character (`\uFFFD`) in JavaScript/TypeScript causes to breaks

๐Ÿ”Ž Search Terms

  • TS1490: File appears to be binary
  • replacement character

๐Ÿ•— Version & Regression Information

#57008 is incorrect on some real files.

โฏ Playground Link

https://github.com/micromark/micromark/pull/166

๐Ÿ’ป Code

Note the ๏ฟฝ in the first 256 characters.

import assert from 'node:assert/strict'
import test from 'node:test'
import {micromark} from 'micromark'

test('nul', function () {
  assert.equal(
    micromark('asd\0asd'),
    '<p>asd๏ฟฝasd</p>',
    'should replace `\\0` w/ a replacement characters (`๏ฟฝ`)'
  )
})

๐Ÿ™ Actual behavior

error TS1490: File appears to be binary

๐Ÿ™‚ Expected behavior

0xFFFD should be fine among other regular characters.

Additional information about the issue

Related-to: #21136. Related-to: #56516. Related-to: #57008.

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Situation: \ufffd exists because it shouldnโ€™t ever appear in a correctly-encoded file on purpose

โ€œWe need to put a raw \ufffd in a file so we can test itโ€

Situation: \ufffd exists in a correctly-encoded file on purpose

https://xkcd.com/927/