Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong typing of SourceMap.version #2967

Closed
theseanl opened this issue Jun 26, 2019 · 1 comment · Fixed by #2976
Closed

Wrong typing of SourceMap.version #2967

theseanl opened this issue Jun 26, 2019 · 1 comment · Fixed by #2976

Comments

@theseanl
Copy link

theseanl commented Jun 26, 2019

  • Rollup Version: 1.16.2
  • Operating System (or Browser):
  • Node Version: v12.4.0

How Do We Reproduce?

Try using map property of OutputBundle object in generateBundle hook
as a return value { code, map } of a load hook

Expected Behavior

Does not produce any type error.

Actual Behavior

[tsserver 2322] [E] Type '{ file: string; mappings: string; names: string[];   
sources: string[]; sourcesContent: string[]; version: string; toString():       
string; toUrl(): string; }' is not assignable to type 'string |                
ExistingRawSourceMap | { mappings: ""; }'.                                     
Type '{ file: string; mappings: string; names: string[]; sources: string[];  
sourcesContent: string[]; version: string; toString(): string; toUrl(): string 
; }' is not assignable to type 'ExistingRawSourceMap'.                         
Types of property 'version' are incompatible.    

There is a wrong type definition of SourceMap.version in https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L59
magic-string sets the version property as 3, but the type declaration declares its type as string.

This is a propagation of a wrong type declaration of magic-string package, which is fixed in master branch in this Feb but not yet published to NPM: Rich-Harris/magic-string@b6fd47d

This prevents e.g. feeding OutputChunk output from generateBundle as a return value of another rollup plugin's load hook.

In order to resolve this issue, magic-string package must be updated in NPM with the current master branch, its version in rollup must be increased, and the type in src/rollup/type.d.ts must be updated.

@lukastaegert
Copy link
Member

Fix at #2976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants