-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Broken TypeScript typings. #19
Comments
This lib should be import via the second way. I run test this lib from scratch, just found that, you may need to update your check Typescript 2.7(just search esModuleInterop) for more details. Here is the complete {
"compilerOptions": {
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es7"],
"experimentalDecorators": true,
"emitDecoratorMetadata": false,
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
"strictFunctionTypes": false,
"esModuleInterop": true,
"allowJs": true,
"baseUrl": "."
},
"exclude": ["node_modules"]
} |
2. added typescript usage notice in readme, #19
This lib exports both commonjs and es6 files, but commonjs file will be required by default , So you may need to add this option https://github.com/evecalm/truncate-html/blob/master/package.json#L5-L7 |
Setting From docs:
|
I'm a little confused, if set check the code of this lib: https://github.com/evecalm/truncate-html/blob/master/src/truncate.ts#L1 https://github.com/evecalm/truncate-html/blob/master/tsconfig.json#L2-L19 |
close it, I assume you solved this problem. Feel free to reopen it if you have any further questions. |
I solved the problem differently. I use |
It should works in my way. You may try it your self by following steps: git clone https://github.com/evecalm/truncate-html.git
cd truncate-html
yarn add dayjs then edit import dayjs from 'dayjs'
console.log('test dayjs', dayjs.isDayjs()) run the code to test: |
When I import
trucate-html
using:Then I'm not able to call
truncate("<p>my-html</p>")
because TypeScript compiler complains that:I'm also not able to call
truncate.setup()
.When I import
trucate-html
using:Then TypeScript compiler doesn't complain, but there are runtime errors after compilation because
truncate
is undefined when imported this way.The text was updated successfully, but these errors were encountered: