Skip to content

Fix bplist-parser import error#65

Closed
dnicolson wants to merge 3 commits intowollardj:mainfrom
dnicolson:fix-esm-imports
Closed

Fix bplist-parser import error#65
dnicolson wants to merge 3 commits intowollardj:mainfrom
dnicolson:fix-esm-imports

Conversation

@dnicolson
Copy link
Copy Markdown
Contributor

@dnicolson dnicolson commented May 3, 2022

This pull request removes TypeScript types in favor of types upstream (joeferner/node-bplist-creator#22, joeferner/node-bplist-parser#34) and also fixes the import of bplist-parser. It's possible that it resolves #58.

The following code works with version 1.3.0:

import * as plist from 'simple-plist';
console.log(plist)

The following code with adjusted import doesn't work with version 1.3.1 and results in an error:

import plist from 'simple-plist';
console.log(plist)
node_modules/simple-plist/dist/index.d.ts:2:8 - error TS1259: Module '".../node_modules/simple-plist/node_modules/bplist-parser/bplistParser"' can only be default-imported using the 'esModuleInterop' flag

2 import bplistParser from "bplist-parser";
         ~~~~~~~~~~~~

  node_modules/simple-plist/node_modules/bplist-parser/bplistParser.d.ts:6:1
    6 export = bPlistParser
      ~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

@dnicolson dnicolson changed the title Replace TypeScript types and fix import Fix bplistParser import error May 7, 2022
@dnicolson dnicolson changed the title Fix bplistParser import error Fix bplist-parser import error May 7, 2022
@oliverschwendener
Copy link
Copy Markdown

Are there any plans to merge this soon? Would be great as I'm experiencing the issue mentioned in #58

@wollardj
Copy link
Copy Markdown
Owner

I haven't looked it over thoroughly yet, but I'll do my best to get this moving along this week.

@wollardj
Copy link
Copy Markdown
Owner

@dnicolson / @oliverschwendener - found some additional issues and ended up covering much of what was in this PR. Could either of you try v1.4.0 (simple-plist@next) and let me know if it solves the problems you're facing?

@oliverschwendener
Copy link
Copy Markdown

For me it works like a charm, thanks alot!

@dnicolson
Copy link
Copy Markdown
Contributor Author

I get these errors with 1.4.0:

node_modules/simple-plist/dist/index.d.ts:1:10 - error TS2305: Module '"bplist-creator"' has no exported member 'default'.

1 export { default as bplistCreator } from "bplist-creator";
           ~~~~~~~

node_modules/simple-plist/dist/index.d.ts:2:10 - error TS2305: Module '"bplist-parser"' has no exported member 'default'.

2 export { default as bplistParser } from "bplist-parser";
           ~~~~~~~

node_modules/simple-plist/dist/parse.d.ts:3:33 - error TS7016: Could not find a declaration file for module 'plist'. 'node_modules/plist/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/plist` if it exists or add a new declaration (.d.ts) file containing `declare module 'plist';`

3 import type { PlistValue } from "plist";

@wollardj
Copy link
Copy Markdown
Owner

@dnicolson I'm not able to reproduce that. Is that in a clean project? I'm wondering if there might be some stale caches laying around on your local or something strange like that.

@wollardj
Copy link
Copy Markdown
Owner

hmm...now that I've cleared my own caches I'm seeing similar errors, though not identical for some reason. I'll keep poking around a bit to see what I can find.

@wollardj
Copy link
Copy Markdown
Owner

wollardj commented Jul 10, 2022

@dnicolson - I'm still having trouble reproducing that exact error, but I've just published 1.4.0-0 which moves the @types/plist package to the dependencies instead of devDependencies. That seems like it should address at least 33% of what you're seeing.

Edit:

If I try your approach of using * instead of default, typescript is throwing an error
image

I'm not sure how you were able to get that to work - can you think of anything relevant?

@dnicolson
Copy link
Copy Markdown
Contributor Author

I'm not sure our approaches are the same, it was a bplist-parser import and not a bplist-creator export.

I see similar errors with version 1.4.0-0:

node_modules/simple-plist/dist/index.d.ts:1:10 - error TS2305: Module '"bplist-creator"' has no exported member 'default'.

1 export { default as bplistCreator } from "bplist-creator";
           ~~~~~~~

node_modules/simple-plist/dist/index.d.ts:2:10 - error TS2305: Module '"bplist-parser"' has no exported member 'default'.

2 export { default as bplistParser } from "bplist-parser";
           ~~~~~~~

src/plist-file-format.ts:85:40 - error TS2345: Argument of type 'PlistValue' is not assignable to parameter of type 'PlistJsObj'.
  Type 'string' is not assignable to type 'PlistJsObj'.

85         plist.writeBinaryFileSync(uri, object);
                                          ~~~~~~

@dnicolson dnicolson mentioned this pull request Oct 16, 2022
@dnicolson dnicolson closed this Apr 30, 2023
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 this pull request may close these issues.

Cannot find module 'bplist-creator'

3 participants