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

fix type error #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix type error #18

wants to merge 1 commit into from

Conversation

Aqzhyi
Copy link

@Aqzhyi Aqzhyi commented Dec 4, 2021

webpack-internal:///./node_modules/opencc-js/bundle-node.js:97
      const n = s.length, arr = [];
                  ^

TypeError: Cannot read properties of undefined (reading 'length')
    at Trie.convert (webpack-internal:///./node_modules/opencc-js/bundle-node.js:97:19)
    at convert (webpack-internal:///./node_modules/opencc-js/bundle-node.js:170:48)
    at pushRssToChannel (webpack-internal:///./src/news/pushRssToChannel.ts:31:39)
    at eval (webpack-internal:///./src/bot/botStart.ts:51:52)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...

```
webpack-internal:///./node_modules/opencc-js/bundle-node.js:97
      const n = s.length, arr = [];
                  ^

TypeError: Cannot read properties of undefined (reading 'length')
    at Trie.convert (webpack-internal:///./node_modules/opencc-js/bundle-node.js:97:19)
    at convert (webpack-internal:///./node_modules/opencc-js/bundle-node.js:170:48)
    at pushRssToChannel (webpack-internal:///./src/news/pushRssToChannel.ts:31:39)
    at eval (webpack-internal:///./src/bot/botStart.ts:51:52)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...
```
Copy link
Member

@ayaka14732 ayaka14732 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s is expected to be a string. For this issue, we should fix the caller instead of modifying this function

@Aqzhyi
Copy link
Author

Aqzhyi commented Dec 27, 2021

s is expected to be a string. For this issue, we should fix the caller instead of modifying this function

Hi, greetings, what do you mean? Which caller?

Do you mean I should fix it on my application itself and not this package?

I tried several ways but I can't fix it unless modifying this package.

import * as OpenCC from 'opencc-js'

export const toTW = OpenCC.Converter({ from: 'cn', to: 'tw' })

It builds ok, but broke after running npm start

Or maybe, what is your suggestions for updating the pull request?

@ayaka14732
Copy link
Member

Hi, @Aqzhyi. I have just checked and I can run your code without any errors.

import * as OpenCC from 'opencc-js';
const toTW = OpenCC.Converter({ from: 'cn', to: 'tw' });
console.log(toTW('吃面'));  // 吃麵

@Aqzhyi
Copy link
Author

Aqzhyi commented Dec 27, 2021

ok, thank you many thanks, let me do more trials.

failed on Linode and netlify. but local looks working.

screenshot-xKae9cWU

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.

None yet

2 participants