DataTables merge namespaces
DataTables merge namespaces
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown: Property 'responsive' does not exist on type 'Api<any>'.
Description of problem: Typescript Merging namespace is not working
I'm using only datatables.net sources type not @types/datatables.net package
these are third-party type packages:
"@types/datatables.net": "^1.10.22",
"@types/datatables.net-autofill": "^2.2.1",
"@types/datatables.net-buttons": "^1.4.7",
"@types/datatables.net-colreorder": "^1.4.2",
"@types/datatables.net-fixedcolumns": "^3.3.1",
"@types/datatables.net-fixedheader": "^3.1.5",
"@types/datatables.net-keytable": "^2.5.1",
"@types/datatables.net-rowgroup": "^1.1.2",
"@types/datatables.net-rowreorder": "^1.1.3",
"@types/datatables.net-scroller": "^1.4.1",
"@types/datatables.net-select": "^1.2.7",
//
"@types/datatables.net-responsive": "not-exist",
"@types/datatables.net-searchbuilder": "not-exist",
"@types/datatables.net-searchpanes": "not-exist",
"@types/datatables.net-staterestore": "not-exist",
if I use these packages, available packages interface and namespaces merged together but with some error for non-existence package type like responsive
https://www.typescriptlang.org/docs/handbook/module-resolution.html
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
https://stackoverflow.com/questions/48704150/how-to-configure-tsconfig-json-for-typings-not-in-types
if I use datatables.net types in types/types.d.ts with
1. /// <reference types="..." /> in index.d.ts
2. or import types with import in index.ts
3. type in tsconfig
namespace and interface will not be merged together and only last imported type will be include
Replies
@allan
datatables.net=> types/types.d.tswhat is
newkeyword here ? an example pleasenewis refers tonew constructor?@types/datatables.netwithout generic typehttps://github.com/sadeghbarati/datatables.net-typescript-usage/tree/main/src
Tested vscode Typescript
and Takeover Typescript with Volar
both has typescript errors
https://datatables.net/forums/discussion/comment/203190/
sorry after some investigation find out
namespaceare being merged togetherbut only for core options in
datatables.netlike Datatables.SettingsExtensionsdon't have type definition, like if you writealso when you import
example: https://github.com/sadeghbarati/datatables.net-typescript-usage
@allan
@colin
hi
can you guys take a look to this issue ?
here test case with codesandbox
https://codesandbox.io/s/nostalgic-ishizaka-31yfdc?file=/src/datatables.ts