You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importMagicStringfrom"magic-string";consts=newMagicString('Hello world');constmap=s.generateMap({});const[firstSourcesContent]=map.sourcesContent;console.log(firstSourcesContent.charAt(0));// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^// TypeError: Cannot read properties of null (reading 'charAt')// at <anonymous> (/x/y/repro/index.ts:14:33)
// This should not raise tsc errorsmap.sourcesContent[0]=null// ^^^^^^^^^^^^^^^^^^// Type 'null' is not assignable to type 'string'.ts(2322)
Based on the standard the implementation works correctly:
Proposed Format
[...]
6. "sourcesContent": [null, null],
[...]
Line 6: An optional list of source content, useful when the “source” can’t be hosted. The contents are listed in the same order as the sources in line 5. “null” may be used if some original sources should be retrieved by name.
Typings of the
sourcesContent
isstring[]
:magic-string/index.d.ts
Line 38 in 69b13c7
magic-string/index.d.ts
Line 49 in 69b13c7
The implementation may return
{ sourcesContent: [null] }
whenincludeContent = false
(default value) is used:magic-string/src/MagicString.js
Line 168 in 69b13c7
Minimal reproduction
Based on the standard the implementation works correctly:
Related downstream bug:
The text was updated successfully, but these errors were encountered: