tsup version: 6.6.3
// center.ts
declare global {
interface String {
center(width: number, fillChar?: string): string;
}
}
Sring.prototype.center=function (width:number,fillChar=" ") {
let s=this
let llength=Math.floor((width-s.length)/2)
return new Array(llength).join(fillChar)+s+new Array(width-s.length-llength).join(fillChar)
}
export {} // necessary
import { defineConfig } from 'tsup'
export default defineConfig({
entry: [
'src/*.ts'
],
format: ['esm','cjs'],
dts: true,
splitting: true,
sourcemap: false,
clean: true,
treeshake:true,
minify: true,
// center.d.ts
declare global {
interface String {
center(width: number, fillChar?: string): string;
}
}
export {}
removed,causes String.prototype.center
to be unrecognized。
I have to use a hacker method:
// center.ts
declare global {
interface String {
center(width: number, fillChar?: string): string;
}
}
Sring.prototype.center=function (width:number,fillChar=" ") {
let s=this
let llength=Math.floor((width-s.length)/2)
return new Array(llength).join(fillChar)+s+new Array(width-s.length-llength).join(fillChar)
}
export const _=0 // replace for export {}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too